Skip to content

Commit 916dfe1

Browse files
committed
Only terminate on shutdown when BuildkiteTerminateInstanceAfterJob is true
1 parent 11a5832 commit 916dfe1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

templates/aws-stack.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,9 @@ Conditions:
699699
UseStackNameForInstanceName:
700700
!Equals [ !Ref InstanceName, "" ]
701701

702+
TerminateInstanceAfterJob:
703+
!Equals [ !Ref BuildkiteTerminateInstanceAfterJob, "true" ]
704+
702705
Mappings:
703706
ECRManagedPolicy:
704707
none : { Policy: '' }
@@ -1092,7 +1095,10 @@ Resources:
10921095
IamInstanceProfile:
10931096
Arn: !GetAtt "IAMInstanceProfile.Arn"
10941097
InstanceType: !Select [ "0", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "" ] ] ] ]
1095-
InstanceInitiatedShutdownBehavior: "terminate"
1098+
InstanceInitiatedShutdownBehavior: !If
1099+
- TerminateInstanceAfterJob
1100+
- terminate
1101+
- stop
10961102
MetadataOptions:
10971103
HttpTokens: !Ref IMDSv2Tokens
10981104
# Allow containers using a Docker network on the host to receive IDMSv2 responses

0 commit comments

Comments
 (0)