diff --git a/templates/aws-stack.yml b/templates/aws-stack.yml index 6f2a78af6..ac4528e93 100644 --- a/templates/aws-stack.yml +++ b/templates/aws-stack.yml @@ -418,6 +418,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 + Rules: HasToken: Assertions: @@ -567,6 +573,9 @@ 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: '' } @@ -1044,7 +1053,9 @@ Resources: TerminationPolicies: - OldestLaunchConfiguration - ClosestToNextInstanceHour + MaxInstanceLifetime: !If [UseMaxInstanceLifetime, !Ref MaxInstanceLifetime, !Ref "AWS::NoValue"] NewInstancesProtectedFromScaleIn: true + CreationPolicy: ResourceSignal: Timeout: !If [ UseDefaultInstanceCreationTimeout, !If [ UseWindowsAgents, PT10M, PT5M ], !Ref InstanceCreationTimeout ]