【问题标题】:Create an AWS Resource Group with Terraform使用 Terraform 创建 AWS 资源组
【发布时间】:2019-05-19 01:47:56
【问题描述】:

我目前正在进入 Terraform,我正在尝试使用标签和资源组来构建我正在部署的不同资源。

https://docs.aws.amazon.com/cli/latest/reference/resource-groups/index.html

我可以使用 Terraform 轻松添加标签,并且可以通过 aws cli 创建资源组,但如果可能的话,我真的希望能够同时使用 Terraform。

官方 Terraform 文档目前似乎不支持 aws_resource_group 资源(我能够找到 aws_inspector_resource_group 和 aws_iam_resource_group,它们是不同类型的分组资源)但我想知道是否有人能够通过某种解决方法来实现它.

我非常感谢您对此事的任何反馈。

提前致谢!

【问题讨论】:

标签: amazon-web-services terraform terraform-provider-aws aws-resource-group


【解决方案1】:

【讨论】:

    【解决方案2】:

    对于任何寻找代码示例的人,试试这个:

    resource "aws_resourcegroups_group" "code-resource" {
    name = "code-resource"
    
      resource_query {
        query = <<JSON
    {
      "ResourceTypeFilters": [
        "AWS::EC2::Instance"
      ],
      "TagFilters": [
        {
          "Key": "Stage",
          "Values": ["dev"]
        }
      ]
    }
    JSON
      }
    }
    

    请根据您的喜好和需要对其进行更新。还请务必查看源文档: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/resourcegroups_group

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-18
      • 2022-01-03
      • 2019-12-24
      • 2021-01-21
      • 2020-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多