Skip to content

Latest commit

 

History

History
35 lines (18 loc) · 1.05 KB

aws_terraform_apply.md

File metadata and controls

35 lines (18 loc) · 1.05 KB

AWS terraform apply from local machine

Change directory

cd /github-actions-aws-terraform/

Set terraform variables through environment variables

export ENV_NAME='development'

export TF_VAR_database_name='development_db'

export TF_VAR_database_username='development_db_user'

export TF_VAR_database_password='development_db_password'

Initialise terraform

terraform -chdir=environments/$ENV_NAME init -reconfigure -input=false

Validate configuration

terraform -chdir=environments/$ENV_NAME validate

Preview the resourced to be created/updated/destroyed

terraform -chdir=environments/$ENV_NAME plan -input=false -var-file="../../variables/$ENV_NAME.tfvars"

Apply terraform changes in AWS

terraform -chdir=environments/$ENV_NAME apply -auto-approve -input=false -var database_password=$TF_VAR_database_password -var-file="../../variables/$ENV_NAME.tfvars"

Force unlock the terraform state (use only if the process was terminated or killed)

terraform -chdir=environments/$ENV_NAME force-unlock {ID}