简体   繁体   English

命令列出使用工作区创建的工作区和 aws 资源

[英]command to list workspaces and aws resources created using workspace

Hi I am new to terraform. I want to list resources of aws and correspoding workspace for that resource.您好,我是 terraform 的新手。我想列出 aws 资源和该资源的相应工作空间。 I know that terraform terraform workspace list will give each workspace.我知道 terraform terraform workspace list会给出每个工作空间。

When listing the states its not giving exact information of which resources were created by terraform workspace.在列出状态时,它没有给出 terraform 工作空间创建了哪些资源的确切信息。

terraform state list

any script or command we have to display just workspace and resource created byt that workspace?我们必须只显示工作区和该工作区创建的资源的任何脚本或命令吗? nothing else.没有其他的。

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.工作区在技术上等同于重命名您的 state 文件。 They aren't any more complex than that.它们并不比这更复杂。 Terraform wraps this simple notion with a set of protections and support for remote state. Terraform 用一组保护和支持远程 state 来包装这个简单的概念。

In other words, you might be misunderstanding how workspaces and state list works because换句话说,您可能会误解工作区和state list工作方式,因为

The terraform state list command can list the resources being managed by the current working directory and workspace, providing a complete or filtered list . terraform state list命令可以列出当前工作目录和工作空间所管理的资源,提供完整的或过滤后的列表

And the most important part is this最重要的部分是这个

The command will list all resources in the state file matching the given addresses (if any).该命令将列出 state 文件中与给定地址(如果有)匹配的所有资源。 If no addresses are given, all resources are listed.如果没有给出地址,则列出所有资源。

TLDR; TLDR;

There's no such extra command because utilizing workspaces and terraform state list should meet your requirements.没有这样的额外命令,因为使用workspacesterraform state list应该可以满足您的要求。

Selecting a given workspace and then terraform state show will give you all the resources for that workspace only.选择给定的工作区,然后terraform state show将为您提供该工作区的所有资源。

To list the Terraform workspaces, you can use the terraform workspace list command:要列出 Terraform 工作区,可以使用 terraform 工作区列表命令:

terraform workspace list

This command will list all the workspaces in your Terraform configuration.此命令将列出 Terraform 配置中的所有工作区。

To list the AWS resources created using a specific Terraform workspace, you can use the terraform state list command:要列出使用特定 Terraform 工作区创建的 AWS 资源,您可以使用 terraform state list 命令:

terraform state list -state=<workspace_name>.tfstate

Replace <workspace_name> with the name of the Terraform workspace you want to inspect.将 <workspace_name> 替换为您要检查的 Terraform 工作空间的名称。 This command will list all the resources that have been created in that workspace.此命令将列出已在该工作区中创建的所有资源。

Note that the terraform state list command requires the .tfstate file of the workspace you want to inspect.请注意, terraform state list命令需要您要检查的工作区的.tfstate文件。 If the workspace was created with a remote backend, you may need to configure the backend first before running this command.如果工作区是使用远程后端创建的,您可能需要在运行此命令之前先配置后端。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以使用 Google Workspace(以前称为 G Suite)作为使用 SAML 2.0 的 AWS WorkSpaces 的身份提供商? - Is it possible to use Google Workspace (formerly G Suite) as Identity Provider for AWS WorkSpaces using SAML 2.0? terraform 获取已创建资源列表 - Get a list of created resources in terraform 删除 AWS 云形成堆栈及其创建的资源 - Delete AWS Cloud formation stack with resources created by it 即使资源存在 AWS,发现的资源也会返回空白列表 - Discovered resources returning a blank list even when resources exist AWS 使用 Terraform 模块导入现有 AWS 资源 - Importing existing AWS Resources using Terraform Module 如何使用 aws cdk 列出所有已部署的 aws 资源 - How to list all deployed aws resources with aws cdk AWS IAM,限制一个账户只能查看和访问它自己创建的资源? - AWS IAM, restricting an account to see and access only resources created by itself? 没有等待创建 AWS RDS 代理的命令 - No command to wait for AWS RDS Proxy to get created 我们可以限制 AWS Workspaces 上的网站访问吗? - Can we restrict websites access on AWS Workspaces? 有没有办法列出特定运营商创建的所有资源及其状态? - Is there a way to list all resources created by a specific operator and their status?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM