Skip to content
Pablo Rodriguez

Infrastructure As Code

Infrastructure as Code (IaC) is an industry term that refers to the process of provisioning and managing cloud resources by defining them in a template file that is both human-readable and machine-consumable.

Any application environment requires many infrastructure components:

  • Operating systems
  • Database connections
  • Storage

Developers regularly need to set up, update, and maintain infrastructure to develop, test, and deploy applications.

Key Benefit

With IaC, you define your infrastructure’s desired state without including all the steps to get to that state. Organizations use infrastructure as code to control costs, reduce risks, and respond with speed to new business opportunities.

Manual infrastructure management is time-consuming and prone to error - especially when managing applications at scale. IaC provides a workable solution to challenges such as how to replicate, redeploy, and repurpose infrastructure reliably and consistently.

Rapid Deployment

Rapidly deploy complex environments with configuration consistency using templates

Change Management

Propagate changes to all stacks by modifying the template

Resource Cleanup

Clean up by deleting the stack, which deletes all created resources

Key Benefits: Reusability, Repeatability, and Maintainability

Section titled “Key Benefits: Reusability, Repeatability, and Maintainability”

Complex Environment Deployment: If you build infrastructure with code, you can rapidly deploy complex environments. With one template (or combination of templates), you can build the same complex environments repeatedly.

Environment Consistency: A stack can include all resources required to run a web application - web server, database, and networking rules. You can use a single template to create three different stacks:

  • Stack 1: Development environment (flexible and dynamic for prototyping, writing, testing, and debugging)
  • Stack 2: Test environment (simulates production for functionality, performance, and reliability testing)
  • Stack 3: Production environment (where application is available to end users)

Using one template for these three stacks provides greater confidence that if test jobs performed well in the test environment, they will also perform well in production. The template minimizes risk of configuration differences between environments.

Change Propagation: If you must make a configuration update in the test environment, you can push the update to the template to update all stacks. This ensures modifications to a single environment will be reliably propagated to all environments that should receive the update.

Cost Management: Clean up all resources created in your account for a test environment after you no longer need them. This reduces costs associated with unnecessary resources and keeps your account clean.

CloudFormation provides a simplified way to model, create, and manage a collection of AWS resources.

  • Collection Management: A collection of resources is called a CloudFormation stack
  • Stack Operations: Can create, update, and delete stacks
  • Predictable Provisioning: Enables orderly and predictable provisioning and updating of resources
  • Version Control: Enables version control of AWS resource deployments

CloudFormation Model Concept: You author a document that describes what your infrastructure should be, including all AWS resources that should be part of the deployment. You can think of this document as a model. You then use the model to create the reality because CloudFormation can actually create the resources in your account.

Version Control Integration: By using CloudFormation, you can treat your infrastructure as code. Author it with any code editor, check it into a version control system such as GitHub, and review files with team members before deploying into appropriate environments. With version control, you can use essential rollback capabilities.

AWS offers other services that help with creation, deployment, and maintenance of infrastructure in a programmatic way. Each service offers options for abstracting parts of the coding required to build infrastructure.

AWS Elastic Beanstalk - A fully managed service that automatically launches an AWS environment with your uploaded application code. Deploy and manage applications without learning about underlying infrastructure.

Decision Factors: Your choice should depend on the relative level of convenience and control needed, and the skills of your architecting and development teams. Whichever service you choose, behind the scenes, AWS will use CloudFormation to deploy your resources.

Infrastructure as Code transforms manual, error-prone processes into automated, repeatable, and version-controlled infrastructure deployment. CloudFormation serves as the foundation for AWS IaC solutions, providing the core capabilities that other AWS services build upon.