ttl stack

pull/218/head
mdugdale 2021-03-11 22:12:29 +00:00
parent 4f4f226af6
commit dcbe1c3b48
3 changed files with 13 additions and 2 deletions

View File

@ -13,6 +13,9 @@ Metadata:
default: Stack name
TTL:
default: Time-to-live
BUILDID:
Type: String
Default: ''
Parameters:
StackName:
Type: String
@ -22,6 +25,7 @@ Parameters:
Description: Time-to-live in minutes for the stack.
Resources:
DeleteCFNLambdaExecutionRole:
Name: !Join [ "", [ 'DeleteCFNLambdaExecutionRole', !Ref BUILDID ] ]
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
@ -48,6 +52,7 @@ Resources:
- "cloudformation:DeleteStack"
Resource: !Sub "arn:aws:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/${StackName}/*"
DeleteCFNLambda:
Name: !Join [ "", [ 'DeleteCFNLambda', !Ref BUILDID ] ]
Type: "AWS::Lambda::Function"
DependsOn:
- DeleteCFNLambdaExecutionRole
@ -82,6 +87,7 @@ Resources:
Timeout: "5"
Role: !GetAtt DeleteCFNLambdaExecutionRole.Arn
DeleteStackEventRule:
Name: !Join [ "", [ 'DeleteStackEventRule', !Ref BUILDID ] ]
DependsOn:
- DeleteCFNLambda
- GenerateCronExpression
@ -95,6 +101,7 @@ Resources:
Arn: !GetAtt DeleteCFNLambda.Arn
Id: 'DeleteCFNLambda'
PermissionForDeleteCFNLambda:
Name: !Join [ "", [ 'PermissionForDeleteCFNLambda', !Ref BUILDID ] ]
Type: "AWS::Lambda::Permission"
Properties:
FunctionName: !Sub "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:DeleteCFNLambda-${StackName}"
@ -102,6 +109,7 @@ Resources:
Principal: "events.amazonaws.com"
SourceArn: !GetAtt DeleteStackEventRule.Arn
BasicLambdaExecutionRole:
Name: !Join [ "", [ 'BasicLambdaExecutionRole', !Ref BUILDID ] ]
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
@ -124,6 +132,7 @@ Resources:
- "logs:PutLogEvents"
Resource: "arn:aws:logs:*:*:*"
GenerateCronExpLambda:
Name: !Join [ "", [ 'GenerateCronExpLambda', !Ref BUILDID ] ]
Type: "AWS::Lambda::Function"
Properties:
Code:
@ -166,6 +175,7 @@ Resources:
Role: !GetAtt BasicLambdaExecutionRole.Arn
GenerateCronExpression:
Name: !Join [ "", [ 'GenerateCronExpression', !Ref BUILDID ] ]
Type: "Custom::GenerateCronExpression"
Version: "1.0"
Properties:

File diff suppressed because one or more lines are too long

View File

@ -276,7 +276,6 @@ class AWS {
try{
await CF.waitFor('stackCreateComplete', { StackName: taskDefStackName }).promise();
await CF.waitFor('stackCreateComplete', { StackName: taskDefStackName+"-ttl" }).promise();
}catch(error){
core.error(error);
}
@ -379,6 +378,8 @@ class AWS {
.promise()
).ShardIterator;
await CF.waitFor('stackCreateComplete', { StackName: taskDefStackName+"-ttl" }).promise();
core.info(`Task status is ${await getTaskStatus()}`);
const logBaseUrl = `https://console.aws.amazon.com/cloudwatch/home?region=${SDK.config.region}#logsV2:log-groups/${taskDefStackName}`;