Terraform workshop ECS AWS Infrastructure (01/2023)

This repository holds all information and scripts for provisioning Terraform workshop ECS infrastructure on Amazon Web Services.

Requirements

This guide is intended to be used by both system administrators and developers.

Prerequisites

To run locally you need to have AWS CLI and Terraform installed, please check the perrequisites section for more information.

Environment variables

For runs that happen on Terraform Cloud, environment variables are currently set up.

In case you need to run plan/apply locally, you need to set the following environment variables:

Name Description
aws_access_key AWS Access Key ID
aws_access_secret AWS Access Key Secret
aws_region AWS Region used for creating resources

You can also create a .env file from the template and populate it with information:

cp terraform.tfvars.template environments/shared/terraform.tfvars
cp terraform.tfvars.template environments/development/terraform.tfvars
cp terraform.tfvars.template environments/production/terraform.tfvars

Versions

Currently used Terraform version for the project is Terraform v1.3.5

Outputs

Terraform Outputs are a way to export values that are generated by Terraform.

List of outputs:

Name Description

Getting the value of an output

Exporting all outputs to a json file can be done with the following command:

terraform output -json > terraform.json

Getting a single output

You can get a single output with the following command:

terraform output aws_cognito_user_pool_id

This mechanism always retrieves the current value of the output. In case of value rotation it will track the latest value after state synchronization.

Initializing Terraform configuration for local development

Terraform configuration should be initialized with the following command per environment folder:

terraform init