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

クリーンアップ1.2. 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

設定値の確認

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

変数の確認:

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}"

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

IdentityStoreユーザーのIDを取得します。

コマンド:

identitystore_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 \
) \
  && echo ${identitystore_user_id}

結果(例):

xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

IdentityStoreユーザーの削除

IdentityStoreユーザーを削除します。

変数の確認:

cat << END

  # sso_admin_identity_store_id:"d-xxxxxxxxxx"
    sso_admin_identity_store_id="${sso_admin_identity_store_id}"
  # identitystore_user_id:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    identitystore_user_id="${identitystore_user_id}"

END

コマンド:

aws identitystore delete-user \
  --identity-store-id ${sso_admin_identity_store_id} \
  --user-id ${identitystore_user_id}

結果(例):

(出力なし)

完了確認

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

コマンド:

! 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

結果(例):

An error occurred (ResourceNotFoundException) when calling the GetUserId operation: USER not found.

手順の完了

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

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

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

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