Search code examples
amazon-web-servicesamazon-s3terraformterraform-provider-awsaws-iot

Update/delete aws_s3_object results in "InvalidArgument: Invalid attribute name specified."


I have a project where I create AWS IoT certificates using Terraform and store them in an Amazon S3 bucket.

I store the certificates using aws_s3_object and the content attribute:

resource "aws_iot_certificate" "this" {
  count = length(aws_iot_thing.this)

  active = true
}

resource "aws_s3_object" "public_key" {
  count = length(var.things)

  bucket  = module.s3_bucket.s3_bucket_id
  key     = "certificate/${var.things[count.index].customer_id}/public_key.pem"
  content = aws_iot_certificate.this[count.index].public_key
}

The application works, but when I try to create or destroy the objects, Terraform always gives me this error:

Error: deleting S3 Bucket (xxxxxxx) Object (certificate/xxxx/public_key.pem): InvalidArgument: Invalid attribute name specified. status code: 400, request id: xxxxx, host id: xxxx

I tried to use a constant key like "test/public_key.pem", with the same result.


Solution

  • Like jarmod mentioned the problem was mentioned in the Terraform AWS provider issue 32307 and fixed in the provider version 5.6.2.