Terraform script (main.tf) to create the vpc in aws.
- terraform init
- terraform validate
- terraform plan -out sanjayShonak_vpc
- terraform apply “sanjayShonak_VPC”
terraform plan -out sanjayShonak_vpc
… output trimmed…
Note: it’s best practice to provide output file. In that case you can use the command provided at the end.
terraform apply “sanjayShonak_VPC”
… output trimmed. As you can see it has added 16 resources.
terraform state
This does advanced state management. The state is stored by default in a local file named “terraform.tfstate”, but it can also be stored remotely, which works better in a team environment.
Option | Description |
list | List resources in the state. |
show | Show a resource in the state. |
mv | Move an item in the state. |
rm | Remove instances from the state. |
pull | Pull current state and output to stdout. |
terraform state list
terraform state show aws_route_table_association.rta1
terraform state show aws_lb.myalb
… output trimmed.
terraform graph
Produces a representation of the dependency graph between different objects in the current configuration and state. The graph is presented in the DOT language. The typical program that can read this format is GraphViz, but many web services are also available to read this format.
terraform graph
terraform destroy