通过 Terraform 标记由 launch_template 和自动缩放组创建的 EBS 卷

Sou*_*uad 4 amazon-web-services terraform

我们如何制作 terraform 创建的 launch_template 资源,将标签添加到创建的 EBS 卷并将其附加到使用的 AMI ?

kic*_*hik 10

tag_specificationsresource_type一起使用volume

resource "aws_launch_template" "foo" {
  name = "foo"

  block_device_mappings {
    device_name = "/dev/sda1"

    ebs {
      volume_size = 20
    }
  }

  image_id = "ami-test"
  instance_type = "t2.micro"
  key_name = "test"

  tag_specifications {
    resource_type = "instance"

    tags = {
      Name = "test"
    }
  }

  tag_specifications {
    resource_type = "volume"

    tags = {
      Name = "test"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

  • 如果您有多个映射,如何标记特定映射? (2认同)