How to use AWS SDK v3 (JavaScript) to copy between buckets in different regions?

0

I ran into this problem and unfortunately I cannot figure out what to do. It seems that the S3Client and only be configured for a specific region and the region key gets automatically attached.

So when using the CopyObjectCOmmand, I run into either a NoSuchBucket error, or, if not specifying the region key, I get the

PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint

error, because the bucket obviously is not found in the client region.

How can I solve this?

Here's the commands

const client = new S3Client({ region: "destination-region", credentials: {...} });

client.send(
  new CopyObjectCommand({
    Bucket: "<destination-bucket>",
    CopySource: "<source-bucket>/<source-key>",
    Key: "<destination-key>",
  })
);

// results in a PermanentRedirect error
// <source-bucket>.s3.<destination-region>.amazonaws.com endpoint not available because in different region
FloRag
質問済み 5ヶ月前123ビュー
回答なし

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