- Introduction
- Lifecycle of Terraform
- State management
- Compose resources based on existing state import
- Visualize the stack graph
- Keep code formatted
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.
sudo apt install python3-pip
sudo pip install --upgrade requests awscli
In this example, we are using AWS CLI
aws configure
terraform init
terraform plan
terraform apply
terraform destroy
To check resource state, use below command
terraform show
To get a list of resource state, use below command
terraform state list
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
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
Format code in *.tf
files using below command
terraform fmt