typescript aws
parent
3d3f6f6cde
commit
5b2591bdea
|
|
@ -14,6 +14,9 @@ Metadata:
|
|||
TTL:
|
||||
default: Time-to-live
|
||||
Parameters:
|
||||
BUILDID:
|
||||
Type: String
|
||||
Default: ''
|
||||
StackName:
|
||||
Type: String
|
||||
Description: Stack name that will be deleted.
|
||||
|
|
@ -33,7 +36,7 @@ Resources:
|
|||
Action: "sts:AssumeRole"
|
||||
Path: "/"
|
||||
Policies:
|
||||
- PolicyName: !Sub "DeleteLambdaExRole-${StackName}"
|
||||
- PolicyName: !Sub "DeleteLambdaExRole-${BUILDID}"
|
||||
PolicyDocument:
|
||||
Version: "2012-10-17"
|
||||
Statement:
|
||||
|
|
@ -46,13 +49,13 @@ Resources:
|
|||
- Effect: "Allow"
|
||||
Action:
|
||||
- "cloudformation:DeleteStack"
|
||||
Resource: !Sub "arn:aws:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/${StackName}/*"
|
||||
Resource: !Sub "arn:aws:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/${BUILDID}/*"
|
||||
DeleteCFNLambda:
|
||||
Type: "AWS::Lambda::Function"
|
||||
DependsOn:
|
||||
- DeleteCFNLambdaExecutionRole
|
||||
Properties:
|
||||
FunctionName: !Sub "DeleteCFNLambda-${StackName}"
|
||||
FunctionName: !Sub "DeleteCFNLambda-${BUILDID}"
|
||||
Code:
|
||||
ZipFile: |
|
||||
import boto3
|
||||
|
|
@ -87,7 +90,7 @@ Resources:
|
|||
- GenerateCronExpression
|
||||
Type: "AWS::Events::Rule"
|
||||
Properties:
|
||||
Name: !Sub "DeleteStackEventRule-${StackName}"
|
||||
Name: !Sub "DeleteStackEventRule-${BUILDID}"
|
||||
Description: Delete stack event
|
||||
ScheduleExpression: !GetAtt GenerateCronExpression.cron_exp
|
||||
State: "ENABLED"
|
||||
|
|
@ -98,7 +101,7 @@ Resources:
|
|||
PermissionForDeleteCFNLambda:
|
||||
Type: "AWS::Lambda::Permission"
|
||||
Properties:
|
||||
FunctionName: !Sub "DeleteCFNLambda-${StackName}"
|
||||
FunctionName: !Sub "DeleteCFNLambda-${BUILDID}"
|
||||
Action: "lambda:InvokeFunction"
|
||||
Principal: "events.amazonaws.com"
|
||||
SourceArn: !GetAtt DeleteStackEventRule.Arn
|
||||
|
|
@ -114,7 +117,7 @@ Resources:
|
|||
Action: "sts:AssumeRole"
|
||||
Path: "/"
|
||||
Policies:
|
||||
- PolicyName: !Sub "BasicLambdaExecutionRole-${StackName}"
|
||||
- PolicyName: !Sub "BasicLambdaExecutionRole-${BUILDID}"
|
||||
PolicyDocument:
|
||||
Version: "2012-10-17"
|
||||
Statement:
|
||||
|
|
@ -127,7 +130,7 @@ Resources:
|
|||
GenerateCronExpLambda:
|
||||
Type: "AWS::Lambda::Function"
|
||||
Properties:
|
||||
FunctionName: !Sub "MakeCronLambda-${StackName}"
|
||||
FunctionName: !Sub "MakeCronLambda-${BUILDID}"
|
||||
Code:
|
||||
ZipFile: |
|
||||
from datetime import datetime, timedelta
|
||||
|
|
@ -171,6 +174,6 @@ Resources:
|
|||
Type: "Custom::GenerateCronExpression"
|
||||
Version: "1.0"
|
||||
Properties:
|
||||
Name: !Sub "GenerateCronExpression-${StackName}"
|
||||
Name: !Sub "GenerateCronExpression-${BUILDID}"
|
||||
ServiceToken: !GetAtt GenerateCronExpLambda.Arn
|
||||
ttl: !Ref 'TTL'
|
||||
|
|
|
|||
Loading…
Reference in New Issue