Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tag EBS volume created by a launch_template and autoscaling group via Terraform

How do we make the launch_template resource created by terraform, add tags to the EBS volume created and which is attached to the used AMI ?

like image 601
Souad Avatar asked Oct 19 '25 04:10

Souad


1 Answers

Use tag_specifications with resource_type of 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"
    }
  }
}
like image 122
kichik Avatar answered Oct 21 '25 03:10

kichik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!