Terrafom installation creating EC2

Terraform script (main.tf) to create the vpc in aws.

  1. terraform init
  2. terraform validate
  3. terraform plan -out sanjayShonak_vpc
  4. 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.

OptionDescription
listList resources in the state.
showShow a resource in the state.
mvMove an item in the state.
rmRemove instances from the state.
pullPull 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

Leave a Reply

Your email address will not be published. Required fields are marked *