QuickSightの名前空間機能を使ってマルチテナント用に環境を分離させる

2021.01.14

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

いわさです。

QuickSightには名前空間(namespace)の概念があります。

1つのAWSアカウントで作成出来るQuickSightアカウントは1つです。
しかし、名前空間を使うことでQuickSightアカウント内に、分離された環境を複数作成することが出来ます。

名前空間はEnterprise Editionでのみ提供されます。
また、アカウント認証方法は"Use Role Based Federation (SSO)"である必要があります。

名前空間作成

名前空間の管理はGUIからは出来ません。
API or AWS CLIで操作する必要があります。

create-namespaceコマンドで名前空間を作成します。
なお、現時点でIdentityStoreにはIAMは指定できません。
所属するユーザーがIAMユーザーだとしても、QUICKSIGHTを指定してください。

iwasa.takahito@iwasa ~ % aws quicksight create-namespace --aws-account-id 999999999999 --namespace namespace1 --identity-store IAM

An error occurred (ValidationException) when calling the CreateNamespace operation: 1 validation error detected: Value 'IAM' at 'identityStore' failed to satisfy constraint: Member must satisfy enum value set: [QUICKSIGHT]
iwasa.takahito@iwasa ~ % aws quicksight create-namespace --aws-account-id 999999999999 --namespace namespace1 --identity-store QUICKSIGHT
{
    "Status": 202,
    "Name": "namespace1",
    "CapacityRegion": "ap-northeast-1",
    "CreationStatus": "CREATING",
    "IdentityStore": "QUICKSIGHT",
    "RequestId": "6621021a-95d4-4812-a38c-648df6f9f32f"
}
iwasa.takahito@iwasa ~ %

名前空間の登録が完了しました。

iwasa.takahito@iwasa ~ % aws quicksight list-namespaces --aws-account-id 999999999999
{
    "Status": 200,
    "Namespaces": [
        {
            "Name": "default",
            "Arn": "arn:aws:quicksight:ap-northeast-1:999999999999:namespace/default",
            "CapacityRegion": "ap-northeast-1",
            "CreationStatus": "CREATED",
            "IdentityStore": "QUICKSIGHT"
        },
        {
            "Name": "namespace1",
            "Arn": "arn:aws:quicksight:ap-northeast-1:999999999999:namespace/namespace1",
            "CapacityRegion": "ap-northeast-1",
            "CreationStatus": "CREATED",
            "IdentityStore": "QUICKSIGHT"
        }
    ],
    "RequestId": "b83ca292-7a02-4535-b68e-237148678217"
}

ユーザー登録

新規IAMユーザー(権限なし)を作成し、AWS CLIからQuickSightへユーザー登録を行います。
登録の際に名前空間を指定することで対象名前空間で管理されるユーザーとなります。

iwasa.takahito@iwasa ~ % aws quicksight register-user --identity-type IAM --email xxxx@mail.jp --user-role READER --iam-arn arn:aws:iam::999999999999:user/namespace1-user1 --aws-account-id 999999999999 --namespace namespace1
{
    "Status": 201,
    "User": {
        "Arn": "arn:aws:quicksight:ap-northeast-1:999999999999:user/namespace1/namespace1-user1",
        "UserName": "namespace1-user1",
        "Email": "xxxx@mail.jp",
        "Role": "READER",
        "IdentityType": "IAM",
        "Active": false,
        "PrincipalId": "federated/iam/XXXXXXXXXX"
    },
    "RequestId": "433a7479-a9d4-4834-a06e-da9824fa457e"
}

default名前空間のユーザー管理上には存在しません。

作成した名前空間の管理者ロールユーザーでサインインし、ユーザー管理を開くと、対象名前空間のユーザーを確認することが出来ます。

default名前空間でダッシュボードを作成し全ユーザーへ共有してみます。

別名前空間のユーザーでサインインしても閲覧出来ません。

別の名前空間にもユーザーを作成

複数の名前空間に同一IAMユーザーを登録することは出来ません。
よって、AWS-CLIを使わない管理者や作成者が必要な場合はそれぞれの名前空間上に用意する必要があります。

iwasa.takahito@iwasa ~ % aws quicksight register-user --identity-type IAM --email xxxx@mail.jp --user-role ADMIN --iam-arn arn:aws:iam::999999999999:user/namespace1-admin1 --aws-account-id 999999999999 --namespace default

An error occurred (ResourceExistsException) when calling the RegisterUser operation: User namespace1-admin1 already exists in namespace default. AWS account id: 999999999999, Namespace: default. IAM ARN: arn:aws:iam::999999999999:user/namespace1-admin1.

デフォルト名前空間の変更

account-settingsにデフォルト名前空間の概念があります。 自己プロビジョニング時の名前空間として使用されるようですが、現状は変更出来ないようです。

iwasa.takahito@iwasa ~ % aws quicksight describe-account-settings --aws-account-id 999999999999
{
    "Status": 200,
    "AccountSettings": {
        "AccountName": "iwasa-quicksight",
        "Edition": "ENTERPRISE",
        "DefaultNamespace": "default",
        "NotificationEmail": "xxxx@mail.jp"
    },
    "RequestId": "b3bffcbd-b67d-4ebf-98dc-e516b3b91f1e"
}
iwasa.takahito@iwasa ~ % aws quicksight update-account-settings --aws-account-id 999999999999 --default-namespace namespace2

An error occurred (InvalidParameterValueException) when calling the UpdateAccountSettings operation: Changing default namespace is currently not supported

まとめ

名前空間を使うと、1つのQuickSightアカウント内で分離した環境を用意することが出来ます。
AWS-CLIのみの取り扱いになる点はグループと同じです。
フォルダで分けるか、より強固に名前空間で分けるかを検討のうえ利用しましょう。