Skip to content

Commit e4255d2

Browse files
committed
Enable SSM access and disable SSH access.
Signed-off-by: Kai Xia <[email protected]>
1 parent b9d66bb commit e4255d2

File tree

1 file changed

+17
-28
lines changed

1 file changed

+17
-28
lines changed

templates/aws-stack.yml

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Metadata:
4040
- ImageIdParameter
4141
- InstanceType
4242
- AgentsPerInstance
43-
- KeyName
4443
- SpotPrice
4544
- SecretsBucket
4645
- ArtifactsBucket
@@ -88,11 +87,6 @@ Metadata:
8887
- EnableDockerLoginPlugin
8988

9089
Parameters:
91-
KeyName:
92-
Description: Optional - SSH keypair used to access the buildkite instances, setting this will enable SSH ingress
93-
Type: String
94-
Default: ""
95-
9690
BuildkiteAgentRelease:
9791
Type: String
9892
AllowedValues:
@@ -464,17 +458,6 @@ Conditions:
464458
UseCostAllocationTags:
465459
!Equals [ !Ref EnableCostAllocationTags, "true" ]
466460

467-
HasKeyName:
468-
!Not [ !Equals [ !Ref KeyName, "" ] ]
469-
470-
EnableSshIngress:
471-
!And
472-
- { Condition : CreateSecurityGroup }
473-
# Enable ingress if a key can be specified another way
474-
- !Or
475-
- { Condition: HasKeyName }
476-
- !Not [ !Equals [ !Ref AuthorizedUsersUrl, "" ] ]
477-
478461
# Whether or not there's any managed polices to attach
479462
HasManagedPolicies:
480463
!Or [ { Condition: UseManagedPolicyARN }, { Condition: UseECR } ]
@@ -693,6 +676,23 @@ Resources:
693676
- sns:Unsubscribe
694677
- sns:Subscribe
695678
Resource: "*"
679+
- Effect: Allow
680+
Action:
681+
- ssm:DescribeInstanceProperties
682+
- ssm:ListAssociations
683+
- ssm:PutInventory
684+
- ssm:UpdateInstanceInformation
685+
- ssmmessages:CreateControlChannel
686+
- ssmmessages:CreateDataChannel
687+
- ssmmessages:OpenControlChannel
688+
- ssmmessages:OpenDataChannel
689+
- ec2messages:AcknowledgeMessage
690+
- ec2messages:DeleteMessage
691+
- ec2messages:FailMessage
692+
- ec2messages:GetEndpoint
693+
- ec2messages:GetMessages
694+
- ec2messages:SendRepl
695+
Resource: "*"
696696
Roles:
697697
- !Ref IAMRole
698698

@@ -800,7 +800,6 @@ Resources:
800800
- DeviceIndex: 0
801801
AssociatePublicIpAddress: { Ref: AssociatePublicIpAddress }
802802
Groups: !Split [ ",", !If [ "CreateSecurityGroup", !Ref SecurityGroup, !Ref SecurityGroupId ] ]
803-
KeyName: !If [ "HasKeyName", !Ref KeyName, !Ref 'AWS::NoValue' ]
804803
IamInstanceProfile:
805804
Arn: !GetAtt "IAMInstanceProfile.Arn"
806805
InstanceType: !Ref InstanceType
@@ -949,16 +948,6 @@ Resources:
949948
- Key: Name
950949
Value: !Ref 'AWS::StackName'
951950

952-
SecurityGroupSshIngress:
953-
Condition: EnableSshIngress
954-
Type: AWS::EC2::SecurityGroupIngress
955-
Properties:
956-
GroupId: !GetAtt SecurityGroup.GroupId
957-
IpProtocol: tcp
958-
FromPort: 22
959-
ToPort: 22
960-
CidrIp: 0.0.0.0/0
961-
962951
AutoscalingLambdaExecutionRole:
963952
Type: AWS::IAM::Role
964953
Condition: HasVariableSize

0 commit comments

Comments
 (0)