This code is used to deploy an AWS EC2 instance as well as an Amazon Virtual Private Cloud (VPC).
These are the requirements for this module.
Terraform | |
---|---|
>= | 1.0.11 |
Terragrunt | |
---|---|
>= | 0.31.0 |
- Clone terraform modules repository at the top level directory
git clone [email protected]:flugel-it/workshop-live-infra.git
- Configure your environment with the correct AWS profile
export AWS_PROFILE=<profile name>
- Optional: Initialize each environment's resource you're going to work on
- To initialize all the resources
./scripts/initialize.sh <environment> # environment: dev, staging
- To initialize only one resource
cd <environment>/<resource> # ex: dev/vpc
terragrunt init
Terragrunt takes care of creating the appropiate resources for tracking infrastructure state remotely.
- Review the changes to be applied
- For the whole environment
cd <environment>/ # ex: dev/
terragrunt run-all plan
- For only one resource
cd <environment>/<resource> # ex: dev/vpc
terragrunt plan
- Apply your changes
- For the whole environment
cd <environment>/ # ex: dev/
terragrunt run-all apply
- For only one resource
cd <environment>/<resource> # ex: dev/vpc
terragrunt apply
The deploy region is configured on a per-environment basis, and loaded
in the root terragrunt.hcl
config on execution.
This region configuration is held in each environment directory's
env.hcl
file, and can be modified as follows:
// dev/env.hcl
// ...
locals {
aws_region = "us-east-1"
// ...
}
//...