EC2 with Terraform
Simple Terraform template to create an AWS EC2 Instance.
This template will create a single EC2 instance with Terraform. The repository documents what the files do and what commands to run in order to successfully provision the EC2 instance.
Usage
- Insert AWS credentials to dev.conf and dev.tfvars
- Add the S3 Bucket where the .tfstate will be stored in dev.conf
- Pick your ami ID and copy it into main.tf
- Copy your key name into main.tf
- Add your security group(s) into main.tf (optional)
- Run the following commands
Initialize Terraform with our config:
terraform init --backend-config=config/dev.conf
Output the plan:
terraform plan --var-file=config/dev.tfvars
Terraform will check the current state and attempt to match the desired state.
Save the plan to a file:
terraform plan -out myplan --var-file=config/dev.tfvars
Apply the changes:
terraform apply myplan