Skip to content

Commit

Permalink
convert rds agent to launch template
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Pickering <[email protected]>
  • Loading branch information
alexvpickering committed Dec 10, 2024
1 parent bb093c0 commit f6088c5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cf/batch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Resources:
BatchLaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateName: !Sub "launch-template-${Environment}"
LaunchTemplateName: !Sub "batch-${Environment}-launch-template"
LaunchTemplateData:
MetadataOptions:
HttpTokens: required
Expand Down
33 changes: 22 additions & 11 deletions cf/rds-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@ Resources:
- !Sub "arn:aws:rds:${AWS::Region}:${AWS::AccountId}:cluster:aurora-cluster-${Environment}-*"
- !Sub "arn:aws:rds:${AWS::Region}:${AWS::AccountId}:cluster:aurora-cluster-${Environment}"

RDSAgent:
Type: AWS::EC2::Instance
Properties:
RDSLaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateName: !Sub "rds-${Environment}-ssm-launch-template"
LaunchTemplateData:
InstanceType: t2.nano
IamInstanceProfile: !Ref SSMProfile
IamInstanceProfile:
Arn: !GetAtt SSMProfile.Arn
ImageId: !Ref LatestAmiId
MetadataOptions:
HttpTokens: required
Expand All @@ -72,10 +75,7 @@ Resources:
Encrypted: 'true'
SecurityGroupIds:
- Fn::ImportValue: !Sub "biomage-${Environment}-rds::RDSAgentSecurityGroupId"
SubnetId:
#Pick first element in SubnetsPrivate
!Select [ 0, Fn::Split: [',', Fn::ImportValue: !Sub "eksctl-biomage-${Environment}-cluster::SubnetsPrivate"] ]
#UserData Runs when ec2 is being deployed
#UserData Runs when ec2 is being deployed
UserData:
Fn::Base64:
'
Expand All @@ -101,6 +101,17 @@ Resources:
#!/bin/bash -e
sudo yum -y install postgresql
'
Tags:
- Key: "Name"
Value: !Sub "rds-${Environment}-ssm-agent"
TagSpecifications:
- ResourceType: instance
Tags:
- Key: "Name"
Value: !Sub "rds-${Environment}-ssm-agent"

RDSAgent:
Type: AWS::EC2::Instance
Properties:
LaunchTemplate:
LaunchTemplateName: !Ref RDSLaunchTemplate
Version: !GetAtt RDSLaunchTemplate.LatestVersionNumber
SubnetId:
!Select [0, Fn::Split: [',', Fn::ImportValue: !Sub "eksctl-biomage-${Environment}-cluster::SubnetsPrivate"]]

0 comments on commit f6088c5

Please sign in to comment.