Skip to content

Latest commit

 

History

History
112 lines (76 loc) · 2.82 KB

README.md

File metadata and controls

112 lines (76 loc) · 2.82 KB

Introduction

This is a demo set of Terraform manifest files to create stack of EKS, EFS, ELB on AWS cloud provider to deploy a simple application for testing purpose.

Noted: In this reference, still few configs are hardcoded resource ID. Looking forward to more contributions to manage all resources needed independently for apply/destroy seamlessly.

Lifecycle of Terraform

sudo apt install python3-pip
sudo pip install --upgrade requests awscli

Perform login to cloud provider using CLI

In this example, we are using AWS CLI

aws configure

Terraform init to download required plugins

terraform init

Terraform plan to see what will be created

terraform plan

Terraform apply to create the stack

terraform apply

Once tasks done, Terraform destroy to delete the stack

terraform destroy

State management

To check resource state, use below command

terraform show

To get a list of resource state, use below command

terraform state list

Compose resources based on existing state import

To import existing resources to Terraform state, use below command

terraform import aws_eks_cluster.my-cluster eks-cluster

Read the Terraform docs for more information on resources supported for each cloud provider.

Get the state of the imported resource, and update the *.tf file accordingly.

Terraform validate to check the syntax of the *.tf files and remove redundant configs if any.

terraform validate

Visualize the stack graph

If any changes in stack, update the .graph.png using below command after running terraform plan

terraform graph -type=plan | dot -Tpng >.graph.png

Install graphviz package if not already installed

sudo apt install graphviz

Keep code formatted

Format code in *.tf files using below command

terraform fmt