事象
- オンプレのデータセンターにある Linux サーバから Direct Connect -> VPC -> VPC Endpoint -> S3 にアクセスしようとするとタイムアウトする。
$ aws s3 ls --profile s3_access --endpoint-url https://bucket.vpce-********.s3.ap-northeast-1.vpce.amazonaws.com s3://s3-data-prod-********-ap-northeast-1 --debug
...
File "/usr/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<botocore.awsrequest.AWSHTTPSConnection object at 0x7f9469a838b0>, 'Connection to sts.amazonaws.com timed out. (connect timeout=60)')
確認ポイント
- S3 の VPC エンドポイント(Interface型)が作成されているか。
- STS の VPC エンドポイント(Interface型)が作成されているか。
- AWS CLI で S3 の --endpoint-url で VPC エンドポイントを指定しているか。
切り分け方法
$ aws ... --debug
- S3 の VPCE エンドポイントにTCP接続を確立できているか
$ telnet https://bucket.vpce-********.s3.ap-northeast-1.vpce.amazonaws.com 443
- STS の VPCE エンドポイントにTCP接続を確立できているか
$ telnet https://vpce-********-********.sts.ap-northeast-1.vpce.amazonaws.com 443
$ aws sts get-caller-identity --endpoint-url https://vpce-********-********.sts.ap-northeast-1.vpce.amazonaws.com --debug
...
2024-08-01 16:03:40,713 - MainThread - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (3): vpce-********-********.sts.ap-northeast-1.vpce.amazonaws.com:443
...
Connect timeout on endpoint URL: "https://vpce-********-********.sts.ap-northeast-1.vpce.amazonaws.com/"