Site icon Mr. 沙先生

Location exception when using Amazon S3 Presigned-URL

這篇是客戶茶包系列,被問到使用 Amazon S3 Presigned-URL 時在特定的 AWS region (me-central-1) 無法正常下載,出現 exception:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

<Error>
<script>window._wordtune_extension_installed = true;</script>
<Code>IllegalLocationConstraintException</Code>
<Message>The me-central-1 location constraint is incompatible for the region specific endpoint this request was sent to.</Message>
<RequestId>4M2W...4ZG</RequestId>
<HostId>ePW...zYH2PKGzBuM=</HostId>
</Error>

而客戶告知都是使用同樣的參數去 sign Object,這種問題很常見的答案藏在 AWS 文件裡,回頭查了一下 Sharing objects with presigned URLs 果然翻開 AWS CLI/AWS SDKs 的內容有提到:

在 March 20, 2019 之後啟動的 AWS Region 都必須加上 endpoint-urlAWS Region 參數才能使用,而客戶使用的 UAE (me-central-1) region 是在 August, 29 2022 上線的。

請客戶加上兩個參數後果然就能動了。

Exit mobile version