Todo Infra is used to provision AWS resources. It's based on vanilla Terraform code.
- Clone this repo
- Install Terraform CLI
- Please add all
*.tfvars
files containing sensitive data to your local working environment. Contact the repository owner or the person responsible for this repository to obtain them
We must configure AWS profile through AWS CLI.
- Install latest version of AWS CLI
- Obtain access key, secret key, and session token from AWS portal
- Configure AWS profile for the current environment
[nonprod]
aws_access_key_id = <your-access-key-id>
aws_secret_access_key = <your-secret-access-key>
aws_session_token = <your-session-token>
[prod]
aws_access_key_id = <your-access-key-id>
aws_secret_access_key = <your-secret-access-key>
aws_session_token = <your-session-token>
- The temporary security credentials will be expired an hour so you need to refresh refresh it hourly
This template provides a handful of scripts to make your dev experience better!
- Navigate to the desired environment
cd nonprod
orcd prod
- Initialize Terraform (First-Time setup)
terraform init
- Run plan for the current directory with a specific profile name
AWS_PROFILE=nonprod terraform plan --var-file <your-file-name>.tfvars
- Run apply
AWS_PROFILE=nonprod terraform apply --var-file <your-file-name>.tfvars
- Format
*.tf
filesterraform fmt -recursive
- Force unlock terraform state. If Terraform halts due to STS (Security Token Service) credentials expiring during an apply operation, you can force-unlock the state using the following command
AWS_PROFILE=nonprod terraform force-unlock <lock-id>
- Always run
plan
before executingapply
to review changes and avoid unintended modifications - Store sensitive data carefully in
.tfvars
file for preventing commit those to the remote repository. Use.gitignore
to exclude these files from version control