0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AWS AppSyncで、IAM認証を使ってコンソールからクエリを実行する際にやること

Posted at

結論

AppSyncでIAM認証を用いて、AWS マネジメントコンソールからクエリを実行する際は、公式ドキュメントの通り、amplify/backend/api/<your-api-name>/custom-roles.jsonを作成し、以下のように記載する。

{
  "adminRoleNames": ["<YOUR_IAM_USER_OR_ROLE_NAME>"]
}

ことの発端

Amplify経由で、AppSyncを作成し、以下のようなschemaを作成しました。

type User @model @auth(
    rules: [
      { allow: private, provider: iam }
    ]
  ){
  id: ID!
  name: String!
}

AWS マネジメントコンソールからcreateを実行したところ、
以下のエラーがコンソール画面に表示されました。

Not Authorized to access createUser on type User

原因

AWS マネジメントコンソールからクエリを実行する際は、どのIAMを使用するか、設定する必要があるため。

対処法

  • amplify/backend/api/<your-api-name>/custom-roles.jsonを作成する。
  • 公式ドキュメントのとおり、以下のように記載する。
    • custom-roles.json
        {
          "adminRoleNames": ["<YOUR_IAM_USER_OR_ROLE_NAME>"]
        }
      
    • 基本的には公式ドキュメントの通りロールを作成して、ロール名を入力すればよいと思います。
    • 面倒であれば、コンソールにログインするユーザ名を入力すればよいと思います。
  • amplify pushして、上記内容を更新する。

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?