AppSync BatchResolver AssumeRole Error

馋奶兔 提交于 2019-12-23 17:55:37

问题


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:

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?


回答1:


It is using the role that you have configured for the table in the AppSync console. Note that that particular role, should have appsync as a trusted entity.

Or if you use the new role tick box when creating the data source in the console, it should take care of it.



来源:https://stackoverflow.com/questions/50052333/appsync-batchresolver-assumerole-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!