Subscribe to Our Weekly Newsletter
Modifying an AWS Cloud Formation Template
Modifying an AWS Cloud Formation Template
Now, since the template has already been created, we will modify it, to enable you to launch a new environment with the custom AMI. By doing so, you will have multiple instances spanned across multiple Availability Zones. Here is the procedure to launch a new stack with a modified template:
- Open the template that you’ve just created using CloudFormer.
- Update the CloudDistribution group to include DistributionConfig and the Loggingportion.
“distd18k4jybr69gw2cloudfrontnet” : { “Type” : “AWS::CloudFront::Distribution”, “Properties” : { “DistributionConfig” : { “S3Origin” : { “DNSName”: “webapplication.s3.amazonaws.com” }, “Enabled” : “true”, “Logging” : { “Bucket” : “webapplication.s3.amazonaws.com”, “Prefix” : “webapp-logging/” } } } },
|
In the Auto-Scaling group, update the “Max Size”, “Min Size”, and “Desired Capacity” to 2.
“asgMyAutoScalingGroup”: { “Type”: “AWS::AutoScaling::AutoScalingGroup”, “Properties”: { “AvailabilityZones”: [ "us-east-1b", "us-east-1c" ], “Cooldown”: “300″, “DesiredCapacity”: “2″, “MaxSize”: “2″, “MinSize”: “2″, “LaunchConfigurationName”: { “Ref”: “lcMyLC” }, “LoadBalancerNames”: [ { "Ref": "elbMyLB" } ] } },
|
- Update the Image ID in the “Launch Configuration” group to the custom AMI that you had created in the Creating a Custom AMI section.
Note: Your AMI ID will be different from the one you see below.
“lcMyLC”: { “Type”: “AWS::AutoScaling::LaunchConfiguration”, “Properties”: { “ImageId”: “ami-576ca43e”, “InstanceType”: “t1.micro”, “KeyName”: “mykeypair”, “SecurityGroups”: [ { "Ref": "sgwebappsecuritygroup" } ] } },
|
- Now, update the following parameters in the Database group:
- Update “DBName” to mydb.
- Update “MasterUserPassword” to the master password you specifed in the Adding Amazon RDS section.
“rdsawsworkshop”: { “Type”: “AWS::RDS::DBInstance”, “Properties”: { “AllocatedStorage”: “5″, “BackupRetentionPeriod”: “1″, “DBInstanceClass”: “db.m1.small”, “DBName”: “mydb”, “DBParameterGroupName”: “default.mysql5.1″, “Engine”: “mysql”, “EngineVersion”: “5.1.57″, “MasterUsername”: “awsuser”, “MasterUserPassword”: “mypassword”, “Port”: “3306″, “PreferredBackupWindow”: “08:30-09:00″, “PreferredMaintenanceWindow”: “fri:03:30-fri:04:00″, “MultiAZ”: “true”, “DBSecurityGroups”: [ { "Ref": "dbsgmydbsecuritygroup" } ] } },
|