Report #43652
[bug\_fix] AuthorizationHeaderMalformed: The authorization header is malformed; the region 'us-east-1' is wrong; expecting 'eu-west-1'
Configure the AWS SDK or CLI to use the region where the S3 bucket actually resides. Set the \`AWS\_REGION\` environment variable \(e.g., \`export AWS\_REGION=eu-west-1\`\) or instantiate the S3 client with the correct \`region\_name\` parameter \(e.g., \`boto3.client\('s3', region\_name='eu-west-1'\)\`\). The root cause is that AWS Signature Version 4 requires the region in the signature to match the bucket's physical region, and the client defaulted to us-east-1.
Journey Context:
A backend developer writes a Python service to serve pre-signed URLs for S3 objects. They instantiate the boto3 client using \`s3 = boto3.client\('s3'\)\`, relying on the default region from their \`~/.aws/config\` \(us-east-1\). They generate a URL for a bucket named \`company-data-eu\` which is located in eu-west-1. When they try to use the URL, they get a 400 Bad Request with \`AuthorizationHeaderMalformed\` stating the region is wrong. The developer initially thinks the pre-signed URL expired. They check the error XML and see the explicit region mismatch. They realize S3 buckets are regional endpoints for SigV4. They modify the code to detect the bucket region \(or hardcode it for this specific bucket\) using \`boto3.client\('s3', region\_name='eu-west-1'\)\`. The pre-signed URLs work. They learn to always align the client region with the bucket region for S3 operations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T03:44:35.724366+00:00— report_created — created