@@ -42,6 +42,7 @@ Metadata:
42
42
- ImageIdParameter
43
43
- InstanceType
44
44
- AgentsPerInstance
45
+ - KeyName
45
46
- SpotPrice
46
47
- SecretsBucket
47
48
- ArtifactsBucket
@@ -91,6 +92,11 @@ Metadata:
91
92
- EnableDockerLoginPlugin
92
93
93
94
Parameters :
95
+ KeyName :
96
+ Description : Optional - SSH keypair used to access the buildkite instances via ec2_user, setting this will enable SSH ingress
97
+ Type : String
98
+ Default : " "
99
+
94
100
BuildkiteAgentRelease :
95
101
Type : String
96
102
AllowedValues :
@@ -519,6 +525,17 @@ Conditions:
519
525
UseCostAllocationTags :
520
526
!Equals [ !Ref EnableCostAllocationTags, "true" ]
521
527
528
+ HasKeyName :
529
+ !Not [ !Equals [ !Ref KeyName, "" ] ]
530
+
531
+ EnableSshIngress :
532
+ !And
533
+ - { Condition : CreateSecurityGroup }
534
+ # Enable ingress if a key can be specified another way
535
+ - !Or
536
+ - { Condition: HasKeyName }
537
+ - !Not [ !Equals [ !Ref AuthorizedUsersUrl, "" ] ]
538
+
522
539
# Whether or not there's any managed polices to attach
523
540
HasManagedPolicies :
524
541
!Or [ { Condition: UseManagedPolicyARN }, { Condition: UseECR } ]
@@ -841,6 +858,7 @@ Resources:
841
858
- DeviceIndex : 0
842
859
AssociatePublicIpAddress : { Ref: AssociatePublicIpAddress }
843
860
Groups : !Split [ ",", !If [ "CreateSecurityGroup", !Ref SecurityGroup, !Ref SecurityGroupId ] ]
861
+ KeyName : !If [ "HasKeyName", !Ref KeyName, !Ref 'AWS::NoValue' ]
844
862
IamInstanceProfile :
845
863
Arn : !GetAtt "IAMInstanceProfile.Arn"
846
864
InstanceType : !Select [ "0", !Split [ ",", !Join [ ",", [ !Ref InstanceType, "", "", "" ] ] ] ]
@@ -1084,6 +1102,16 @@ Resources:
1084
1102
- Key : Name
1085
1103
Value : !Ref 'AWS::StackName'
1086
1104
1105
+ SecurityGroupSshIngress :
1106
+ Condition : EnableSshIngress
1107
+ Type : AWS::EC2::SecurityGroupIngress
1108
+ Properties :
1109
+ GroupId : !GetAtt SecurityGroup.GroupId
1110
+ IpProtocol : tcp
1111
+ FromPort : 22
1112
+ ToPort : 22
1113
+ CidrIp : 0.0.0.0/0
1114
+
1087
1115
Autoscaling :
1088
1116
Type : AWS::Serverless::Application
1089
1117
Condition : HasVariableSize
0 commit comments