terraform state list output?You run terraform state list in your Terraform project directory. What will this command show you?
Think about what Terraform tracks after applying changes.
The terraform state list command shows all resources that Terraform currently tracks in its state file. It does not show resources just defined in configuration or modules.
terraform state list?Given a Terraform project with resources defined but not yet applied, which resource will NOT be listed by terraform state list?
Think about what Terraform state tracks versus what is just defined.
Terraform state only tracks resources that have been applied or imported. Resources only defined but not applied are not in the state and so not listed.
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?
Remember the format Terraform uses to identify resources in state list.
The terraform state list command outputs resource addresses in the format resource_type.resource_name. Both resources appear since both were applied.
terraform state list?Consider you share your Terraform state file with others. Which risk is related to the output of terraform state list?
Think about what information the list command reveals.
The terraform state list command reveals resource names and types, which can expose infrastructure structure. It does not show sensitive attribute values or allow modifications.
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?
Terraform state list accepts a resource address prefix to filter the output.
The terraform state list module.network command filters and lists only resources managed by the network module using the native address prefix filtering.