From da91dd94caf9a4a160a6493397d2697201c921e4 Mon Sep 17 00:00:00 2001 From: nitrocode Date: Wed, 5 May 2021 23:07:00 -0400 Subject: [PATCH 1/2] Add MaxInstanceLifetime --- templates/aws-stack.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/templates/aws-stack.yml b/templates/aws-stack.yml index 2460a30f9..c388db512 100644 --- a/templates/aws-stack.yml +++ b/templates/aws-stack.yml @@ -407,6 +407,12 @@ Parameters: - "false" Default: "false" + MaxInstanceLifetime: + Type: Number + Description: The maximum amount of time, in seconds, that an instance can be in service. The default is null. If specified, the value must be either 0 or a number equal to or greater than 86,400 seconds (1 day). + Default: 0 + MinValue: 0 + Outputs: VpcId: Value: @@ -535,6 +541,10 @@ Conditions: - !Equals [ !Select [ 0, !Split [ ".", !Ref InstanceType ] ], "r6g" ] - !Equals [ !Select [ 0, !Split [ ".", !Ref InstanceType ] ], "r6gd" ] + UseMaxInstanceLifetime: + !Not [ !Equals [ !Ref MaxInstanceLifetime, 0 ] ] + + Mappings: ECRManagedPolicy: none : { Policy: '' } @@ -1013,6 +1023,7 @@ Resources: TerminationPolicies: - OldestLaunchConfiguration - ClosestToNextInstanceHour + MaxInstanceLifetime: !If [UseMaxInstanceLifetime, !Ref MaxInstanceLifetime, !Ref "AWS::NoValue"] CreationPolicy: ResourceSignal: Timeout: !If [ UseDefaultInstanceCreationTimeout, !If [ UseWindowsAgents, PT10M, PT5M ], !Ref InstanceCreationTimeout ] From 155478bb4200ac8323771708d85bea57dbd11faa Mon Sep 17 00:00:00 2001 From: nitrocode Date: Wed, 5 May 2021 23:10:01 -0400 Subject: [PATCH 2/2] Remove extra spacing --- templates/aws-stack.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/aws-stack.yml b/templates/aws-stack.yml index c388db512..c7aa8fe10 100644 --- a/templates/aws-stack.yml +++ b/templates/aws-stack.yml @@ -544,7 +544,6 @@ Conditions: UseMaxInstanceLifetime: !Not [ !Equals [ !Ref MaxInstanceLifetime, 0 ] ] - Mappings: ECRManagedPolicy: none : { Policy: '' }