-
Notifications
You must be signed in to change notification settings - Fork 2
Terraform
Home > Deployments And Infrastructure > Terraform
This project uses terraform (iac) to manage infra and resources. The backend is configured to store the terraform state file in AWS S3 and the file hash is stored in a dynamo DB table in order track and lock the state. This is configured for each environment, and credentials must be obtained for each env in order to apply changes. Credentials can be found here. The terraform commands are listed below. Please see the Makefile and the terraform directory in the repo for more information.
# ========================================
# Terraform Cloud backend config variables
# ========================================
define TF_BACKEND_CFG
bucket = "terraform-remote-state-$(LZ2_PROJECT)-$(ENV_NAME)"
key = ".terraform/terraform.tfstate"
region = "ca-central-1"
dynamodb_table = "terraform-remote-state-lock-$(LZ2_PROJECT)"
encrypt = true
endef
export TF_BACKEND_CFG
After you have obtained the environment specific credentials, copy/paste these into the terminal from the root directory of the project. Additionally you will need to run export ENV_NAME=<prod/test/dev/tools>
prior to running the terraform commands. Run the Makefile commands from the root of the project (cd terraform
is included in these commands).
# ======================================================================
# Terraform commands
# ======================================================================
format:
@terraform -chdir=$(TERRAFORM_DIR) fmt
config:format
@echo "$$TFVARS_DATA" > $(TERRAFORM_DIR)/.auto.tfvars
@echo "$$TF_BACKEND_CFG" > $(TERRAFORM_DIR)/backend.hcl
init: config
@terraform -chdir=$(TERRAFORM_DIR) init -input=false \
-reconfigure \
-backend-config=backend.hcl -upgrade
plan: init
@terraform -chdir=$(TERRAFORM_DIR) plan -no-color
apply: init
@terraform -chdir=$(TERRAFORM_DIR) apply -auto-approve -input=false
destroy: init
@terraform -chdir=$(TERRAFORM_DIR) destroy
output:
@terraform -chdir=$(TERRAFORM_DIR) output
Discrepancy Report On Payments