AWS CloudFormation Intrinsic Functions and Mappings

Post on 12-Jan-2017

474 views 3 download

transcript

AWS CloudFormationIntrinsic Functions and Mappings

Managing Windows instances in the Cloud

Sponsors

Presented by Adam Book from

Find me on LinkedIn

CloudFormation Deep Dive

CloudFormation Review

AWS CloudFormation Allows you to build Infrastructure as code using templates which are constructed from json.

CloudFormation Template

There are 8 sections of a Cloud formation template, most of which are optional

Format Version (optional)

Description (optional)

Metadata (optional)

Mappings (optional)

Parameters(optional)

Conditions(optional)

Resources (required)

Outputs(optional)

CloudFormationIntrinsic FunctionsFunction OverviewFn::Base64 returns the Base64 representation of the input string (user data)

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.

CloudFormationMappings

The Mappings section is optional but is matches a key to a corresponding set of named values. If you want to set values based on region, you can create a mapping that uses the key as the name and then contains the values you want to specify for each region.

You cannot include parameters, pseudo parameters, or intrinsic functions in the Mappings section.

CloudFormationMappings - cont. "Mappings" : { "RegionMap" : { "us-east-1" : { "32" : "ami-6411e20d"}, "us-west-1" : { "32" : "ami-c9c7978c"}, "eu-west-1" : { "32" : "ami-37c2f643"}, "ap-southeast-1" : { "32" : "ami-66f28c34"}, "ap-northeast-1" : { "32" : "ami-9c03a89d"} } }

CloudFormationMappings - cont. "asgApp": { "MinSize" : { "value": "2" }, "MaxSize" : { "value": "2" }, "DesiredCapacity" : { "value": "2" }, "HealthCheckType" : { "value": "EC2" }, "TerminationPolicies" : { "value": "OldestInstance" } }

CloudFormationMappings - cont.

"asgAppA": { "Type": "AWS::AutoScaling::AutoScalingGroup", "Properties": { "AvailabilityZones" : { "Ref": "AZs" }, "VPCZoneIdentifier" : { "Ref": "PrivateAPPSubnets" }, "LaunchConfigurationName" : { "Ref": "LaunchConfig" }, "MinSize" : { "Fn::FindInMap": [ "asgApp", "MinSize", "value" ] }, "MaxSize" : { "Fn::FindInMap": [ "asgApp", "MaxSize", "value" ] }, "DesiredCapacity" : { "Fn::FindInMap": [ "asgApp", "DesiredCapacity", "value" ] }, "HealthCheckType" : { "Fn::FindInMap": [ "asgApp", "HealthCheckType", "value" ] }, "TerminationPolicies" : [{ "Fn::FindInMap": [ "asgApp", "TerminationPolicies", "value" ] }],

Cloud Formation Templates Real World Examples

Photo curtesyof Stephen Radford via http://snap.io

Questions?

Image by http://www.gratisography.com/