SlideShare a Scribd company logo
Aamazon Web Service Cloud-Formation
By Kamal Maiti
Sr. Subject Matter Expert
Linux System Engineer
Amdocs Development Center, India
 Method to Create or Manage a Collection of AWS Resources.
 Often Described as “Infrastructure as Code”.
 Built with JSON Template Files.
Dated : 3rd July, 2015
AWS CLOUD-FORMATION
Agenda :
Phase 1 :
 Style of Json scripting Syntax
 Cloud-Formation(CF) scripting style & syntax
 CF Scripting Block : Template version, Description, Parameters, Mappings,
Resources, Outputs
 CF AWS Resource Types, Resource Property types, Resource Attributes
 Intrinsic Functions & usage
Phase 2 :
 CF helper scripts.
 CF Stack & Template
 Building environment using stack, updating stack
 IAM role implementation
 Auto-scaling
 Troubleshooting, Best Practices
 Q/A
STYLE OF JSON SYNTAX
JSON syntax is a subset of the JavaScript object notation syntax:
 Data is in Key/value pairs : “Key” : “Value”
 Data is separated by commas : “data1”, “data2”
 Curly braces hold objects : { … }
 Square brackets hold arrays : [ … ]
 JSON Data - A Name(key) and a Value :
 JSON data is written as KEY & VALUE pairs.
 A Key/value pair consists of a field name (in double quotes),
followed by a colon, followed by a value:
Example :
"firstName “ : “Smith"
STYLE OF JSON SYNTAX
KEY
VALUE
 JSON Values :
 A number (integer or floating point)
 A string (in double quotes)
 A Boolean (true or false)
 An array (in square brackets)
 An object (in curly braces)
 null
STYLE OF JSON SYNTAX
 JSON Objects :
 JSON objects are written inside curly braces.
 Just like in JavaScript, objects can contain
multiple key / values pairs.
Example :
{"firstName":"Jhon", "lastName":"Smith"}
STYLE OF JSON SYNTAX
 JSON Arrays
 JSON arrays are written inside square brackets.
 Just like in JavaScript, an array can contain multiple objects.
Example:
"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]
STYLE OF JSON SYNTAX
{
"Title" : "The Daughter Of Time",
"Author" : "Josephine Tey",
"Genre" : " Crime, Thrillers & Mystery ",
"Detail" : {
"Publisher" : " Simon & Schuster ",
"Publication_Year" : 2009 ,
"ISBN" : “0-684-80386-0",
“Language" : "English",
"Pages" : 999
},
"Price" : [
{
"type" :"Hardcover",
"price" : "17.99"
},
{
"type" : "Kindle Edition",
"price" : "5.22"
}
]
}
Json Script Example
Main Object Starts
Nested Object Starts
Nested Object Starts
First Sub Object Starts
First Sub Object Ends
Main Object Ends
Nested Object Ends
Nested Object Ends
Array Starts (second object as array)
Array Ends
Value: String
Value : Number
No comma (, ) after last value
 Cloud Formation uses Json scripting style & syntax.
 Objects are wrapped within '{' and '}‘.
 Arrays are enclosed by '[' and ']'.
 Objects are list of key & Value pairs.
 Arrays are list of values.
 Both objects and arrays can be nested.
 strings, numbers, booleans (i.e true and false) and null
can be used as values.
CLOUD-FORMATION SYNTAX
AWS CF TEMPLATE FORMAT
{
“AWSTemplateFormatVersion” : “…”,
“Description” : “…”,
“Parameters” : “…”,
“Mappings” : “…”,
“Resources” : “…”,
“Outputs: : “…”
}
Object Starts
Object Ends
No comma after
last key/value
Optional
Mandatory
Optional
Optional
Optional
Editor for Developing CF script
 oXygen XML Editor - Available in our Software Catalog. Live json
syntax checker.
 Online Editor :
“jsoneditoronline.org” - I prefer to use. Live json syntax
checker.
“codebeautify.org/online-json-editor” – have not used
VALIDATE AWS CF SCRIPT
AWS CLI :
 Through aws instance which has IAM role to execute aws commands
 Or configure aws tool on a machine.
Example :
aws cloudformation validate-template –template-body file:////home/kamalma/example.json
aws cloudformation validate –template-body https://s3.amazonaws.com/templates/example.json
AWS MANAGEMENT CONSOLE GUI :
 Automatically validates once you upload script.
EXAMPLE OF CLOUD-FORMATION BLOCK
{
“AWSTemplateFormatVersion” : “2010-09-09”,
“Description” : ”This is a test template”
“Parameters” : {
“Customer” : {
“Description” : “Name of the customer”,
“Type” : “String”,
“Default” : “claro”,
“AllowedValues” : [“claro”,”tyco”, “qpass”]
}
}
}
Static/fixed
Name
Variable/Cus
tomizable
Name
Optional
Optional
Optional
EXAMPLE OF CLOUD-FORMATION BLOCK
{
"Mappings" : {
“MyRegionMap" : {
"us-east-1" : {
"AMI" : "ami-76f0061f“ },
"us-west-1" : {
"AMI" : "ami-655a0a20“ },
"eu-west-1" : {
"AMI" : "ami-7fd4e10b“ },
}
}
},
"Resources" : {
"Ec2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"KeyName" : "MyKey",
"ImageId" : { "Fn::FindInMap" : [ “MyRegionMap", { "Ref" :
"AWS::Region" }, "AMI" ]}
}
}
},
“Outputs” : { }
}
Static Name
Static Name
Static Name
First Key
Second Name
User Defined Name
User Defined Name
 CF AWS Resource Section :
 Type
 Properties
 Attributes
Cloud-Formation AWS “Resources”
 Standard Resource Type Format : AWS::ProductIdentifier::ResourceType
Example: AWS::EC2::Instance
 Each resource has “Properties” object block
 Each Resource has attribute(s) inside of property or outside of it.
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Ec2 block device mapping",
"Resources" : {
"MyEC2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"ImageId" : "ami-79fd7eee",
"KeyName" : "testkey",
"BlockDeviceMappings" : [
{
"DeviceName" : "/dev/sdm",
"Ebs" : {
"VolumeType" : “gp2",
"Iops" : "200",
"DeleteOnTermination" : "false",
"VolumeSize" : "20“ }
}
]
}
}
}
}
Resource
Type
Resource
Property Block
Resource
Attributes
How Do I know all AWS Resource names, Resource Types,
Resource Attributes ?
 Amazon online link :
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html
And Go to “Template Reference” section.
 Refer cloud-formation user guide pdf [cfn-ug.pdf]
