Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate auto scaling launch config to launch template #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions cloudformation/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -382,21 +382,24 @@ Resources:
Properties:
Roles:
- Ref: WebappRole
WebappLaunchConfig:
Type: AWS::AutoScaling::LaunchConfiguration
WebappLaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Properties:
AssociatePublicIpAddress: true
ImageId:
Ref: ImageId
InstanceType:
Ref: InstanceType
SecurityGroups:
- Ref: WebappSecurityGroup
IamInstanceProfile:
Ref: WebappInstanceProfile
UserData:
"Fn::Base64":
!Sub |
LaunchTemplateName: !Sub ${AWS::StackName}-launch-template
LaunchTemplateData:
ImageId:
Ref: ImageId
InstanceType:
Ref: InstanceType
SecurityGroupIds:
- Ref: WebappSecurityGroup
IamInstanceProfile:
Arn: !GetAtt
- WebappInstanceProfile
- Arn
UserData:
"Fn::Base64":
!Sub |
#!/bin/bash

yum install -y java-1.8.0-openjdk-devel wget
Expand Down Expand Up @@ -468,8 +471,9 @@ Resources:
DesiredCapacity: !Ref AutoScalingGroupDesiredCapacity
MinSize: !Ref AutoScalingGroupMinSize
MaxSize: !Ref AutoScalingGroupMaxSize
LaunchConfigurationName:
Ref: WebappLaunchConfig
LaunchTemplate:
LaunchTemplateId: !Ref WebappLaunchTemplate
Version: !GetAtt WebappLaunchTemplate.LatestVersionNumber
VPCZoneIdentifier:
- Ref: PrivateSubnet1
- Ref: PrivateSubnet2
Expand Down