Infrastructure as code defines and provisions infrastructure through code or declarative configuration. On AWS, it can describe networks, virtual machines, load balancers, DNS entries, storage, and databases, then automate their creation and modification. section 1.3.3 section 4.4
AWS exposes hardware and software services through an API; infrastructure as code turns that programmable foundation into repeatable infrastructure definitions. section 4.0
Use the AWS automation layer that matches the task:
- Run the command-line interface from a terminal, including scripts written in Bash or PowerShell. section 4.0 section 4.6
- Use an SDK from a supported programming language to embed AWS operations in an application. section 4.0 section 4.6
- Use CloudFormation templates in JSON or YAML to declare the desired infrastructure state; CloudFormation resolves the required API calls. section 4.0 section 4.6
- Apply software-development practices such as code repositories, automated tests, and build servers to infrastructure definitions. section 4.4
Changing an EC2 instance type
With imperative commands, stop the EC2 instance, wait, change its type, start it, and wait again. With CloudFormation, change the InstanceType property in the template and update the stack. A template can accept the instance type as a parameter, while the resulting deployed environment is called a stack. section 4.5.2













