🏁
小ネタ/AWS のオプトインしていないオプトインリージョンに対する操作は認証エラーになる
tl;dr
- 複数のアカウントで平行してリソースを棚卸するときなどで、認証エラーになったときは、ロールの問題とあわせて別にリージョンの利用状況が同じかもチェックしよう
[cloudshell-user@ip-0-0-0-0 ~]$ aws ec2 describe-regions --all-regions --query="Regions[?RegionName=='ap-east-1'].OptInStatus" --output text
not-opted-in
[cloudshell-user@ip-0-0-0-0 ~]$ aws ec2 describe-instances --region ap-east-1
An error occurred (AuthFailure) when calling the DescribeInstances operation: AWS was not able to validate the provided access credentials
メモ
- 存在しない region の場合はエンドポイントに到達できない
[cloudshell-user@ip-0-0-0-0 ~]$ aws ec2 describe-instances --region ap-east-2
Could not connect to the endpoint URL: "https://ec2.ap-east-2.amazonaws.com/"
- boto3 での見えかた
[ERROR] ClientError: An error occurred (AuthFailure) when calling the DescribeInstances operation: AWS was not able to validate the provided access credentials
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 36, in lambda_handler
res = ec2.describe_instances(MaxResults=1000)
File "/var/runtime/botocore/client.py", line 391, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/var/runtime/botocore/client.py", line 719, in _make_api_call
raise error_class(parsed_response, operation_name)
Discussion