- Infrastructure as code is the practice of provisioning and managing infrastructure using code and software development techniques like version control. This allows infrastructure changes to be tested and deployed in a consistent, repeatable way.
- AWS services like CloudFormation, OpsWorks, and CodeDeploy allow defining infrastructure as code templates and automating the deployment of applications and infrastructure changes across environments like development, testing, and production.
- CloudFormation templates define AWS resources and their dependencies and can be used to create matching environments in different stages. OpsWorks and CodeDeploy help manage application deployments and ongoing configuration of running systems.
3. Infrastructure as Code is a practice in
which infrastructure is provisioned and
managed using code and software
development techniques, such as
version control and continuous
integration and delivery.
4. Why Infrastructure as Code?
• Faster development cycles
• Increasing need for “Immutable” architectures
• Predictable and reproducible environments are a norm
• Managing instances can become cumbersome and
requires convoluted processes in enterprises
• Automation is a must have element in any application
• Microservices are becoming the new standard for
application architectures, driving a number of trends
5. “It’s all software”
AWS Resources
Operating System and Host Configuration
Application Configuration
15. How do you currently
provision infrastructure for
your customers?
16. Create templates of your infrastructure
CloudFormation provisions AWS resources
based on dependency needs
Version control/replicate/update templates like
code
Integrates with development, CI/CD,
management tools
Launched in 2010
AWS
CloudFormation
17. Template CloudFormation Stack
JSON formatted file
Parameter definition
Resource creation
Configuration actions
Configured AWS resources
Comprehensive service support
Service event aware
Customizable
Framework
Stack creation
Stack updates
Error detection and rollback
CloudFormation – Components & Technology
21. Option 2: AWS CloudFormation provides helper scripts for deployment within your EC2
instances
Metadata Key — AWS::CloudFormation::Init
Cfn-init reads this metadata key and installs the packages listed in this key (e.g.,
httpd, mysql, and php). Cfn-init also retrieves and expands files listed as sources.
cfn-hup
cfn-signal
cfn-get-
metadata
Amazon EC2AWS CloudFormation
cfn-init
Bootstrapping Applications & Handling Updates
23. CloudFormation in a DevOps pipeline
AWS
CloudFormationIssue Tracker
App Developers
DevOps Engineers,
Infrastructure Developers,
Systems Engineers
Dev Env Code Repo
App Pkgs,
CloudFormation
Templates, Etc.
CI Server
Test
Staging
ProdCode Review
"Infra-as-Code"
App Code
& Templates
25. Template File
Defining Stack
The entire infrastructure can be
represented in an AWS
CloudFormation template.
Many Stacks & Environments from One Template
26. Template File
Defining Stack
The entire infrastructure can be
represented in an AWS
CloudFormation template.
Use the version
control system of
your choice to
store and track
changes to this
template
Many Stacks & Environments from One Template
Git
Perforce
SVN
…
27. Template File
Defining Stack
Git
Perforce
SVN
…
Dev
Test
Prod
The entire infrastructure can be
represented in an AWS
CloudFormation template.
Use the version
control system of
your choice to
store and track
changes to this
template
Build out multiple
environments, such
as for Development,
Test, Production and
even DR using the
same template
Many Stacks & Environments from One Template
29. AWS CodeDeploy
Automates code deployments to any instance
Handles the complexity of updating your applications
Avoid downtime during application deployment
Deploy to Amazon EC2 or on-premises servers, in
any language and on any operating system
30. Amazon EC2
How CodeDeploy works
3
Amazon S3
1 Deployable Assets and
AppSpec file
AWS CodeDeploy
Deployment Logic and
Metadata
2
4
31. How do I manage the
application once provisioned?
32. Ongoing Management
• Updates/patches?
• New software?
• New configurations?
• New code deploys?
• Pool specific changes?
• Environment specific changes?
• Run commands across all hosts?
• Be on top of all running resources?
34. Could we do this with AWS CloudFormation?
Sure! But potentially tricky to do at scale:
• Try changing a vhost configuration on every web
server across multiple environments (dev, stage,
prod)
• Install a package on certain hosts, but not others to
test out newer versions
• Need to change LDAP config on every running
Amazon EC2 Linux host, but they are across 25
different AWS CloudFormation templates?
35. Why do you need OpsWorks?
Model and group your applications
Manage the lifecycle of your instances
Control Access Management
Monitor the health of your resources
Analyze logging information
Mitigate operational problems
36. Configure your instances using AWS OpsWorks
Uses Chef to configure the software on the instances
Chef provides a Ruby DSL abstraction for common OS operations
Associates predefined scripts (i.e., Chef cookbooks) with your instances
Applies cookbooks configuration changes using lifecycle events
42. A stack represents
the cloud
infrastructure and
applications that
you want to
manage together.
A layer defines
how to set up and
configure a set of
instances and
related resources.
Then deploy your
app to specific
instances and
customize the
deployment with
Chef recipes.
Decide how to
scale: manually,
with 24/7
instances, or
automatically, with
load-based or
time-based
instances.
AWS OpsWorks
43. AWS OpsWorks Instance Lifecycle
Setup Configure Deploy Undeploy Shutdown
Agent on each instance understands a set
of commands that are triggered by
OpsWorks. The agent then runs Chef.