Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to propagate default_tags through asg/launch_template to instances/volumes #19387

Open
tschaffer-smart opened this issue May 14, 2021 · 3 comments
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@tschaffer-smart
Copy link

I am unable to get default_tags to propagate into my ASG's instances and volumes.

An ASG can propagate, but it requires explicitly setting the tag and adding "propagate_at_launch = true". The alternative is defining it in the tag_specifications in the launch_template, but that one is not inheriting the values. I have tried the default of not defining tags_specifications blocks, and also defined a "simple" form, where I set only one dummy tag to see if it would still pull the default tags.

I would accept if all that was necessary was to define the stanza to force it through, but ideally this shouldn't be necessary - since we defined at the provider level that we want everything tagged.

example for minimal spec for launch_template.tf

tag_specifications {
resource_type = "instance"
}

@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label May 14, 2021
@anGie44 anGie44 added service/ec2 Issues and PRs that pertain to the ec2 service. enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels May 20, 2021
@anGie44
Copy link
Contributor

anGie44 commented May 20, 2021

Hi @tschaffer-smart , thank you for raising this issue. For resources that support tags, default_tags are only propagated with the root-level tags configuration in mind. Since the tags in reference are nested within the tag_specifications block, support is not yet available; nevertheless, we'll take note of this use case as it relates to #19188

@ivankatliarchuk
Copy link

tags_specifications block does not inherit default_tags. Any plans to support this use case?

@villapx-path
Copy link

This doesn't solve the "missing" feature, but you can achieve the desired behavior by replacing the provider.aws.default_tags block with a (local) variable:

locals {
  default_tags = {
    SomeDefaultTag = "some value"
  }
}

provider "aws" {
  default_tags {
    tags = local.default_tags
  }
}

resource "aws_launch_template" "my_launch_template" {
  name = "mine"
  tag_specifications {
    resource_type = "instance"
    tags = merge(
      {
        LaunchTemplateSpecificTag = "Some tag to be applied to every instance"
      },
      local.default_tags
    )
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

4 participants