4

I’m trying to use the new DynamoDB BatchResolvers to write to two DynamoDB table in an AppSync resolver (currently using a Lambda function to do this). However, I’m getting the following permission error when looking at the CloudWatch logs:

“User: arn:aws:sts::111111111111:assumed-role/appsync-datasource-ddb-xxxxxx-TABLE-ONE/APPSYNC_ASSUME_ROLE is not authorized to perform: dynamodb:BatchWriteItem on resource: arn:aws:dynamodb:us-east-1:111111111111:table/TABLE-TWO (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: AccessDeniedException;

I’m using TABLE-ONE as my data source in my resolver.

I added the "dynamodb:BatchWriteItem" and "dynamodb:BatchGetItem" to TABLE-ONE’s permission:

{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": [ "dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:PutItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Scan", "dynamodb:Query", "dynamodb:UpdateItem" ], "Resource": [ "arn:aws:dynamodb:us-east-1:111111111111:table/TABLE-ONE", "arn:aws:dynamodb:us-east-1:111111111111:table/TABLE-ONE/*", "arn:aws:dynamodb:us-east-1:111111111111:table/TABLE-TWO", "arn:aws:dynamodb:us-east-1:111111111111:table/TABLE-TWO/*" ] } ] }

I have another resolver that uses the BatchGetItem operation and was getting null values in my response - changing the table’s policy access level fixed the null values: enter image description here

However, checking the box for BatchWriteItem doesn’t seem to solve the issue either adding the permissions to the data source table’s policy.

I also tested my resolver test feature in AppSync, the evaluated request and response are working as intended.

Where else could I set the permissions for a BatchWriteItem operation between two tables? It seems like it's invoking the user's assumed-role instead of the table's role - can I 'force' it to use the table's role?

4

1 回答 1

5

它正在使用您在 AppSync 控制台中为表配置的角色。请注意,该特定角色应将 appsync 作为受信任的实体。在此处输入图像描述

或者,如果您在控制台中创建数据源时使用新角色复选框,它应该会处理它。

于 2018-05-04T22:29:17.240 回答