IAM Identity Centerの有効化 (管理者)
InstanceのQuotaが1のため、有効化するRegionを間違えると複数はEnableできないのでRegionを間違えないようにする
最初は個人のアカウントで検証用に作成したが、Permission setの作り方が見つからなかったのでAWS Orgで作成。
Orgを初めて作ると、以下のようなメールが来るのでVerifyしておく。
User作成 (管理者)
アクセス権限の付与 (管理者)
PermissionSetを作成
PermissionSetはAccountとは関係なくどんなことができるかを定義するIAM Roleのようなもの。
次のセクションで実際にどのUserやGroupに、どのAWS Accountに対して、どのPermissionSetを付与するかを設定する
https://docs.aws.amazon.com/singlesignon/latest/userguide/howtocreatepermissionset.html に基づきPermissionSetを作成する
練習としてPredefinedのPowerUserAccess
でSessionの長さを12hとして作成。
PermissionSetのAssign
AWS Account、User/Group、PermissionSetの組み合わせで、どのAWS Accountのどの権限(PermissionSet)を誰(User/Group)に付与するかを決める
https://docs.aws.amazon.com/singlesignon/latest/userguide/useraccess.html に基づいて設定する
AWS accountsを開いてUserまたはGroupに上のステップで作成した権限を付与する
今回は、簡単のため nakaにPowerUserAccessを付与した
各Userの設定 (利用ユーザ)
受け取った案内に従ってPasswordを設定
上のUser作成でユーザを作成するときに、Emailを入れてメールで初期設定の案内が届くようになっている
以下のようなメールが届くので、Your AWS access portal URL
を控えておく。
このYour AWS access portal URL
はあとでcliの設定時にも使う
パスワードを設定
MFAの設定などをして設定完了。
awscli設定
configを設定する
- SSO start URLには、メールで受信した
Your AWS access portal URL
を使う
aws configure sso
SSO session name (Recommended): naka
SSO start URL [None]: https://xxxx.awsapps.com/start
SSO region [None]: ap-northeast-1
SSO registration scopes [sso:account:access]:
Attempting to automatically open the SSO authorization page in your default browser.
If the browser does not open or you wish to use a different device to authorize this request, open the following URL:
https://device.sso.ap-northeast-1.amazonaws.com/
Then enter the code:
KBHG-XQCT
The only AWS account available to you is: xxxxxxxxxxx
Using the account ID xxxxxxxxxxx
The only role available to you is: PowerUserAccess
Using the role name "PowerUserAccess"
CLI default client Region [ap-northeast-1]:
CLI default output format [json]:
CLI profile name [PowerUserAccess-xxxxxxxxxxx]: naka
To use this profile, specify the profile name using --profile, as shown:
aws s3 ls --profile naka
上のコマンドの中で以下のように聞かれるので、Allow accessする
無事成功
-
~/.aws/sso/cache/
いかにssoのJSONファイルが生成される -
~/.aws/config
が以下のようにできる
[default]
region = ap-northeast-1
output = json
[profile naka]
sso_session = naka
sso_account_id = xxxxxxxx
sso_role_name = PowerUserAccess
region = ap-northeast-1
output = json
[sso-session naka]
sso_start_url = https://xxxxxx.awsapps.com/start
sso_region = ap-northeast-1
sso_registration_scopes = sso:account:access
aws command を試してみると使えるようになっている
aws s3 ls --profile naka
この段階で必要な権限がない場合には、管理者側で PermissionSetとAssign の設定で必要な権限が付与されているか確認してもらう必要がある。
自分のawscliが正しいcredentialsを使おうとしているかを以下のコマンドでも確認できる
aws sts get-caller-identity --profile naka