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

aws_launch_template tag_specifications cannot contain empty or null tags #13155

Open
steved opened this issue May 4, 2020 · 2 comments
Open
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@steved
Copy link

steved commented May 4, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.12.24
+ provider.aws v2.60.0

Affected Resource(s)

  • aws_launch_template

Terraform Configuration Files

Minimal reproduction:

resource "aws_launch_template" "test" {
  name = "test_1"

  tag_specifications {
    resource_type = "instance"
  }
}

Possibly also a related reproduction?

resource "aws_launch_template" "test" {
  name = "test_1"

  tag_specifications {
    resource_type = "instance"
    tags = {}
  }
}

Debug Output

https://gist.github.com/steved/092c6ff4ecbae5126cb3ddcf169f039c

Expected Behavior

Ideally, I think this should this fail validation? At the very least making the Tags schema required would fix the first case. I don't see a way of requiring a non-empty map, however.

Actual Behavior

InvalidRequest error without a very descriptive pointer to the incorrect statement:

aws_launch_template.test: Creating...

Error: InvalidRequest: The request received was invalid.
	status code: 400, request id: 33f7abec-980c-41a9-8503-ee960cbc65cc

  on main.tf line 9, in resource "aws_launch_template" "test":
   9: resource "aws_launch_template" "test" {

Steps to Reproduce

  1. terraform apply either of the config files above.

Important Factoids

Was able to workaround this using a foreach:

locals {
  tags = {}
}

resource "aws_launch_template" "test" {
  name = "test_1"

  dynamic "tag_specifications" {
    for_each = local.tags
    content {
      resource_type = "instance"
      tags          = { (tag_specifications.key) = tag_specifications.value }
    }
  }
}

References

N/A

@ghost ghost added the service/ec2 Issues and PRs that pertain to the ec2 service. label May 4, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label May 4, 2020
@ewbankkit
Copy link
Contributor

@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 27, 2021
@ewbankkit ewbankkit added this to the v5.0.0 milestone May 11, 2023
@johnsonaj
Copy link
Contributor

tag_specifications is an attribute specific to aws_launch_template and is not impacted by the work done to default_tags and the tags attributes

@johnsonaj johnsonaj removed this from the v5.0.0 milestone May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

4 participants