Skip to content

Instantly share code, notes, and snippets.

@ryo0301
Last active April 5, 2016 03:55
Show Gist options
  • Save ryo0301/c6635992ee45f7049fcd to your computer and use it in GitHub Desktop.
Save ryo0301/c6635992ee45f7049fcd to your computer and use it in GitHub Desktop.
CloudFormationのロールバック時に設定ファイルも元に戻す ref: http://qiita.com/ryo0301/items/c2141d05eda63b2d2bad
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "CloudFormation rollback test",
"Parameters": {
"VersionId": {
"Type": "String"
}
},
"Resources": {
"Group": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"CreationPolicy": {
"ResourceSignal": {
"Count": "2",
"Timeout": "PT10M"
}
},
"UpdatePolicy": {
"AutoScalingRollingUpdate": {
"MaxBatchSize": "1",
"MinInstancesInService": "1",
"WaitOnResourceSignals": "true",
"PauseTime": "PT10M"
},
"AutoScalingScheduledAction": {
"IgnoreUnmodifiedGroupSizeProperties": "true"
}
},
"Properties": {
"LaunchConfigurationName": { "Ref": "LaunchConfig" },
"VPCZoneIdentifier": [
"subnet-XXXXXXXX"
],
"HealthCheckType": "EC2",
"DesiredCapacity": "2",
"MinSize": "2",
"MaxSize": "2"
}
},
"LaunchConfig": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"VolumeType": "gp2",
"VolumeSize": "8",
"DeleteOnTermination": "true"
}
}
],
"IamInstanceProfile": "test",
"ImageId": "ami-383c1956",
"InstanceType": "t2.micro",
"InstanceMonitoring": "false",
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"", [
"#!/bin/bash\n",
"yum update -y aws-cfn-bootstrap\n",
"yum install -y nginx\n",
"aws s3api get-object",
" --bucket XXXXXXX",
" --key nginx.conf",
" --version-id '", {"Ref": "VersionId"}, "'",
" /etc/nginx/nginx.conf\n",
"service nginx start\n",
"/opt/aws/bin/cfn-signal -e $?",
" --stack ", {"Ref": "AWS::StackName"},
" --resource Group",
" --region ", {"Ref": "AWS::Region"}
]
]
}
}
}
}
}
}
Received SUCCESS signal with UniqueId i-XXXXXXXX
Received SUCCESS signal with UniqueId i-XXXXXXXX
Received 1 FAILURE signal(s) out of 2. Unable to satisfy 100% MinSuccessfulInstancesPercent requirement
Received SUCCESS signal with UniqueId i-XXXXXXXX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment