VPC内でAWS Wranglerを利用したところSTSエンドポイントに繋がらないエラーが発生したので、その対応を書いておきます。
事象
VPC上のPythonプログラムにて AWS Wrangler
(現 aws-sdk-pandas
)を利用しところ、以下のようなエラーが発生。
botocore.exceptions.ConnectionClosedError: Connection was closed before we received a valid response from endpoint URL: "https://sts.amazonaws.com/".
[ERROR] Exception: Connection was closed before we received a valid response from endpoint URL: "https://sts.amazonaws.com/".
対応方法
以下の2点対応することで解決できました。
- 対応➀ VPCエンドポイント作成します
- 対応➁ STS Endpointを向くようにAWS Wranglerを設定します
対応➁について
以下の2パターンの対応方法があります。
- 環境変数
WR_STS_ENDPOINT_URL=https://sts.ap-northeast-1.amazonaws.com
- Python内に記述
wr.config.sts_endpoint_url = "https://sts.ap-northeast-1.amazonaws.com"
参考