Terraform: Unsupported attribute / empty tuple when removing count

Created on 14 Jul 2020  ยท  3Comments  ยท  Source: hashicorp/terraform

Terraform Version

ฮป terraform version
Terraform v0.12.28
+ provider.archive v1.3.0
+ provider.aws v2.70.0

Terraform Configuration Files

resource "aws_dynamodb_table" "file_service_requests" {
  count       = 1
  name         = "file-service-requests-${terraform.workspace}"
  hash_key     = "Ref"
  billing_mode = "PAY_PER_REQUEST"

  attribute {
    name = "Ref"
    type = "S"
  }

  ttl {
    attribute_name = "Ttl"
    enabled        = true
  }
}

output "dynamodb_table_name" {
  value       = aws_dynamodb_table.file_service_requests[0].name
  description = "Name of the dynamodb for inbound requests"
}

After removing count:

resource "aws_dynamodb_table" "file_service_requests" {
  name         = "file-service-requests-${terraform.workspace}"
  hash_key     = "Ref"
  billing_mode = "PAY_PER_REQUEST"

  attribute {
    name = "Ref"
    type = "S"
  }

  ttl {
    attribute_name = "Ttl"
    enabled        = true
  }
}

output "dynamodb_table_name" {
  value       = aws_dynamodb_table.file_service_requests.name
  description = "Name of the dynamodb for inbound requests"
}

Expected Behavior

The plan should not show any changes and should not fail

Actual Behavior


Plan fails:

Error: Unsupported attribute

  on modules/file_service/outputs.tf line 7, in output "dynamodb_table_name":
   7:   value       = aws_dynamodb_table.file_service_requests.name
    |----------------
    | aws_dynamodb_table.file_service_requests is empty tuple

This value does not have any attributes.

Steps to Reproduce

  • [ ] terraform init
  • [ ] terraform apply
  • [ ] remove count
  • [ ] terraform plan

References

  • Seems related to #23676
bug config v0.12

All 3 comments

I've confirmed this is fixed in the latest 0.13 release.
Thanks for reporting it @TomTucka!

0.13 has been released: https://www.terraform.io/downloads.html

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pawelsawicz picture pawelsawicz  ยท  3Comments

rjinski picture rjinski  ยท  3Comments

zeninfinity picture zeninfinity  ยท  3Comments

cpoole picture cpoole  ยท  3Comments

ketzacoatl picture ketzacoatl  ยท  3Comments