Last active
June 10, 2019 15:06
-
-
Save lvthillo/8d08898a4413b98969cf649fb8189120 to your computer and use it in GitHub Desktop.
LaunchConfiguration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ASGLaunchConfiguration: | |
| Type: AWS::AutoScaling::LaunchConfiguration | |
| Properties: | |
| ImageId: !FindInMap | |
| - RegionMap | |
| - !Ref 'AWS::Region' | |
| - HVM64 | |
| InstanceType: t2.micro | |
| KeyName: !Ref SSHKey | |
| LaunchConfigurationName: ASGLaunchConfiguration | |
| IamInstanceProfile: !Ref ASGInstanceProfile | |
| SecurityGroups: | |
| - !Ref ASGSG | |
| UserData: | |
| # This script below installs AmazonCloudWatchAgent | |
| # This script will only run during initial instance launch/setup. | |
| # This script will trigger configsets of default | |
| # After the execution of the default ConfigSets the cfn-signal will be returned | |
| Fn::Base64: !Sub | | |
| #!/bin/bash | |
| rpm -Uvh https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm | |
| /opt/aws/bin/cfn-init -v --stack ${AWS::StackId} --resource ASGLaunchConfiguration --region ${AWS::Region} --configsets default | |
| /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackId} --resource ASGLaunchConfiguration --region ${AWS::Region} | |
| Metadata: | |
| AWS::CloudFormation::Init: | |
| configSets: | |
| # These scripts will run during the instance launch triggered by the userData | |
| default: | |
| - 01_setupCfnHup | |
| - 02_config-amazon-cloudwatch-agent | |
| - 03_restart_amazon-cloudwatch-agent | |
| # These scripts will run during an update of the instance metadata = stack update. | |
| UpdateEnvironment: | |
| - 02_config-amazon-cloudwatch-agent | |
| - 03_restart_amazon-cloudwatch-agent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment