case0sh / terr-aws-ec2-cicd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AWS and Terraform workshop

Prerequisite

  1. Linux workstation.
  2. wget package installed on your workstation.
  3. Install Terraform

How to run Terraform project?

  1. Navigate to terraform project directory.

  2. Make some changes in terraform.tfvars

  3. Fill the code where mentioned Update:

  4. Initialize terraform project.

terraform init
export PROJECT_ID="<Project ID>"
export TF_USERNAME="<GitLab Username>"
export TF_PASSWORD="<Access Token>"
export TF_ADDRESS="https://gitlab.com/api/v4/projects/${PROJECT_ID}/terraform/state/tf_state"

terraform init \
  -backend-config=address=${TF_ADDRESS} \
  -backend-config=lock_address=${TF_ADDRESS}/lock \
  -backend-config=unlock_address=${TF_ADDRESS}/lock \
  -backend-config=username=${TF_USERNAME} \
  -backend-config=password=${TF_PASSWORD} \
  -backend-config=lock_method=POST \
  -backend-config=unlock_method=DELETE \
  -backend-config=retry_wait_min=5
  1. Generate terraform execution plan.
terraform plan
  1. Run terraform apply, if plan looks good.
terraform apply
  1. For check your droplets.
terraform show
  1. For clean-up, destroy all the resources created by terraform.
terraform destroy

About


Languages

Language:HCL 85.8%Language:Shell 14.2%