-
Install Terraform: Make sure you have Terraform installed on your local machine. You can download Terraform from the official website: https://www.terraform.io/downloads.html
-
AWS Account: You will need an AWS account to create resources using Terraform. If you don't have an account, you can sign up for a free tier account at https://aws.amazon.com/free/
-
AWS CLI: Install and configure the AWS CLI on your local machine. The AWS CLI will be used to create the IAM user for Terraform. You can download it from https://aws.amazon.com/cli/ and review instructions to work with environment variables
-
Open the AWS Management Console and navigate to the IAM (Identity and Access Management) service.
-
Create a new user with programmatic access. Give the user a descriptive name, such as
tf-deploy
. -
Choose "Attach existing policies directly" and search for the "AdministratorAccess" policy. For production environments, consider granting more restrictive policies based on your requirements.
-
Once the user is created, note down the "Access Key ID" and "Secret Access Key". These credentials to configure the AWS CLI but ensure to store this in a secured vault with proper access for future uses.
-
Configure AWS CLI on your local machine using the credentials obtained in the previous step. We will be leveraging environment variables.
export AWS_ACCESS_KEY_ID=<AWS_ACCESS_KEY_ID>
export AWS_SECRET_ACCESS_KEY=<AWS_SECRET_ACCESS_KEY>
export AWS_DEFAULT_REGION=<AWS_DEFAULT_REGION>
To setup the backend run the init.sh
script in the repo, this will leverage the backend
folder terraform script to create a bucket and setup backend.tf
file for consumption in the actual IaC folder. The init
flag also does the terraform init
and plan
for the actual infrastructure.
./init.sh init
terraform apply -auto-approve=true
This should output the required URL To visit to see the validate the REST API is functional