ハンズオン(簡易版): IAM Identity Center基礎

5.1. IdentityStoreユーザーの作成 (ichi)

手順の目的

IdentityStoreユーザー名"ichi"を作成します。

設定値の指定

手順に必要な設定値を変数に格納をします。

0. リージョン

リージョンを指定します。

環境変数の設定:

export AWS_DEFAULT_REGION='ap-northeast-1'

1. IdentityStoreユーザー名

一時ファイルを指定します。

変数の設定:

DIR_TMP="${HOME}/environment/tmp-handson-cli-iic"

変数の設定:

FILE_TMP="${DIR_TMP}/handson-cli-iic-user.tmp" \
  && echo ${FILE_TMP}

結果(例):

${HOME}/environment/tmp-handson-cli-iic/handson-cli-iic-user.tmp

一時ファイルをドットコマンドで読み込みます。

コマンド:

. ${FILE_TMP}

IdentityStoreユーザー名を指定します。

変数の設定:

IDENTITYSTORE_USER_NAME="${USER_NAME}" \
  && echo ${IDENTITYSTORE_USER_NAME}

結果(例):

ichi

2. IdentityStoreユーザーの名

IdentityStoreユーザーの名を指定します。

変数の設定:

IDENTITYSTORE_USER_GIVEN_NAME="${GIVEN_NAME}" \
  && echo ${IDENTITYSTORE_USER_GIVEN_NAME}

結果(例):

Ichiro

3. IdentityStoreユーザーの姓

IdentityStoreユーザーの姓を指定します。

変数の設定:

IDENTITYSTORE_USER_FAMILY_NAME="${FAMILY_NAME}" \
  && echo ${IDENTITYSTORE_USER_FAMILY_NAME}

結果(例):

Suzuki

4. ユーザー表示名

ユーザー表示名を指定します。

変数の設定:

IDENTITYSTORE_USER_DISPLAY_NAME="${IDENTITYSTORE_USER_GIVEN_NAME}_${IDENTITYSTORE_USER_FAMILY_NAME}" \
  && echo ${IDENTITYSTORE_USER_DISPLAY_NAME}

結果(例):

Ichiro_Suzuki

5. メールアドレス

IdentityStoreユーザーのメールアドレスを指定します。

変数の設定:

IDENTITYSTORE_USER_EMAIL_ADDRESS="${MAIL_ADDRESS}" \
  && echo ${IDENTITYSTORE_USER_EMAIL_ADDRESS}

結果(例):

ichi@example.jp

6. メールアドレスのタイプ

IdentityStoreユーザーのメールアドレスのタイプを指定します。

変数の設定:

IDENTITYSTORE_USER_EMAIL_TYPE='Work'

設定値の確認

各変数に正しい設定値が格納されていることを確認します。

変数の確認:

cat << END

  # 0. AWS_DEFAULT_REGION:"ap-northeast-1"
       AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION}"

  # 1. IDENTITYSTORE_USER_NAME:"ichi"
       IDENTITYSTORE_USER_NAME="${IDENTITYSTORE_USER_NAME}"
  # 2. IDENTITYSTORE_USER_GIVEN_NAME:"Ichiro"
       IDENTITYSTORE_USER_GIVEN_NAME="${IDENTITYSTORE_USER_GIVEN_NAME}"
  # 3. IDENTITYSTORE_USER_FAMILY_NAME:"Suzuki"
       IDENTITYSTORE_USER_FAMILY_NAME="${IDENTITYSTORE_USER_FAMILY_NAME}"
  # 4. IDENTITYSTORE_USER_DISPLAY_NAME:"Ichiro_Suzuki"
       IDENTITYSTORE_USER_DISPLAY_NAME="${IDENTITYSTORE_USER_DISPLAY_NAME}"
  # 5. IDENTITYSTORE_USER_EMAIL_ADDRESS:"ichi@example.jp"
       IDENTITYSTORE_USER_EMAIL_ADDRESS="${IDENTITYSTORE_USER_EMAIL_ADDRESS}"
  # 6. IDENTITYSTORE_USER_EMAIL_TYPE:"Work"
       IDENTITYSTORE_USER_EMAIL_TYPE="${IDENTITYSTORE_USER_EMAIL_TYPE}"

END

各変数について、上の行と下の行の値の内容もしくは形式が同じであることを確認します。 もし異なる場合は、それぞれの手順番号に戻って変数の設定を行います。

処理の実行

IdentityStore IDを取得します。

コマンド:

sso_admin_identity_store_id=$( \
  aws sso-admin list-instances \
    --query "Instances[].IdentityStoreId" \
    --output text \
) \
  && echo ${sso_admin_identity_store_id}

結果(例):

d-xxxxxxxxxx

ユーザー名設定文字列を指定します。

変数の設定:

STRING_IDENTITYSTORE_USER_NAME="FamilyName=${IDENTITYSTORE_USER_FAMILY_NAME},GivenName=${IDENTITYSTORE_USER_GIVEN_NAME}" \
  && echo ${STRING_IDENTITYSTORE_USER_NAME}

結果(例):

FamilyName=Suzuki,GivenName=Ichiro

メールアドレス設定文字列を指定します。

変数の設定:

STRING_IDENTITYSTORE_USER_EMAIL="Value="${IDENTITYSTORE_USER_EMAIL_ADDRESS}",Type=${IDENTITYSTORE_USER_EMAIL_TYPE},Primary=true" \
  && echo ${STRING_IDENTITYSTORE_USER_EMAIL}

結果(例):

Value="ichi@example.jp",Type=Work,Primary=true

IdentityStoreユーザーの作成

IdentityStoreユーザーを作成します。

変数の確認:

cat << END

  # sso_admin_identity_store_id:"d-xxxxxxxxxx"
    sso_admin_identity_store_id="${sso_admin_identity_store_id}"
  # IDENTITYSTORE_USER_NAME:"ichi"
    IDENTITYSTORE_USER_NAME="${IDENTITYSTORE_USER_NAME}"
  # IDENTITYSTORE_USER_DISPLAY_NAME:"Ichiro_Suzuki"
    IDENTITYSTORE_USER_DISPLAY_NAME="${IDENTITYSTORE_USER_DISPLAY_NAME}"
  # STRING_IDENTITYSTORE_USER_NAME:"FamilyName=Suzuki,GivenName=Ichiro"
    STRING_IDENTITYSTORE_USER_NAME="${STRING_IDENTITYSTORE_USER_NAME}"
  # STRING_IDENTITYSTORE_USER_EMAIL:"Value="ichi@example.jp",Type=Work,Primary=true"
    STRING_IDENTITYSTORE_USER_EMAIL="${STRING_IDENTITYSTORE_USER_EMAIL}"

END

コマンド:

aws identitystore create-user \
  --identity-store-id ${sso_admin_identity_store_id} \
  --user-name ${IDENTITYSTORE_USER_NAME} \
  --display-name ${IDENTITYSTORE_USER_DISPLAY_NAME} \
  --name "${STRING_IDENTITYSTORE_USER_NAME}" \
  --emails "${STRING_IDENTITYSTORE_USER_EMAIL}"

結果(例):

{
  "UserId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "IdentityStoreId": "d-xxxxxxxxxx"
}

完了確認

「IdentityStoreユーザー名"ichi"が存在する。」ことを確認します。

コマンド:

aws identitystore describe-user \
  --identity-store-id ${sso_admin_identity_store_id} \
  --user-id $(
    aws identitystore get-user-id \
      --identity-store-id ${sso_admin_identity_store_id} \
      --alternate-identifier "{\"UniqueAttribute\":{\"AttributePath\":\"userName\",\"AttributeValue\":\"${IDENTITYSTORE_USER_NAME}\"}}" \
      --query 'UserId' \
      --output text
  ) \
  --query 'UserName' \
  --output text

結果(例):

ichi

手順の完了

  • IAM Identity Centerダッシュボード ( https://console.aws.amazon.com/singlesignon/home )にアクセスします。

  • 左ペイン "ユーザー"をクリックします。

  • 検索フォームにユーザー名"ichi"を入力します。

  • ユーザー名"ichi"が表示されれば正常です。