0
0

AWS IAM Identity Centerの設定

Last updated at Posted at 2024-08-18

IAM Identity Centerの有効化 (管理者)

image.png

InstanceのQuotaが1のため、有効化するRegionを間違えると複数はEnableできないのでRegionを間違えないようにする

Screenshot 2024-08-18 at 12.42.58.png

最初は個人のアカウントで検証用に作成したが、Permission setの作り方が見つからなかったのでAWS Orgで作成。

Orgを初めて作ると、以下のようなメールが来るのでVerifyしておく。

Screenshot 2024-08-18 at 12.46.27.png

User作成 (管理者)

Screenshot 2024-08-18 at 10.49.21.png

アクセス権限の付与 (管理者)

PermissionSetを作成

PermissionSetはAccountとは関係なくどんなことができるかを定義するIAM Roleのようなもの。
次のセクションで実際にどのUserやGroupに、どのAWS Accountに対して、どのPermissionSetを付与するかを設定する

https://docs.aws.amazon.com/singlesignon/latest/userguide/howtocreatepermissionset.html に基づきPermissionSetを作成する
Screenshot 2024-08-18 at 12.49.44.png

練習としてPredefinedのPowerUserAccessでSessionの長さを12hとして作成。
Screenshot 2024-08-18 at 12.52.06.png

PermissionSetのAssign

AWS Account、User/Group、PermissionSetの組み合わせで、どのAWS Accountのどの権限(PermissionSet)を誰(User/Group)に付与するかを決める

https://docs.aws.amazon.com/singlesignon/latest/userguide/useraccess.html に基づいて設定する

Screenshot 2024-08-18 at 12.55.39.png

AWS accountsを開いてUserまたはGroupに上のステップで作成した権限を付与する

Screenshot 2024-08-18 at 12.56.42.png

今回は、簡単のため nakaにPowerUserAccessを付与した

各Userの設定 (利用ユーザ)

受け取った案内に従ってPasswordを設定

上のUser作成でユーザを作成するときに、Emailを入れてメールで初期設定の案内が届くようになっている

以下のようなメールが届くので、Your AWS access portal URL を控えておく。

このYour AWS access portal URLはあとでcliの設定時にも使う

Screenshot 2024-08-18 at 10.50.51.png

パスワードを設定

Screenshot 2024-08-18 at 10.51.43.png

MFAの設定などをして設定完了。

Screenshot 2024-08-18 at 10.54.41.png

awscli設定

configを設定する

  1. 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する

Screenshot 2024-08-18 at 10.58.32.png

無事成功 :tada:

Screenshot 2024-08-18 at 10.59.14.png

  1. ~/.aws/sso/cache/いかにssoのJSONファイルが生成される
  2. ~/.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 を試してみると使えるようになっている :tada:

aws s3 ls --profile naka

この段階で必要な権限がない場合には、管理者側で PermissionSetとAssign の設定で必要な権限が付与されているか確認してもらう必要がある。

自分のawscliが正しいcredentialsを使おうとしているかを以下のコマンドでも確認できる

aws sts get-caller-identity --profile naka

Ref

  1. https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html
  2. https://dev.classmethod.jp/articles/iic-setting-terraform/
  3. https://dev.classmethod.jp/articles/aws-cli-for-iam-identity-center-sso/
    1. https://zenn.dev/aldagram_tech/articles/fefd52c93dd5a9
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0