Intrinsic Functions
 AWS CF built-in functions
 Helps to manage stacks
Currently available functions :
Fn::Base64  Returns the Base64 representation of the input string
Condition Functions  Used to define various condition.
Example: Fn::And, Fn::Equals, Fn::If, Fn::Not, Fn::Or
Fn::FindInMap  Returns the value corresponding to keys in a two-level map that is declared in
the Mappings section
Fn::GetAtt  Returns the value of an attribute from a resource in the template
Fn::GetAZs  Returns an array that lists Availability Zones for a specified region
Fn::Join  Appends a set of values into a single value, separated by the specified
delimiter.
Fn::Select  Returns a single object from a list of objects by index.
Ref  Returns the value of the specified parameter or resource.
Intrinsic Function Usage
Fn::Base64
Usage : Usually used in Userdata section
Declaration : { "Fn::Base64" : valueToEncode }
Example :
{
"MyInstance": {
"Type": "AWS::EC2::Instance",
"Metadata": {
:
},
"Properties": {
"ImageId" : "ami-12345678",
"UserData" : {
"Fn::Base64" : {
"Fn::Join" : ["", [
"#!/bin/bashn",
"/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackName" },
" -r MyInstance ",
" --region ", { "Ref" : "AWS::Region" }, "n",
"/opt/aws/bin/cfn-signal -e 0 --stack ", { "Ref" : "AWS::StackName" },
" --resource MyInstance n"
] ]
}
}
}
}
}
Intrinsic Function Usage
Condition Functions
Fn::And
Declaration : "Fn::And": [{condition}, {...}]
Parameters :
condition : A condition that evaluates to true or false.
Example : The following MyAndCondition evaluates to true if the referenced security group name
is equal to sg-mysggroup and if SomeOtherCondition evaluates to true:
"MyAndCondition": {
"Fn::And": [
{"Fn::Equals": ["sg-mysggroup", {"Ref": "ASecurityGroup"}]},
{"Condition": "SomeOtherCondition"}
]
}
Intrinsic Function Usage
Fn::FindInMap
Declaration : "Fn::FindInMap" : [ "MapName", "TopLevelKey", "SecondLevelKey"]
Parameters :
MapName : The logical name of a mapping declared in the Mappings section that contains the keys and values.
TopLevelKey: The top-level key name. Its value is a list of key-value pairs.
SecondLevelKey: The second-level key name, which is set to one of the keys from the list assigned to TopLevelKey.
Return Value: The value that is assigned to SecondLevelKey.
{
...
"Mappings" : {
"RegionMap" : {
"us-east-1" : { "32" : "ami-6411e20d", "64" : "ami-7a11e213" },
"us-west-1" : { "32" : "ami-c9c7978c", "64" : "ami-cfc7978a" },
"eu-west-1" : { "32" : "ami-37c2f643", "64" : "ami-31c2f645" },
"ap-southeast-1" : { "32" : "ami-66f28c34", "64" : "ami-60f28c32" },
"ap-northeast-1" : { "32" : "ami-9c03a89d", "64" : "ami-a003a8a1" }
}
},
"Resources" : {
"myEC2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" },
"32"]},
"InstanceType" : "m1.small"
}
}
}
}
NB : In above example, if you are build stack in us-west-1 region, for 64 bit instance, it’ll use “ami-cfc7978a”
Intrinsic Function Usage
Fn::GetAtt
Declaration : "Fn::GetAtt" : [ "logicalNameOfResource", "attributeName" ]
Parameters :
logicalNameOfResource: The logical name of the resource that contains the attribute
you want.
attributeName: The name of the resource-specific attribute whose value you want.
Example :
“Outputs” : {
"PrivateIP" : {
"Description" : "Private IP of newly created EC2 instance",
"Value" : { "Fn::GetAtt" : ["EC2Instance", "PrivateIp"] }
}
}
Intrinsic Function Usage
Ref
Declaration : "Ref" : "logicalName"
Parameters :
logicalName: The logical name of the resource or parameter you want to
dereference.
Example :
"MyEIP" : {
"Type" : "AWS::EC2::EIP",
"Properties" : {
"InstanceId" : { "Ref" : "MyEC2Instance" }
}
}
Intrinsic Function Usage
Fn::Join
Declaration : "Fn::Join" : [ "delimiter", [ comma-delimited list of values ] ]
Return Value : The combined string.
Example :
"Fn::Join" : [ ":", [ "a", "b", "c" ] ]
This example returns: "a:b:c".
PHASE 2
 CF helper scripts.
 CF Stack & Template
 Building environment using stack, updating stack
 IAM Role Implementation
 Auto-scaling
 CF Limitation
 Troubleshooting
 Best Practices
 Q/A
Agenda :
CF Helper Scripts
 Set of Python Scripts
 Scripts work in conjunction with resource metadata
 Scripts run on the Amazon EC2 instance as part of the stack creation process
 Pre-installed on the latest versions of the Amazon Linux AMI
 For other AMI, you have to install before using it.
 AWS CloudFormation provides the following helpers:
cfn-init: Used to retrieve and interpret the resource metadata, installing packages,
creating files and starting services.
cfn-signal: A simple wrapper to signal an AWS CloudFormation CreationPolicy or
WaitCondition, enabling you to synchronize other resources in the stack with the application being ready.
cfn-get-metadata: A wrapper script making it easy to retrieve either all metadata
defined for a resource or path to a specific key or subtree of the resource metadata.
cfn-hup: A daemon to check for updates to metadata and execute custom hooks when the
changes are detected.
CF Helper Scripts Usage
"UserData":{
"Fn::Base64":{ "Fn::Join":[ "", [
"#!/bin/bash -xen",
"# Install the files and packages from the metadatan",
"/opt/aws/bin/cfn-init -v ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource EC2Instance",
" --configsets InstallSoftware",
" --region ", { "Ref" : "Region" }, "n",
"# Start up the cfn-hup daemon to listen for changes to the metadatan",
"/opt/aws/bin/cfn-hup || error_exit 'Failed to start cfn-hup'n",
"# Signal the status from cfn-initn",
"/opt/aws/bin/cfn-signal -e $? ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource EC2Instance",
" --region ", { "Ref" : "Region" }, "n"
]]
}
}
User data section of EC2
resource
Called cfn-init script
Run cfn-hup deamon
Checks return status
of cfn-init
"Metadata" : {
"AWS::CloudFormation::Init" : {
"configSets" : {
"InstallSoftware" : ["Install"]
},
"Install" : {
"files" : {
"/etc/cfn/cfn-hup.conf" : {
"content" : { "Fn::Join" : ["", [
"[main]n",
"stack=", { "Ref" : "AWS::StackId" }, "n",
"region=", { "Ref" : "Region" }, "n"
]]},
"mode" : "000400", "owner" : "root", "group" : "root“ },
"/etc/cfn/hooks.d/cfn-auto-reloader.conf" : {
"content": { "Fn::Join" : ["", [
"[cfn-auto-reloader-hook]n",
"triggers=post.updaten",
"path=Resources.WebServerInstance.Metadata.AWS::CloudFormation::Initn",
"action=/opt/aws/bin/cfn-init -v ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource EC2Instance ",
" --configsets InstallSoftware ",
" --region ", { "Ref" : "Region" }, "n",
"runas=rootn"
]]}
}
},
"commands" : {
"configure node" : {
"command" : { "Fn::Join" : ["", [
"logger 'finised commandlines' n"
]]
}
}
},
"services" : {
"sysvinit" : {
"cfn-hup" : { "enabled" : "true", "ensureRunning" : "true",
"files" : ["/etc/cfn/cfn-hup.conf", "/etc/cfn/hooks.d/cfn-auto-
reloader.conf"]}
}
}}
}
}
EC2 Metadata section
EC2 standard cfn-init section
Cfn-hup config file
Cfn-hup autoloader config file
Auto-loader will be used for post update only
Starts cfn-hup as daemon
CF Stack & Template
 Nested Template can be called to reuse same template
 Resource "Type" : "AWS::CloudFormation::Stack“ must be used.
 "TemplateURL" needs to be used in Property section.
 "Parameters" can be passed from master to nested template
Example :
"Resources" : {
"FrontNodeStack" : {
"Type" : "AWS::CloudFormation::Stack",
"Properties" : {
"TemplateURL" : "https://s3-sa-east-1.amazonaws.com/claro-templates-static-sa-
east-1/tyco-front-back-nested-ec2-gru1.json",
"Parameters" : {
"Customer" : { "Ref" : "Customer“ },
[…]
"PuppetMaster" : {"Ref" : "PuppetMaster"}
}
}
}
}
Stack resource Type
Building Environment Using Stack Template
 Deploy Stack : Two ways :
 GUI ie AWS management console
 AWS SLI/SDK/API call
Example using AWS command :
aws cloudformation create-stack --stack-name myteststack --capabilities
CAPABILITY_IAM --template-body file:////home/kamalma/cloudformation/vol-
attachment-ec2.json
Using AWS management console :
 Upload template on S3 in the region where you want deploy
 Click on “Cloud Formation”
 Click on “Create Stack” and provide required details.
UPDATING STACK
 AWS CLI :
Example :
aws cloudformation update-stack --stack-name qpass-cf-util-gru1-v3-test1 --template-body
file:////home/kamalma/cloudformation/qpass-cf-util-gru1-v3.json
 Change Parameter Value :
aws cloudformation update-stack --stack-name mystack --template-url
https://s3.amazonaws.com/sample/updated.template --parameters
ParameterKey=KeyPairName,ParameterValue=SampleKeyPair
ParameterKey=SubnetIDs,ParameterValue=SampleSubnetID1,SampleSubnetID2
For more details on CLI, refer : http://docs.aws.amazon.com/cli/latest/reference/
IAM Role Implementation
 User
 Group
 Role based ie a resource can work like a group to do
action on other resources.
Example : Ec2 instance can retrieve/update/update data on s3 bucket
if role base code is put in CF.
 Avoid to use credentials based authentication in CF.
Auto-Scaling
“MyInstance" : {
"Type" : "AWS::AutoScaling::LaunchConfiguration",
"Properties" : {
"SecurityGroups" : [“XXXX"],
[…]
}
}
“AppAutoScalingGroup" : {
"Type" : "AWS::AutoScaling::AutoScalingGroup",
"Properties" : {
"AvailabilityZones" : { "Fn::GetAZs" : "" },
"LaunchConfigurationName" : { "Ref" : “MyInstance" },
"MinSize" : "1",
"MaxSize" : "2",
"Cooldown" : "600",
"TerminationPolicies" : [ "NewestInstance" ],
"VPCZoneIdentifier" : [ "subnet-XXX" ],
"NotificationConfiguration" : {
"TopicARN" : { "Ref" : "SNSTopic" },
"NotificationTypes" : [
"autoscaling:EC2_INSTANCE_LAUNCH",
"autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
"autoscaling:EC2_INSTANCE_TERMINATE",
"autoscaling:EC2_INSTANCE_TERMINATE_ERROR"
]
}
}
},
"AppServerScaleUpPolicy" : {
"Type" : "AWS::AutoScaling::ScalingPolicy",
"AutoScalingGroupName" : { "Ref" :
"AppAutoScalingGroup" },
[..]
"ScalingAdjustment" : "1"
"AppServerScaleDownPolicy" : {
"Type" : "AWS::AutoScaling::ScalingPolicy",
"AutoScalingGroupName" : { "Ref" :
"AppAutoScalingGroup" },
[..]
"ScalingAdjustment" : "-1"
“AppCPUAlarmHigh": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"AlarmDescription": "Scale-up if CPU > 7% for 1 minute",
"MetricName": "CPUUtilization",
"Namespace": "AWS/EC2",
"Statistic": "Average",
"Period": "60",
"EvaluationPeriods": "1",
"Threshold": "7",
"AlarmActions": [ { "Ref": "AppServerScaleUpPolicy" } ],
[…]
"ComparisonOperator": "GreaterThanThreshold"
“AppCPUAlarmLow": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"AlarmDescription": "Scale-down if CPU < 5% for 2 minutes",
"MetricName": "CPUUtilization",
"Namespace": "AWS/EC2",
"Statistic": "Average",
"Period": "120",
"EvaluationPeriods": "1",
"Threshold": "5",
"AlarmActions": [ { "Ref": "AppServerScaleDownPolicy" } ],
[…]
"ComparisonOperator": "LessThanThreshold"
CF Limitation
 Maximum Stack Limit : 20
 Maximum size of an output name : 255 chars
 Maximum size of a resource name : 255 Chars
 Maximum size of a parameter name : 255 characters
 Maximum size of a parameter value : 4,096 bytes
 Maximum size of a template description : 1,024 bytes
 Maximum number of mapping attributes : 30 attributes
 Maximum amount of data that cfn-signal can pass: 4,096 bytes
 Maximum number of mappings that you can declare : 100 mappings
 Maximum number of parameters that you can declare : 60 parameters
 Maximum number of resources that you can declare in template : 200
 Maximum size of a template body that you can pass in a CreateStack, UpdateStack, or
ValidateTemplate request : 51,200 Bytes
 Maximum size of a template body that you can pass in an Amazon S3 object for a CreateStack,
UpdateStack, ValidateTemplate request with an Amazon S3 template URL. : 460,800 bytes
TROUBLESHOOTING STEPS
 Use good json editor to develop stack
 Validate template before deploying it
 For common error you can refer this link :
basic troubleshooting
 Watch Events and understand error thrown by stack.
 A small mistake in script can roll back stack process.
 You can put checkpoint message to log.
Best Practices
Planning and organizing :
 Organize Your Stacks By Lifecycle and Ownership
 Reuse Templates to Replicate Stacks in Multiple Environments
 Verify Quotas for All Resource Types
 Use Nested Stacks to Reuse Common Template Patterns
Creating templates :
 Do Not Embed Credentials in Your Templates
 Use AWS-Specific Parameter Types
 Use Parameter Constraints
 Use AWS::CloudFormation::Init to Deploy Software Applications on Amazon EC2
Instances
 Validate Templates Before Using Them
Managing stacks :
 Manage All Stack Resources Through AWS CloudFormation
 Use Stack Policies
 Use AWS CloudTrail to Log AWS CloudFormation Calls
 Use Code Reviews and Revision Controls to Manage Your Templates
Q/A

More Related Content

PPTX
Infrastructure as Code in AWS using Cloudformation
PPTX
AWS SQS SNS
PDF
[AWS Dev Day] 실습워크샵 | Amazon EKS 핸즈온 워크샵
PDF
Amazon AWS | What is Amazon AWS | AWS Tutorial | AWS Training | Edureka
PDF
AWS ELB
PDF
PDF
AWS 상의 컨테이너 서비스 소개 ECS, EKS - 이종립 / Principle Enterprise Evangelist @베스핀글로벌
PDF
All You Need to Know about AWS Elastic Load Balancer
Infrastructure as Code in AWS using Cloudformation
AWS SQS SNS
[AWS Dev Day] 실습워크샵 | Amazon EKS 핸즈온 워크샵
Amazon AWS | What is Amazon AWS | AWS Tutorial | AWS Training | Edureka
AWS ELB
AWS 상의 컨테이너 서비스 소개 ECS, EKS - 이종립 / Principle Enterprise Evangelist @베스핀글로벌
All You Need to Know about AWS Elastic Load Balancer

What's hot (20)

PDF
AWS Lambda를 기반으로한 실시간 빅테이터 처리하기
PDF
Arm 기반의 AWS Graviton 프로세서로 구동되는 AWS 인스턴스 살펴보기 - 김종선, AWS솔루션즈 아키텍트:: AWS Summi...
PPTX
서버리스 데이터 플로우 개발기 - 김재현 (Superb AI) :: AWS Community Day 2020
PDF
20분안에 스타트업이 알아야하는 AWS의 모든것 - 윤석찬 :: 스타트업얼라이언스 런치클럽
PDF
마이크로서비스를 위한 AWS 아키텍처 패턴 및 모범 사례 - AWS Summit Seoul 2017
PDF
AWS 클라우드 기반 확장성 높은 천만 사용자 웹 서비스 만들기 - 윤석찬
PDF
Meetup #4: AWS ELB Deep dive & Best practices
PPTX
[NDC17] Kubernetes로 개발서버 간단히 찍어내기
PDF
다양한 솔루션으로 만들어가는 AWS 네트워크 보안::이경수::AWS Summit Seoul 2018
PPT
Docker introduction
PDF
AWS 클라우드 서비스 소개 및 사례 (방희란) - AWS 101 세미나
PPTX
Cloud Formation
PDF
Packer, Terraform, Vault를 이용해 만드는 
재현 가능한 게임 인프라
PPTX
AWS basics
PDF
Amazon RDS Proxy 집중 탐구 - 윤석찬 :: AWS Unboxing 온라인 세미나
PDF
AWS Serverless Introduction (Lambda)
PDF
AWS Blackbelt 2015シリーズ Amazon Storage Service (S3)
PDF
Amazon EKS를 위한 AWS CDK와 CDK8s 활용법 - 염지원, 김광영 AWS 솔루션즈 아키텍트 :: AWS Summit Seou...
PDF
게임사를 위한 Amazon GameLift 세션 - 이정훈, AWS 솔루션즈 아키텍트
PDF
Infrastructure as Code with Terraform and Ansible
AWS Lambda를 기반으로한 실시간 빅테이터 처리하기
Arm 기반의 AWS Graviton 프로세서로 구동되는 AWS 인스턴스 살펴보기 - 김종선, AWS솔루션즈 아키텍트:: AWS Summi...
서버리스 데이터 플로우 개발기 - 김재현 (Superb AI) :: AWS Community Day 2020
20분안에 스타트업이 알아야하는 AWS의 모든것 - 윤석찬 :: 스타트업얼라이언스 런치클럽
마이크로서비스를 위한 AWS 아키텍처 패턴 및 모범 사례 - AWS Summit Seoul 2017
AWS 클라우드 기반 확장성 높은 천만 사용자 웹 서비스 만들기 - 윤석찬
Meetup #4: AWS ELB Deep dive & Best practices
[NDC17] Kubernetes로 개발서버 간단히 찍어내기
다양한 솔루션으로 만들어가는 AWS 네트워크 보안::이경수::AWS Summit Seoul 2018
Docker introduction
AWS 클라우드 서비스 소개 및 사례 (방희란) - AWS 101 세미나
Cloud Formation
Packer, Terraform, Vault를 이용해 만드는 
재현 가능한 게임 인프라
AWS basics
Amazon RDS Proxy 집중 탐구 - 윤석찬 :: AWS Unboxing 온라인 세미나
AWS Serverless Introduction (Lambda)
AWS Blackbelt 2015シリーズ Amazon Storage Service (S3)
Amazon EKS를 위한 AWS CDK와 CDK8s 활용법 - 염지원, 김광영 AWS 솔루션즈 아키텍트 :: AWS Summit Seou...
게임사를 위한 Amazon GameLift 세션 - 이정훈, AWS 솔루션즈 아키텍트
Infrastructure as Code with Terraform and Ansible
Ad

Similar to AWS CloudFormation Session (16)

PPTX
Programando sua infraestrutura com o AWS CloudFormation
PDF
AWS Cloud Formation
PPTX
Building and Deploying Application to Apache Mesos
PDF
Scalable and Fault-Tolerant Apps with AWS
PDF
Deployment and Management on AWS:
 A Deep Dive on Options and Tools
PPTX
Introduction to aws cloud formation
PDF
AWS CloudFormation Masterclass
PPTX
AWS CloudFormation Intrinsic Functions and Mappings
PPTX
Apache Kafka, HDFS, Accumulo and more on Mesos
PDF
5 things you don't know about Amazon Web Services
PPTX
Stratalux Cloud Formation and Chef Integration Presentation
PDF
CloudFormation experience
PDF
Elasticsearch And Apache Lucene For Apache Spark And MLlib
PDF
2013 05-fite-club-working-models-cloud-growing-up
PDF
Auto Scaling Groups
PDF
Ams adapters
Programando sua infraestrutura com o AWS CloudFormation
AWS Cloud Formation
Building and Deploying Application to Apache Mesos
Scalable and Fault-Tolerant Apps with AWS
Deployment and Management on AWS:
 A Deep Dive on Options and Tools
Introduction to aws cloud formation
AWS CloudFormation Masterclass
AWS CloudFormation Intrinsic Functions and Mappings
Apache Kafka, HDFS, Accumulo and more on Mesos
5 things you don't know about Amazon Web Services
Stratalux Cloud Formation and Chef Integration Presentation
CloudFormation experience
Elasticsearch And Apache Lucene For Apache Spark And MLlib
2013 05-fite-club-working-models-cloud-growing-up
Auto Scaling Groups
Ams adapters
Ad

Recently uploaded (20)

PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
AutoCAD Professional Crack 2025 With License Key
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
Nekopoi APK 2025 free lastest update
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PDF
Download FL Studio Crack Latest version 2025 ?
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
medical staffing services at VALiNTRY
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Design an Analysis of Algorithms I-SECS-1021-03
Why Generative AI is the Future of Content, Code & Creativity?
AutoCAD Professional Crack 2025 With License Key
17 Powerful Integrations Your Next-Gen MLM Software Needs
Odoo Companies in India – Driving Business Transformation.pdf
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
Nekopoi APK 2025 free lastest update
Navsoft: AI-Powered Business Solutions & Custom Software Development
Monitoring Stack: Grafana, Loki & Promtail
Download FL Studio Crack Latest version 2025 ?
Design an Analysis of Algorithms II-SECS-1021-03
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Digital Systems & Binary Numbers (comprehensive )
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
CHAPTER 2 - PM Management and IT Context
Wondershare Filmora 15 Crack With Activation Key [2025
medical staffing services at VALiNTRY
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus

AWS CloudFormation Session

  • 1. Aamazon Web Service Cloud-Formation By Kamal Maiti Sr. Subject Matter Expert Linux System Engineer Amdocs Development Center, India  Method to Create or Manage a Collection of AWS Resources.  Often Described as “Infrastructure as Code”.  Built with JSON Template Files. Dated : 3rd July, 2015
  • 2. AWS CLOUD-FORMATION Agenda : Phase 1 :  Style of Json scripting Syntax  Cloud-Formation(CF) scripting style & syntax  CF Scripting Block : Template version, Description, Parameters, Mappings, Resources, Outputs  CF AWS Resource Types, Resource Property types, Resource Attributes  Intrinsic Functions & usage Phase 2 :  CF helper scripts.  CF Stack & Template  Building environment using stack, updating stack  IAM role implementation  Auto-scaling  Troubleshooting, Best Practices  Q/A
  • 3. STYLE OF JSON SYNTAX JSON syntax is a subset of the JavaScript object notation syntax:  Data is in Key/value pairs : “Key” : “Value”  Data is separated by commas : “data1”, “data2”  Curly braces hold objects : { … }  Square brackets hold arrays : [ … ]
  • 4.  JSON Data - A Name(key) and a Value :  JSON data is written as KEY & VALUE pairs.  A Key/value pair consists of a field name (in double quotes), followed by a colon, followed by a value: Example : "firstName “ : “Smith" STYLE OF JSON SYNTAX KEY VALUE
  • 5.  JSON Values :  A number (integer or floating point)  A string (in double quotes)  A Boolean (true or false)  An array (in square brackets)  An object (in curly braces)  null STYLE OF JSON SYNTAX
  • 6.  JSON Objects :  JSON objects are written inside curly braces.  Just like in JavaScript, objects can contain multiple key / values pairs. Example : {"firstName":"Jhon", "lastName":"Smith"} STYLE OF JSON SYNTAX
  • 7.  JSON Arrays  JSON arrays are written inside square brackets.  Just like in JavaScript, an array can contain multiple objects. Example: "employees":[ {"firstName":"John", "lastName":"Doe"}, {"firstName":"Anna", "lastName":"Smith"}, {"firstName":"Peter", "lastName":"Jones"} ] STYLE OF JSON SYNTAX
  • 8. { "Title" : "The Daughter Of Time", "Author" : "Josephine Tey", "Genre" : " Crime, Thrillers & Mystery ", "Detail" : { "Publisher" : " Simon & Schuster ", "Publication_Year" : 2009 , "ISBN" : “0-684-80386-0", “Language" : "English", "Pages" : 999 }, "Price" : [ { "type" :"Hardcover", "price" : "17.99" }, { "type" : "Kindle Edition", "price" : "5.22" } ] } Json Script Example Main Object Starts Nested Object Starts Nested Object Starts First Sub Object Starts First Sub Object Ends Main Object Ends Nested Object Ends Nested Object Ends Array Starts (second object as array) Array Ends Value: String Value : Number No comma (, ) after last value
  • 9.  Cloud Formation uses Json scripting style & syntax.  Objects are wrapped within '{' and '}‘.  Arrays are enclosed by '[' and ']'.  Objects are list of key & Value pairs.  Arrays are list of values.  Both objects and arrays can be nested.  strings, numbers, booleans (i.e true and false) and null can be used as values. CLOUD-FORMATION SYNTAX
  • 10. AWS CF TEMPLATE FORMAT { “AWSTemplateFormatVersion” : “…”, “Description” : “…”, “Parameters” : “…”, “Mappings” : “…”, “Resources” : “…”, “Outputs: : “…” } Object Starts Object Ends No comma after last key/value Optional Mandatory Optional Optional Optional
  • 11. Editor for Developing CF script  oXygen XML Editor - Available in our Software Catalog. Live json syntax checker.  Online Editor : “jsoneditoronline.org” - I prefer to use. Live json syntax checker. “codebeautify.org/online-json-editor” – have not used
  • 12. VALIDATE AWS CF SCRIPT AWS CLI :  Through aws instance which has IAM role to execute aws commands  Or configure aws tool on a machine. Example : aws cloudformation validate-template –template-body file:////home/kamalma/example.json aws cloudformation validate –template-body https://s3.amazonaws.com/templates/example.json AWS MANAGEMENT CONSOLE GUI :  Automatically validates once you upload script.
  • 13. EXAMPLE OF CLOUD-FORMATION BLOCK { “AWSTemplateFormatVersion” : “2010-09-09”, “Description” : ”This is a test template” “Parameters” : { “Customer” : { “Description” : “Name of the customer”, “Type” : “String”, “Default” : “claro”, “AllowedValues” : [“claro”,”tyco”, “qpass”] } } } Static/fixed Name Variable/Cus tomizable Name Optional Optional Optional
  • 14. EXAMPLE OF CLOUD-FORMATION BLOCK { "Mappings" : { “MyRegionMap" : { "us-east-1" : { "AMI" : "ami-76f0061f“ }, "us-west-1" : { "AMI" : "ami-655a0a20“ }, "eu-west-1" : { "AMI" : "ami-7fd4e10b“ }, } } }, "Resources" : { "Ec2Instance" : { "Type" : "AWS::EC2::Instance", "Properties" : { "KeyName" : "MyKey", "ImageId" : { "Fn::FindInMap" : [ “MyRegionMap", { "Ref" : "AWS::Region" }, "AMI" ]} } } }, “Outputs” : { } } Static Name Static Name Static Name First Key Second Name User Defined Name User Defined Name
  • 15.  CF AWS Resource Section :  Type  Properties  Attributes Cloud-Formation AWS “Resources”  Standard Resource Type Format : AWS::ProductIdentifier::ResourceType Example: AWS::EC2::Instance  Each resource has “Properties” object block  Each Resource has attribute(s) inside of property or outside of it.
  • 16. { "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "Ec2 block device mapping", "Resources" : { "MyEC2Instance" : { "Type" : "AWS::EC2::Instance", "Properties" : { "ImageId" : "ami-79fd7eee", "KeyName" : "testkey", "BlockDeviceMappings" : [ { "DeviceName" : "/dev/sdm", "Ebs" : { "VolumeType" : “gp2", "Iops" : "200", "DeleteOnTermination" : "false", "VolumeSize" : "20“ } } ] } } } } Resource Type Resource Property Block Resource Attributes
  • 17. How Do I know all AWS Resource names, Resource Types, Resource Attributes ?  Amazon online link : http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html And Go to “Template Reference” section.  Refer cloud-formation user guide pdf [cfn-ug.pdf]
  • 18. Intrinsic Functions  AWS CF built-in functions  Helps to manage stacks Currently available functions : Fn::Base64  Returns the Base64 representation of the input string Condition Functions  Used to define various condition. Example: Fn::And, Fn::Equals, Fn::If, Fn::Not, Fn::Or Fn::FindInMap  Returns the value corresponding to keys in a two-level map that is declared in the Mappings section Fn::GetAtt  Returns the value of an attribute from a resource in the template Fn::GetAZs  Returns an array that lists Availability Zones for a specified region Fn::Join  Appends a set of values into a single value, separated by the specified delimiter. Fn::Select  Returns a single object from a list of objects by index. Ref  Returns the value of the specified parameter or resource.
  • 19. Intrinsic Function Usage Fn::Base64 Usage : Usually used in Userdata section Declaration : { "Fn::Base64" : valueToEncode } Example : { "MyInstance": { "Type": "AWS::EC2::Instance", "Metadata": { : }, "Properties": { "ImageId" : "ami-12345678", "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ "#!/bin/bashn", "/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackName" }, " -r MyInstance ", " --region ", { "Ref" : "AWS::Region" }, "n", "/opt/aws/bin/cfn-signal -e 0 --stack ", { "Ref" : "AWS::StackName" }, " --resource MyInstance n" ] ] } } } } }
  • 20. Intrinsic Function Usage Condition Functions Fn::And Declaration : "Fn::And": [{condition}, {...}] Parameters : condition : A condition that evaluates to true or false. Example : The following MyAndCondition evaluates to true if the referenced security group name is equal to sg-mysggroup and if SomeOtherCondition evaluates to true: "MyAndCondition": { "Fn::And": [ {"Fn::Equals": ["sg-mysggroup", {"Ref": "ASecurityGroup"}]}, {"Condition": "SomeOtherCondition"} ] }
  • 21. Intrinsic Function Usage Fn::FindInMap Declaration : "Fn::FindInMap" : [ "MapName", "TopLevelKey", "SecondLevelKey"] Parameters : MapName : The logical name of a mapping declared in the Mappings section that contains the keys and values. TopLevelKey: The top-level key name. Its value is a list of key-value pairs. SecondLevelKey: The second-level key name, which is set to one of the keys from the list assigned to TopLevelKey. Return Value: The value that is assigned to SecondLevelKey. { ... "Mappings" : { "RegionMap" : { "us-east-1" : { "32" : "ami-6411e20d", "64" : "ami-7a11e213" }, "us-west-1" : { "32" : "ami-c9c7978c", "64" : "ami-cfc7978a" }, "eu-west-1" : { "32" : "ami-37c2f643", "64" : "ami-31c2f645" }, "ap-southeast-1" : { "32" : "ami-66f28c34", "64" : "ami-60f28c32" }, "ap-northeast-1" : { "32" : "ami-9c03a89d", "64" : "ami-a003a8a1" } } }, "Resources" : { "myEC2Instance" : { "Type" : "AWS::EC2::Instance", "Properties" : { "ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "32"]}, "InstanceType" : "m1.small" } } } } NB : In above example, if you are build stack in us-west-1 region, for 64 bit instance, it’ll use “ami-cfc7978a”
  • 22. Intrinsic Function Usage Fn::GetAtt Declaration : "Fn::GetAtt" : [ "logicalNameOfResource", "attributeName" ] Parameters : logicalNameOfResource: The logical name of the resource that contains the attribute you want. attributeName: The name of the resource-specific attribute whose value you want. Example : “Outputs” : { "PrivateIP" : { "Description" : "Private IP of newly created EC2 instance", "Value" : { "Fn::GetAtt" : ["EC2Instance", "PrivateIp"] } } }
  • 23. Intrinsic Function Usage Ref Declaration : "Ref" : "logicalName" Parameters : logicalName: The logical name of the resource or parameter you want to dereference. Example : "MyEIP" : { "Type" : "AWS::EC2::EIP", "Properties" : { "InstanceId" : { "Ref" : "MyEC2Instance" } } }
  • 24. Intrinsic Function Usage Fn::Join Declaration : "Fn::Join" : [ "delimiter", [ comma-delimited list of values ] ] Return Value : The combined string. Example : "Fn::Join" : [ ":", [ "a", "b", "c" ] ] This example returns: "a:b:c".
  • 25. PHASE 2  CF helper scripts.  CF Stack & Template  Building environment using stack, updating stack  IAM Role Implementation  Auto-scaling  CF Limitation  Troubleshooting  Best Practices  Q/A Agenda :
  • 26. CF Helper Scripts  Set of Python Scripts  Scripts work in conjunction with resource metadata  Scripts run on the Amazon EC2 instance as part of the stack creation process  Pre-installed on the latest versions of the Amazon Linux AMI  For other AMI, you have to install before using it.  AWS CloudFormation provides the following helpers: cfn-init: Used to retrieve and interpret the resource metadata, installing packages, creating files and starting services. cfn-signal: A simple wrapper to signal an AWS CloudFormation CreationPolicy or WaitCondition, enabling you to synchronize other resources in the stack with the application being ready. cfn-get-metadata: A wrapper script making it easy to retrieve either all metadata defined for a resource or path to a specific key or subtree of the resource metadata. cfn-hup: A daemon to check for updates to metadata and execute custom hooks when the changes are detected.
  • 27. CF Helper Scripts Usage "UserData":{ "Fn::Base64":{ "Fn::Join":[ "", [ "#!/bin/bash -xen", "# Install the files and packages from the metadatan", "/opt/aws/bin/cfn-init -v ", " --stack ", { "Ref" : "AWS::StackName" }, " --resource EC2Instance", " --configsets InstallSoftware", " --region ", { "Ref" : "Region" }, "n", "# Start up the cfn-hup daemon to listen for changes to the metadatan", "/opt/aws/bin/cfn-hup || error_exit 'Failed to start cfn-hup'n", "# Signal the status from cfn-initn", "/opt/aws/bin/cfn-signal -e $? ", " --stack ", { "Ref" : "AWS::StackName" }, " --resource EC2Instance", " --region ", { "Ref" : "Region" }, "n" ]] } } User data section of EC2 resource Called cfn-init script Run cfn-hup deamon Checks return status of cfn-init
  • 28. "Metadata" : { "AWS::CloudFormation::Init" : { "configSets" : { "InstallSoftware" : ["Install"] }, "Install" : { "files" : { "/etc/cfn/cfn-hup.conf" : { "content" : { "Fn::Join" : ["", [ "[main]n", "stack=", { "Ref" : "AWS::StackId" }, "n", "region=", { "Ref" : "Region" }, "n" ]]}, "mode" : "000400", "owner" : "root", "group" : "root“ }, "/etc/cfn/hooks.d/cfn-auto-reloader.conf" : { "content": { "Fn::Join" : ["", [ "[cfn-auto-reloader-hook]n", "triggers=post.updaten", "path=Resources.WebServerInstance.Metadata.AWS::CloudFormation::Initn", "action=/opt/aws/bin/cfn-init -v ", " --stack ", { "Ref" : "AWS::StackName" }, " --resource EC2Instance ", " --configsets InstallSoftware ", " --region ", { "Ref" : "Region" }, "n", "runas=rootn" ]]} } }, "commands" : { "configure node" : { "command" : { "Fn::Join" : ["", [ "logger 'finised commandlines' n" ]] } } }, "services" : { "sysvinit" : { "cfn-hup" : { "enabled" : "true", "ensureRunning" : "true", "files" : ["/etc/cfn/cfn-hup.conf", "/etc/cfn/hooks.d/cfn-auto- reloader.conf"]} } }} } } EC2 Metadata section EC2 standard cfn-init section Cfn-hup config file Cfn-hup autoloader config file Auto-loader will be used for post update only Starts cfn-hup as daemon
  • 29. CF Stack & Template  Nested Template can be called to reuse same template  Resource "Type" : "AWS::CloudFormation::Stack“ must be used.  "TemplateURL" needs to be used in Property section.  "Parameters" can be passed from master to nested template Example : "Resources" : { "FrontNodeStack" : { "Type" : "AWS::CloudFormation::Stack", "Properties" : { "TemplateURL" : "https://s3-sa-east-1.amazonaws.com/claro-templates-static-sa- east-1/tyco-front-back-nested-ec2-gru1.json", "Parameters" : { "Customer" : { "Ref" : "Customer“ }, […] "PuppetMaster" : {"Ref" : "PuppetMaster"} } } } } Stack resource Type
  • 30. Building Environment Using Stack Template  Deploy Stack : Two ways :  GUI ie AWS management console  AWS SLI/SDK/API call Example using AWS command : aws cloudformation create-stack --stack-name myteststack --capabilities CAPABILITY_IAM --template-body file:////home/kamalma/cloudformation/vol- attachment-ec2.json Using AWS management console :  Upload template on S3 in the region where you want deploy  Click on “Cloud Formation”  Click on “Create Stack” and provide required details.
  • 31. UPDATING STACK  AWS CLI : Example : aws cloudformation update-stack --stack-name qpass-cf-util-gru1-v3-test1 --template-body file:////home/kamalma/cloudformation/qpass-cf-util-gru1-v3.json  Change Parameter Value : aws cloudformation update-stack --stack-name mystack --template-url https://s3.amazonaws.com/sample/updated.template --parameters ParameterKey=KeyPairName,ParameterValue=SampleKeyPair ParameterKey=SubnetIDs,ParameterValue=SampleSubnetID1,SampleSubnetID2 For more details on CLI, refer : http://docs.aws.amazon.com/cli/latest/reference/
  • 32. IAM Role Implementation  User  Group  Role based ie a resource can work like a group to do action on other resources. Example : Ec2 instance can retrieve/update/update data on s3 bucket if role base code is put in CF.  Avoid to use credentials based authentication in CF.
  • 33. Auto-Scaling “MyInstance" : { "Type" : "AWS::AutoScaling::LaunchConfiguration", "Properties" : { "SecurityGroups" : [“XXXX"], […] } } “AppAutoScalingGroup" : { "Type" : "AWS::AutoScaling::AutoScalingGroup", "Properties" : { "AvailabilityZones" : { "Fn::GetAZs" : "" }, "LaunchConfigurationName" : { "Ref" : “MyInstance" }, "MinSize" : "1", "MaxSize" : "2", "Cooldown" : "600", "TerminationPolicies" : [ "NewestInstance" ], "VPCZoneIdentifier" : [ "subnet-XXX" ], "NotificationConfiguration" : { "TopicARN" : { "Ref" : "SNSTopic" }, "NotificationTypes" : [ "autoscaling:EC2_INSTANCE_LAUNCH", "autoscaling:EC2_INSTANCE_LAUNCH_ERROR", "autoscaling:EC2_INSTANCE_TERMINATE", "autoscaling:EC2_INSTANCE_TERMINATE_ERROR" ] } } }, "AppServerScaleUpPolicy" : { "Type" : "AWS::AutoScaling::ScalingPolicy", "AutoScalingGroupName" : { "Ref" : "AppAutoScalingGroup" }, [..] "ScalingAdjustment" : "1" "AppServerScaleDownPolicy" : { "Type" : "AWS::AutoScaling::ScalingPolicy", "AutoScalingGroupName" : { "Ref" : "AppAutoScalingGroup" }, [..] "ScalingAdjustment" : "-1" “AppCPUAlarmHigh": { "Type": "AWS::CloudWatch::Alarm", "Properties": { "AlarmDescription": "Scale-up if CPU > 7% for 1 minute", "MetricName": "CPUUtilization", "Namespace": "AWS/EC2", "Statistic": "Average", "Period": "60", "EvaluationPeriods": "1", "Threshold": "7", "AlarmActions": [ { "Ref": "AppServerScaleUpPolicy" } ], […] "ComparisonOperator": "GreaterThanThreshold" “AppCPUAlarmLow": { "Type": "AWS::CloudWatch::Alarm", "Properties": { "AlarmDescription": "Scale-down if CPU < 5% for 2 minutes", "MetricName": "CPUUtilization", "Namespace": "AWS/EC2", "Statistic": "Average", "Period": "120", "EvaluationPeriods": "1", "Threshold": "5", "AlarmActions": [ { "Ref": "AppServerScaleDownPolicy" } ], […] "ComparisonOperator": "LessThanThreshold"
  • 34. CF Limitation  Maximum Stack Limit : 20  Maximum size of an output name : 255 chars  Maximum size of a resource name : 255 Chars  Maximum size of a parameter name : 255 characters  Maximum size of a parameter value : 4,096 bytes  Maximum size of a template description : 1,024 bytes  Maximum number of mapping attributes : 30 attributes  Maximum amount of data that cfn-signal can pass: 4,096 bytes  Maximum number of mappings that you can declare : 100 mappings  Maximum number of parameters that you can declare : 60 parameters  Maximum number of resources that you can declare in template : 200  Maximum size of a template body that you can pass in a CreateStack, UpdateStack, or ValidateTemplate request : 51,200 Bytes  Maximum size of a template body that you can pass in an Amazon S3 object for a CreateStack, UpdateStack, ValidateTemplate request with an Amazon S3 template URL. : 460,800 bytes
  • 35. TROUBLESHOOTING STEPS  Use good json editor to develop stack  Validate template before deploying it  For common error you can refer this link : basic troubleshooting  Watch Events and understand error thrown by stack.  A small mistake in script can roll back stack process.  You can put checkpoint message to log.
  • 36. Best Practices Planning and organizing :  Organize Your Stacks By Lifecycle and Ownership  Reuse Templates to Replicate Stacks in Multiple Environments  Verify Quotas for All Resource Types  Use Nested Stacks to Reuse Common Template Patterns Creating templates :  Do Not Embed Credentials in Your Templates  Use AWS-Specific Parameter Types  Use Parameter Constraints  Use AWS::CloudFormation::Init to Deploy Software Applications on Amazon EC2 Instances  Validate Templates Before Using Them Managing stacks :  Manage All Stack Resources Through AWS CloudFormation  Use Stack Policies  Use AWS CloudTrail to Log AWS CloudFormation Calls  Use Code Reviews and Revision Controls to Manage Your Templates
  • 37. Q/A