Reputation: 29237
Hi I am new to terraform.
I want to list resources of aws and correspoding workspace for that resource.
I know that terraform terraform workspace list
will give each workspace.
When listing the states its not giving exact information of which resources were created by terraform workspace.
terraform state list
any script or command we have to display just workspace and resource created byt that workspace? nothing else.
Upvotes: 0
Views: 1555
Reputation: 20052
From the docs:
Workspaces allow you to use the same working copy of your configuration and the same plugin and module caches, while still keeping separate states for each collection of resources you manage.
And then
Workspaces are technically equivalent to renaming your state file. They aren't any more complex than that. Terraform wraps this simple notion with a set of protections and support for remote state.
In other words, you might be misunderstanding how workspaces and state list
works because
The
terraform state list
command can list the resources being managed by the current working directory and workspace, providing a complete or filtered list.
And the most important part is this
The command will list all resources in the state file matching the given addresses (if any). If no addresses are given, all resources are listed.
TLDR;
There's no such extra command because utilizing workspaces
and terraform state list
should meet your requirements.
Selecting a given workspace and then terraform state show
will give you all the resources for that workspace only.
Upvotes: 1