0
0
Terraformcloud~20 mins

Terraform state list command - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform State List Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
1:30remaining
What does the command terraform state list output?

You run terraform state list in your Terraform project directory. What will this command show you?

AA list of all resources currently tracked in the Terraform state file.
BA list of all resources defined in the Terraform configuration files, regardless of state.
CA detailed JSON output of the current Terraform state file contents.
DA list of all Terraform modules used in the configuration.
Attempts:
2 left
💡 Hint

Think about what Terraform tracks after applying changes.

🧠 Conceptual
intermediate
1:30remaining
Which resource will NOT appear in the output of terraform state list?

Given a Terraform project with resources defined but not yet applied, which resource will NOT be listed by terraform state list?

AA resource imported into the state file.
BA resource applied and tracked in the state file.
CA resource defined in the configuration but never applied.
DA resource created by a module and applied.
Attempts:
2 left
💡 Hint

Think about what Terraform state tracks versus what is just defined.

Configuration
advanced
2:00remaining
What is the output of terraform state list after applying this configuration?

Given this Terraform configuration:

resource "aws_s3_bucket" "bucket1" {
  bucket = "my-bucket-1"
}

resource "aws_s3_bucket" "bucket2" {
  bucket = "my-bucket-2"
}

You run terraform apply successfully, then run terraform state list. What is the output?

A
my-bucket-1
my-bucket-2
B
bucket1
bucket2
Caws_s3_bucket.bucket1
D
aws_s3_bucket.bucket1
aws_s3_bucket.bucket2
Attempts:
2 left
💡 Hint

Remember the format Terraform uses to identify resources in state list.

security
advanced
1:30remaining
Which of these is a security risk when using terraform state list?

Consider you share your Terraform state file with others. Which risk is related to the output of terraform state list?

AIt reveals the exact resource names and types currently managed, which may expose infrastructure details.
BIt exposes sensitive resource attribute values like passwords or keys.
CIt allows unauthorized modification of the state file.
DIt automatically deletes resources not listed in the state.
Attempts:
2 left
💡 Hint

Think about what information the list command reveals.

Architecture
expert
2:00remaining
How can you use terraform state list to identify resources managed by a specific module?

You have a Terraform state with multiple modules. You want to list only resources managed by the module named network. Which command will achieve this?

Aterraform state list --filter=module.network
Bterraform state list module.network
Cterraform state list | grep module.network
Dterraform state list -module=network
Attempts:
2 left
💡 Hint

Terraform state list accepts a resource address prefix to filter the output.