This session will walk through practical examples and live demonstrations using AWS CloudFormation, AWS OpsWorks, orchestration engines and source control systems to automate your infrastructure deployment and maintenance.
17. • Modify existing template
• Or create a new one
– Ensure all resources are
present
• Infrastructure as Code:
– Store in version control
– Store with your code
– Git, Subversion, etc
Update your template, apply it to the stack
"Resources" : {
"BrandNewDNSrecord" : {
"Type" : "AWS::Route53::RecordSet",
"Properties" : {
"Comment" : "Demo for Summit 2015",
"HostedZoneId" : "ABC123BUZZY",
"Name" : "summit.buzzy.geek.nz.",
"TTL" : "60",
"Type" : "A"
}
}
}
24. The love story so far...
• Repeatable deployments
• Versioned Infrastructure
as code
25. Deploying different environments
• Multiple similar environments
– Production
– Test, Development
– Multiple AWS regions
• Avoid becoming a template factory
– Fewer, more adaptable templates
26. Example: Production or Dev?
stack
Auto Scalingstack
Elastic Load
Balancing
template
Web Server
security group
RDS Database
MySQL
security group security group
Instances
RDS Database
MySQL
security group
27. • A parameter to specify
the kind of stack
Parameters and Conditions
"Parameters" : {
"EnvironmentType" : {
"Description" : "Production or Development environment",
"AllowedValues" : [ "Prod", "Dev" ],
"ConstraintDescription" : "Must be Prod or Dev"
}
"Conditions" : {
"UseProdCondition" : {
"Fn::Equals" : [{"Ref" : "EnvironmentType"}, "Prod"]
},
"UseDevCondition" : {
"Fn::Equals" : [{"Ref" : "EnvironmentType"}, "Dev"]
}
"Resources": {
"WebServer": {
"Type": "AWS::EC2::Instance",
"Condition": "useDevCondition",
},
28. • A parameter to specify
the kind of stack
• Conditions that will be
evaluated
Parameters and Conditions
"Parameters" : {
"EnvironmentType" : {
"Description" : "Production or Development environment",
"AllowedValues" : [ "Prod", "Dev" ],
"ConstraintDescription" : "Must be Prod or Dev"
}
"Conditions" : {
"UseProdCondition" : {
"Fn::Equals" : [{"Ref" : "EnvironmentType"}, "Prod"]
},
"UseDevCondition" : {
"Fn::Equals" : [{"Ref" : "EnvironmentType"}, "Dev"]
}
"Resources": {
"WebServer": {
"Type": "AWS::EC2::Instance",
"Condition": "UseDevCondition",
},
29. • A parameter to specify
the kind of stack
• Conditions that will be
evaluated
• Determines whether a
resource or property
should be created
Parameters and Conditions
"Parameters" : {
"EnvironmentType" : {
"Description" : "Production or Development environment",
"AllowedValues" : [ "Prod", "Dev" ],
"ConstraintDescription" : "Must be Prod or Dev"
}
"Conditions" : {
"UseProdCondition" : {
"Fn::Equals" : [{"Ref" : "EnvironmentType"}, "Prod"]
},
"UseDevCondition" : {
"Fn::Equals" : [{"Ref" : "EnvironmentType"}, "Dev"]
}
"Resources": {
"WebServer": {
"Type": "AWS::EC2::Instance",
"Condition": "UseDevCondition",
},
30. Example: Production or Dev?
stack
Auto Scalingstack
Elastic Load
Balancing
template
Web Server
security group
RDS Database
MySQL
security group security group
Instances
Parameter:
Prod or Dev
RDS Database
MySQL
security group
31. • Logic about how a
resource will be created
Mappings
"Parameters" : {
"EnvironmentType" : {
"Description" : "Production or Development environment",
"AllowedValues" : [ "Prod", "Dev" ],
"ConstraintDescription" : "Must be Prod or Dev"
},
"Mappings" : {
"SourceAMI" : {
"Prod" : { "ap-southeast-1" : "ami-d34db33f", "us-east-1" : "ami-12345678" },
"Dev" : { "ap-southeast-1" : "ami-d5f8fc0d", "us-east-1" : "ami-b6c63d8f" }
}
}
"Resources": {
"WebServer": {
"ImageID" : { "Fn::FindInMap" : [ "SourceAMI", { "Ref" : "EnvironmentType" },
{ "Ref" : "AWS::Region" ] }
35. The love story so far...
• Repeatable deployments
• Versioned Infrastructure as code
• Use-case specific deployments
36. Expanding your use of CloudFormation:
Working with multiple templates
An inevitability as you grow
• Stack limits (60 outputs, 200 resources, 51200 bytes)
• Segregation of duties
• Velocity of change
Layers of stacks
• Identity
• Network
• Shared services
• Back end services
• Front end services
59. The love story…
• Repeatable deployments
• Versioned Infrastructure as code
• Use-case specific deployments
• Management at scale
• Application automation
60. Next steps
• Get the templates used in this session:
http://s3.buzzy.geek.nz/summit2015
• Experiment!