Amazon QuickSight でサブスクリプションの削除を行うとセカンダリ名前空間が残ってしまうのかを確認してみた

2022.12.03

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

いわさです。

先日 QuickSight サブスクリプションの削除周りの検証を行ったときに公式ドキュメントに気になる文言を見つけました。

The act of deleting Amazon QuickSight from your is immediate and final. Deletion removes every QuickSight asset on the AWS account you are using. It doesn't delete namespaces that you added. (The Default namespace is deleted automatically.) You can locate and delete namesspaces by using the API operations ListNamespaces and DeleteNamespace.

QuickSight のサブスクリプション削除時には追加した名前空間も全て削除されるような動きになるのかと思っていたのですが、このドキュメントの記述を見るとデフォルトの名前空間だけ削除されるように読み取れなくもないです。
追加した名前空間だけ残るということなのでしょうか。

本日は実際に名前空間を追加して QuickSight サブスクリプションを削除し、挙動を確認してみました。

確認

まず以下を参考に名前空間を追加します。

% aws quicksight create-namespace --aws-account-id 123456789012 --namespace namespace1 --identity-store QUICKSIGHT
{
    "Status": 202,
    "Name": "namespace1",
    "CapacityRegion": "ap-northeast-1",
    "CreationStatus": "CREATING",
    "IdentityStore": "QUICKSIGHT",
    "RequestId": "b1cd9758-1b8f-4cd4-8098-d2cbfc8ef143"
}
% aws quicksight list-namespaces --aws-account-id 123456789012
{
    "Namespaces": [
        {
            "Name": "default",
            "Arn": "arn:aws:quicksight:ap-northeast-1:123456789012:namespace/default",
            "CapacityRegion": "ap-northeast-1",
            "CreationStatus": "CREATED",
            "IdentityStore": "QUICKSIGHT"
        },
        {
            "Name": "namespace1",
            "Arn": "arn:aws:quicksight:ap-northeast-1:123456789012:namespace/namespace1",
            "CapacityRegion": "ap-northeast-1",
            "CreationStatus": "CREATING",
            "IdentityStore": "QUICKSIGHT"
        }
    ],
    "Status": 200,
    "RequestId": "e9cc59c8-9737-4431-a17a-39f64b668564"
}

追加された名前空間用の IAM ユーザーを作成し QuickSight ユーザーとして登録します。

% aws iam create-user --user-name namespace-user1
{
    "User": {
        "Path": "/",
        "UserName": "namespace-user1",
        "UserId": "AIDAXUIDMDMASTXNUGPBX",
        "Arn": "arn:aws:iam::123456789012:user/namespace-user1",
        "CreateDate": "2022-11-24T20:13:12+00:00"
    }
}
% aws iam create-login-profile --user-name namespace-user1 --password P@ssw0rdd --no-password-reset-required
{
    "LoginProfile": {
        "UserName": "namespace-user1",
        "CreateDate": "2022-11-24T20:14:20+00:00",
        "PasswordResetRequired": false
    }
}
% aws quicksight register-user --identity-type IAM --email iwasa.takahito+nsuser1@classmethod.jp --user-role ADMIN --iam-arn arn:aws:iam::123456789012:user/namespace-user1 --aws-account-id 123456789012 --namespace namespace1
{
    "Status": 201,
    "User": {
        "Arn": "arn:aws:quicksight:ap-northeast-1:123456789012:user/namespace1/namespace-user1",
        "UserName": "namespace-user1",
        "Email": "iwasa.takahito+nsuser1@classmethod.jp",
        "Role": "ADMIN",
        "IdentityType": "IAM",
        "Active": false,
        "PrincipalId": "federated/iam/AKIAIOSFODNN7EXAMPLE"
    },
    "RequestId": "198185e4-d8f3-41f4-b620-f23b6802d8fa"
}

これで、対象ユーザーでログインすると追加された名前空間にアクセスすることが出来るようになりました。

サブスクリプション削除する

ここで本題のサブスクリプション削除をしてみたいと思います。
果たしてどうなるか。

追加の名前空間が存在する場合は削除自体が出来ませんでした。

AWS CLI のサブスクリプション削除操作でも削除できません。

% aws quicksight delete-account-subscription --aws-account-id 123456789012

An error occurred (PreconditionNotMetException) when calling the DeleteAccountSubscription operation: Failed to unsubscribe as the account has active secondary namespaces.

ということで、セカンダリ名前空間を先に削除してからサブスクリプションは削除する必要があるということがわかりました。
実際にやってみましょう。

以下のコマンドで追加した名前空間を削除します。

% aws quicksight delete-namespace --aws-account-id 123456789012 --namespace namespace1
{
    "Status": 202,
    "RequestId": "41e8668c-d297-45ba-8cb5-3598a0795b02"
}

その後サブスクリプションの削除が出来ました。

さいごに

本日は Amazon QuickSight でサブスクリプションの削除を行うとセカンダリ名前空間が残ってしまうのかを確認してみました。

セカンダリ名前空間がまとめて削除されるわけでも、デフォルトの名前空間だけ削除されるわけでもなく、セカンダリ名前空間が存在していると削除操作が出来ない。ということがわかりました。