I am trying to upload a file to S3 w/ Expires metadata. This is from Windows using Powershell 7.
This command succeeds using the AWS CLI:
aws s3 cp myFile.xml "s3://my-bucket/myFile.xml" --content-type "text/xml" --region "us-east-1" --expires "2024-01-01" --cache-control "max-age=60"
And the Content-Type, Cache-Control and Expires headers are all set the way I expect them to be.
However, when I use AWS Tools for Powershell's Write-S3Object, it fails:
Write-S3Object -BucketName "my-bucket" -File myFile.xml -ContentType "text/xml" -Key "myFile.xml" -Region "us-east-1" -HeaderCollection @{"Cache-Control" = "max-age=60"; "Expires"="2024-01-01"}
The error is:
Write-S3Object: The request signature we calculated does not match the signature you provided. Check your key and signing method.
It's because of that Expires header. If I leave that off the Write-S3Object command, it works.
I've tried setting the Expires date in the future, the past, changing the format, etc. Nothing works.
If I add any other header other than Cache-Control to that header collection, I get the same error. If I leave off Cache-Control and just specify Expires, I get the same error.
Are these two commands as equivalent as I think they are?
BTW I found this post but it didn't seem helpful to my situation: Amazon S3 - How to fix 'The request signature we calculated does not match the signature' error?
AWS Tools for PowerShell does work when you specify an
HTTP-dateper RFC 7231 section 7.1.1.1 instead ofYYYY-MM-DD.This works for me with version 4.1.517:
https://github.com/aws/aws-sdk/issues/434 is tracking this inconsistency across the different AWS SDKs and console.