ttl stack
parent
dcbe1c3b48
commit
2a0e93082a
|
|
@ -25,9 +25,9 @@ Parameters:
|
||||||
Description: Time-to-live in minutes for the stack.
|
Description: Time-to-live in minutes for the stack.
|
||||||
Resources:
|
Resources:
|
||||||
DeleteCFNLambdaExecutionRole:
|
DeleteCFNLambdaExecutionRole:
|
||||||
Name: !Join [ "", [ 'DeleteCFNLambdaExecutionRole', !Ref BUILDID ] ]
|
|
||||||
Type: "AWS::IAM::Role"
|
Type: "AWS::IAM::Role"
|
||||||
Properties:
|
Properties:
|
||||||
|
Name: !Join [ "", [ 'DeleteCFNLambdaExecutionRole', !Ref BUILDID ] ]
|
||||||
AssumeRolePolicyDocument:
|
AssumeRolePolicyDocument:
|
||||||
Version: "2012-10-17"
|
Version: "2012-10-17"
|
||||||
Statement:
|
Statement:
|
||||||
|
|
@ -52,11 +52,11 @@ Resources:
|
||||||
- "cloudformation:DeleteStack"
|
- "cloudformation:DeleteStack"
|
||||||
Resource: !Sub "arn:aws:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/${StackName}/*"
|
Resource: !Sub "arn:aws:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/${StackName}/*"
|
||||||
DeleteCFNLambda:
|
DeleteCFNLambda:
|
||||||
Name: !Join [ "", [ 'DeleteCFNLambda', !Ref BUILDID ] ]
|
|
||||||
Type: "AWS::Lambda::Function"
|
Type: "AWS::Lambda::Function"
|
||||||
DependsOn:
|
DependsOn:
|
||||||
- DeleteCFNLambdaExecutionRole
|
- DeleteCFNLambdaExecutionRole
|
||||||
Properties:
|
Properties:
|
||||||
|
Name: !Join [ "", [ 'DeleteCFNLambda', !Ref BUILDID ] ]
|
||||||
FunctionName: !Sub "DeleteCFNLambda-${StackName}"
|
FunctionName: !Sub "DeleteCFNLambda-${StackName}"
|
||||||
Code:
|
Code:
|
||||||
ZipFile: |
|
ZipFile: |
|
||||||
|
|
@ -87,12 +87,12 @@ Resources:
|
||||||
Timeout: "5"
|
Timeout: "5"
|
||||||
Role: !GetAtt DeleteCFNLambdaExecutionRole.Arn
|
Role: !GetAtt DeleteCFNLambdaExecutionRole.Arn
|
||||||
DeleteStackEventRule:
|
DeleteStackEventRule:
|
||||||
Name: !Join [ "", [ 'DeleteStackEventRule', !Ref BUILDID ] ]
|
|
||||||
DependsOn:
|
DependsOn:
|
||||||
- DeleteCFNLambda
|
- DeleteCFNLambda
|
||||||
- GenerateCronExpression
|
- GenerateCronExpression
|
||||||
Type: "AWS::Events::Rule"
|
Type: "AWS::Events::Rule"
|
||||||
Properties:
|
Properties:
|
||||||
|
Name: !Join [ "", [ 'DeleteStackEventRule', !Ref BUILDID ] ]
|
||||||
Description: Delete stack event
|
Description: Delete stack event
|
||||||
ScheduleExpression: !GetAtt GenerateCronExpression.cron_exp
|
ScheduleExpression: !GetAtt GenerateCronExpression.cron_exp
|
||||||
State: "ENABLED"
|
State: "ENABLED"
|
||||||
|
|
@ -101,17 +101,17 @@ Resources:
|
||||||
Arn: !GetAtt DeleteCFNLambda.Arn
|
Arn: !GetAtt DeleteCFNLambda.Arn
|
||||||
Id: 'DeleteCFNLambda'
|
Id: 'DeleteCFNLambda'
|
||||||
PermissionForDeleteCFNLambda:
|
PermissionForDeleteCFNLambda:
|
||||||
Name: !Join [ "", [ 'PermissionForDeleteCFNLambda', !Ref BUILDID ] ]
|
|
||||||
Type: "AWS::Lambda::Permission"
|
Type: "AWS::Lambda::Permission"
|
||||||
Properties:
|
Properties:
|
||||||
|
Name: !Join [ "", [ 'PermissionForDeleteCFNLambda', !Ref BUILDID ] ]
|
||||||
FunctionName: !Sub "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:DeleteCFNLambda-${StackName}"
|
FunctionName: !Sub "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:DeleteCFNLambda-${StackName}"
|
||||||
Action: "lambda:InvokeFunction"
|
Action: "lambda:InvokeFunction"
|
||||||
Principal: "events.amazonaws.com"
|
Principal: "events.amazonaws.com"
|
||||||
SourceArn: !GetAtt DeleteStackEventRule.Arn
|
SourceArn: !GetAtt DeleteStackEventRule.Arn
|
||||||
BasicLambdaExecutionRole:
|
BasicLambdaExecutionRole:
|
||||||
Name: !Join [ "", [ 'BasicLambdaExecutionRole', !Ref BUILDID ] ]
|
|
||||||
Type: "AWS::IAM::Role"
|
Type: "AWS::IAM::Role"
|
||||||
Properties:
|
Properties:
|
||||||
|
Name: !Join [ "", [ 'BasicLambdaExecutionRole', !Ref BUILDID ] ]
|
||||||
AssumeRolePolicyDocument:
|
AssumeRolePolicyDocument:
|
||||||
Version: "2012-10-17"
|
Version: "2012-10-17"
|
||||||
Statement:
|
Statement:
|
||||||
|
|
@ -132,9 +132,9 @@ Resources:
|
||||||
- "logs:PutLogEvents"
|
- "logs:PutLogEvents"
|
||||||
Resource: "arn:aws:logs:*:*:*"
|
Resource: "arn:aws:logs:*:*:*"
|
||||||
GenerateCronExpLambda:
|
GenerateCronExpLambda:
|
||||||
Name: !Join [ "", [ 'GenerateCronExpLambda', !Ref BUILDID ] ]
|
|
||||||
Type: "AWS::Lambda::Function"
|
Type: "AWS::Lambda::Function"
|
||||||
Properties:
|
Properties:
|
||||||
|
Name: !Join [ "", [ 'GenerateCronExpLambda', !Ref BUILDID ] ]
|
||||||
Code:
|
Code:
|
||||||
ZipFile: |
|
ZipFile: |
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
@ -175,9 +175,9 @@ Resources:
|
||||||
Role: !GetAtt BasicLambdaExecutionRole.Arn
|
Role: !GetAtt BasicLambdaExecutionRole.Arn
|
||||||
|
|
||||||
GenerateCronExpression:
|
GenerateCronExpression:
|
||||||
Name: !Join [ "", [ 'GenerateCronExpression', !Ref BUILDID ] ]
|
|
||||||
Type: "Custom::GenerateCronExpression"
|
Type: "Custom::GenerateCronExpression"
|
||||||
Version: "1.0"
|
Version: "1.0"
|
||||||
Properties:
|
Properties:
|
||||||
|
Name: !Join [ "", [ 'GenerateCronExpression', !Ref BUILDID ] ]
|
||||||
ServiceToken: !GetAtt GenerateCronExpLambda.Arn
|
ServiceToken: !GetAtt GenerateCronExpLambda.Arn
|
||||||
ttl: !Ref 'TTL'
|
ttl: !Ref 'TTL'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue