Unsupported argument: aws_s3_bucket_object.source_hash

The documentation describes source_hash as an alternative to etag when storing aws_s3_bucket_object. [aws_s3_bucket_object | Resources | hashicorp/aws | Terraform Registry]

The issue is etag is unreliable in a number of circumstances and using etag to prevent unnecessary updates will not work.

source_hash is the documented alternative, but I cannot get the syntax correct:

resource "aws_s3_bucket_object" "NessusAgent_0_1_x64_manifest" {
  bucket = aws_s3_bucket.SSMContent.id
  key    = "NessusAgent-10.0.1-x64/manifest.json"
  source = "../Infrastructure/NessusAgent-10.0.1-x64/manifest.json"
  server_side_encryption = "aws:kms"
  source_hash = filemd5("../Infrastructure/NessusAgent-10.0.1-x64/manifest.json")
}

Results:

│ Error: Unsupported argument
│
│   on ..\Infrastructure\aws_s3_bucket.SSMContent.tf line 32, in resource "aws_s3_bucket_object" "NessusAgent_0_1_x64_manifest":
│   32:   source_hash = filemd5("../Infrastructure/NessusAgent-10.0.1-x64/manifest.json")
│
│ An argument named "source_hash" is not expected here.

Is my syntax wrong. My configuration:

Terraform v1.1.4
on windows_386
+ provider registry.terraform.io/hashicorp/aws v3.37.0

(https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object#source_hash)

Hi @jlongo62,

You linked to the documentation for version 3.72.0 of the aws provider, but are only using version 3.37.0. I suspect that the source_hash attribute was added in a later release, and you will need to upgrade the provider.

Hey @jlongo62 :wave: I took a look and it appears @jbardin was spot on – the source_hash attribute was added in 3.50.0.