Skip to content

Commit

Permalink
autoscaling rolling update
Browse files Browse the repository at this point in the history
  • Loading branch information
saravanan30erd committed Apr 11, 2018
1 parent 1a8e6e3 commit 5ea3f15
Showing 1 changed file with 43 additions and 7 deletions.
50 changes: 43 additions & 7 deletions vpc.template → wordpress.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Template to create a VPC with public and private subnets with NAT Gateway",
"Description": "Template to setup High Availability WordPress site",
"Metadata": {
"AWS::CloudFormation::Interface": {
"ParameterGroups": [
Expand Down Expand Up @@ -38,7 +38,9 @@
"MaximumInstances",
"KeyName",
"AppImageId",
"InstanceType"
"InstanceType",
"MaxBatchSize",
"MinInstancesInService"
]
},
{
Expand Down Expand Up @@ -89,6 +91,12 @@

],
"ParameterLabels": {
"MinInstancesInService": {
"default" : "AutoScaling Rolling Update MinInstancesInService"
},
"MaxBatchSize": {
"default": "AutoScaling Rolling Update MaxBatchSize"
},
"WPVersion": {
"default" : "WordPress Version"
},
Expand Down Expand Up @@ -192,6 +200,16 @@
}
},
"Parameters": {
"MinInstancesInService": {
"Description" : "Specifies the minimum number of instances that must be in service within the Auto Scaling group while AWS CloudFormation updates old instances.",
"Default": 1,
"Type": "Number"
},
"MaxBatchSize": {
"Description": "Specifies the maximum number of instances that AWS CloudFormation updates.",
"Default": 1,
"Type": "Number"
},
"WPVersion": {
"Description" : "WordPress Version to install",
"Default" : "latest",
Expand Down Expand Up @@ -260,7 +278,7 @@
"ConstraintDescription": "DB Password must be 8-41 characters and contain only alpha numeric characters."
},
"AnsibleRepository": {
"Default": "https://github.com/ansible/ansible-examples.git",
"Default": "https://github.com/saravanan30erd/wordpress-cf-template.git",
"Description": "The git repository URL of WordPress Deployment ansible playbook",
"Type": "String"
},
Expand Down Expand Up @@ -979,8 +997,8 @@
"MinSize" : { "Ref" : "MinimumInstances" },
"MaxSize" : { "Ref" : "MaximumInstances" },
"TargetGroupARNs" : [ { "Ref" : "ALBTargetGroup" } ],
"HealthCheckGracePeriod" : 360,
"HealthCheckType" : "EC2",
"HealthCheckGracePeriod" : 600,
"HealthCheckType" : "ELB",
"DesiredCapacity" : { "Ref" : "DesiredCapacity" },
"Tags" : [ {
"Key" : "Name",
Expand All @@ -989,6 +1007,20 @@
}
]
},
"CreationPolicy" : {
"ResourceSignal" : {
"Timeout" : "PT15M",
"Count" : "1"
}
},
"UpdatePolicy" : {
"AutoScalingRollingUpdate" : {
"MaxBatchSize" : {"Ref" : "MaxBatchSize"},
"MinInstancesInService" : {"Ref" : "MinInstancesInService"},
"PauseTime" : "PT15M",
"WaitOnResourceSignals": "true"
}
},
"DependsOn" : "DatabasePrimaryInstance"
},
"LaunchConfig" : {
Expand All @@ -1006,7 +1038,7 @@
"sleep 10\n",
"yum update -y\n",
"done\n",
"yum install python27 python27-pip git -y\n",
"yum install python27 python27-pip git aws-cfn-bootstrap -y\n",
"pip install ansible\n",
"/usr/local/bin/ansible-pull -U ", {"Ref": "AnsibleRepository"},
" -C ", {"Ref": "AnsibleBranch"},
Expand All @@ -1021,7 +1053,11 @@
" -e wp_admin_user=", {"Ref": "WPAdminUser"},
" -e wp_admin_password=", {"Ref": "WPAdminPassword"},
" -e wp_admin_email=", {"Ref": "WPAdminEmail"},
" -o", "\n"
" -o\n",
"/opt/aws/bin/cfn-signal -e $? ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource AppServerGroup ",
" --region ", { "Ref" : "AWS::Region" }, "\n"
]]}}
},
"DependsOn": ["DatabasePrimaryInstance","ApplicationLoadBalancer"]
Expand Down

0 comments on commit 5ea3f15

Please sign in to comment.