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

Block type tags issue - Error: Unsupported block type #21742

Closed
berry2012 opened this issue Jun 16, 2019 · 3 comments
Closed

Block type tags issue - Error: Unsupported block type #21742

berry2012 opened this issue Jun 16, 2019 · 3 comments

Comments

@berry2012
Copy link

berry2012 commented Jun 16, 2019

Blocks of type "tags" are not expected here. Did you mean to define argument
"tags"? If so, use the equals sign to assign it a value.

resource "aws_s3_bucket" "code" {
  bucket        = "${var.domain_name}-${random_id.wp_code_bucket.dec}"
  acl           = "private"
  force_destroy = true

  tags {
    Name = "code bucket"
  }
}
terraform --version
Terraform v0.12.2
+ provider.aws v2.15.0
+ provider.random v2.1.2
@apparentlymart
Copy link
Contributor

Hi @berry2012,

tags is an argument of aws_s3_bucket, rather than a nested object related to it, so you should use = to represent the fact that you are assigning a map value to that argument, rather than creating a nested object of type tags:

  tags = {
    Name = "code bucket"
  }

While the syntax difference between these two is subtle, the meaning is quite different: tags can accept any expression as long as its result is a map, and in this case we just happen to be using a literal map expression that uses the same delimiters as a nested block uses. The distinction is more apparent when tags is assigned from a more dynamic expression:

  tags = merge(local.default_tags, local.s3_tags, {
    Name = "code bucket"
  })

If you saw this error after upgrading an existing configuration from Terraform 0.11, I'd suggest reviewing the upgrade guide, which includes a tool to automatically fix this and several other quirks caused by the incomplete validation in Terraform 0.11's language implementation.

If you're writing this configuration in Terraform 0.12 for the first time and saw this incorrect tags declaration in some documentation, it'd be a great help if you could file an issue (probably in the AWS provider repository, if this was in the AWS provider documentation) so that we can get that documentation fixed to show the correct usage.

myechuri added a commit to elotl/kubeadm-aws-old that referenced this issue Jun 24, 2019
@hashibot
Copy link
Contributor

Hello! 🤖

We use GitHub issues for tracking bugs and enhancements rather than for questions. While we can sometimes help with certain simple problems here, it's better to use the community forum where there are more people ready to help. The GitHub issues here are monitored only by our few core maintainers.

Since this issue doesn't represent a specific bug or feature request, I'm going to close it. Please do feel free to ask your question in the community forum. Thanks!

@ghost
Copy link

ghost commented Sep 12, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants