AWS CLI EC2 instance roleを使っているときに、assume role する方法
AWS CLI EC2 instance roleを使っているときに、assume role する方法
問題
AWS CLIは https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/cli-roles.html で簡単にassume role で引き受けたroleが使用できるが、元の権限が EC2 instance role を使っているとこのページの通りだと The source_profile "default" must specify either static credentials or an assume role configuration
と言われてしまい動作しない
./aws/config
[profile test]
role_arn = arn:aws:iam::xxxxxxxx:role/TestRole
source_profile = default
[default]
output = json
region = ap-northeast-1
-> % aws --profile test ec2 describe-instances
The source_profile "default" must specify either static credentials or an assume role configuration
解決方法
https://docs.aws.amazon.com/cli/latest/topic/config-vars.html#using-aws-iam-roles にある
credential_source = Ec2InstanceMetadata
を指定すれば、できるようになる
./aws/config
[profile test]
role_arn = arn:aws:iam::xxxxxxxx:role/TestRole
credential_source = Ec2InstanceMetadata
region = ap-northeast-1
[default]
output = json
region = ap-northeast-1
-> % aws --profile test ec2 describe-instances | head -8
{
"Reservations": [
{
"Instances": [
{
"Monitoring": {
"State": "disabled"
},
Author And Source
この問題について(AWS CLI EC2 instance roleを使っているときに、assume role する方法), 我々は、より多くの情報をここで見つけました https://qiita.com/watarin/items/d5641ccc69e83107dcb3著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .