0
votes

I'm using lambda to modify some csv files from s3 bucket and writing it to a different s3 bucket using AWS Javascript SDK. The buckets for getObject and putObject are in different regions. The lambda is in the same region as the destination buckets. But the modified files in the destination buckets have this error in them

AuthorizationHeaderMalformedThe authorization header is malformed; the region 'us-east-1' is wrong; expecting 'us-west-2'us-west-2.

Whenever the source and destination buckets are in same region, I get the proper modified files.

What changes do I need to make this work when source and destination bucket are in different regions.

Thanks

1

1 Answers

1
votes

S3 service is global, but bucket itself in regional, which means when you neet to use a bucket you need to do it using the same region where the bucket exists.

If I understood correct your source bucket is in us-west-2 and your destination bucket is in us-east-1.

So you need to use like this:

s3_source = boto3.client('s3', region_name='us-west-2')
... your logic to get and handle the file ...

s3_destination = boto3.client('s3', region_name='us-east-1')
... your logic to write the file ...