Help for the VSCode editor.
-
Which location is the terraform state file stored by default?
Inside the configuration directory.
This keeps it associated with the configuration.
-
Which option should we use to disable state?
We cannot disable state!
State is the thing which makes terraform possible. Without it we have nothing.
-
Which format is the state file stored in by default?
JSON
-
Which of the following commands does NOT refresh the state?
terraform init
plan
refreshes the state with the state of currently deployed resources, if you have previously applied the configuration.apply
updates the state with any changes made.
-
What is the name of the state file that is created by default?
terraform.tfstate
-
Navigate to the configuration directory /root/terraform-projects/project-flash we have created a few configuration files here.
The directory has been initialized and the provider plugins downloaded inside the .terraform directory. However, there is no terraform.tfstate file created. Why is that?
terraform apply
was not runUntil some resources have actually been deployed, there is no state.
-
Run the terraform show command and identify the id created for the resource called speed_force.
cd /root/terraform-projects/project-flash/ terraform show
No details printed. There is no state.
We haven't applied anything yet.
-
Now, run terraform apply in this directory.
terraform apply
-
Now, check terraform show again. What is the value of id for the resource called speed_force?
terraform show
Locate the
id
attribute of thespeed_force
resource -
Information only
-
Inspect the terraform.tfstate file or run terraform show command. You will notice that all the attribute details for all the resources created by this configuration is now printed on the screen!
Among them is an EC2 Instance which is created by the resource called dev-server. See if you can find out the private_ip for the instance that was created.cd /root/terraform-projects/project-flash/ terraform show
Locate the
private_ip
attribute of theaws_instance.dev-server
resource -
Information only