Create and deploy multiple EC2 AMIs dynamically using Terraform
This repository demonstrates how to use Terraform to build and deploy multiple types of AWS EC2 AMIs dynamically.
It serves as a hands-on reference for anyone creating reusable, scalable infrastructure on AWS.
This project illustrates:
- How to automatically generate multiple EC2 AMIs using Terraform
- How to scale and template AMI creation based on variables
- How to structure your IaC for repeatable and automated deployments
If you're looking to understand dynamic AMI provisioning or replicate EC2 environments consistently, this repo is the perfect starting point.
Before deploying:
- An AWS Account with properly configured AWS CLI credentials (
aws configure) - Terraform installed
👉 Need it? Follow the official guide:
https://learn.hashicorp.com/tutorials/terraform/install-cli
- Follow AWS least-privilege IAM best practices:
https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege - Tested in us-west-1, but should deploy in any AWS region
- Deploying resources will incur AWS charges
This deploys into your AWS CLI’s default profile:
cd aws-compu-terraform
terraform init
terraform validate
terraform apply --auto-approveRemove all created infrastructure:
terraform destroy --auto-approve- Clone the repository
- Navigate into the project directory
- Run:
| Command | Purpose |
|---|---|
terraform init |
Initializes working directory & downloads providers |
terraform validate |
Validates syntax and config structure |
terraform plan |
Shows execution plan before applying |
terraform apply |
Deploys the infrastructure |
terraform apply -auto-approve |
Deploys without prompt |
terraform destroy |
Tears down infrastructure |
terraform destroy -auto-approve |
Tear down without prompt |
terraform fmt -recursive |
Formats all Terraform code |
🛠️ Built with Terraform ☁️ Deployed on AWS ✨ Developed by Augusto Valdivia
