API Gateway: AWS Service integration using IAM authorization

0

I'm using AWS Service integration to connect API Gateway to DynamoDB.

E.g. PUT orders/{id} -> AWS Service: DynamoDB, Action: UpdateItem (using a mapping template to transform the HTTP body to a UpdateItem request).

Works fine. Now I'd like to secure the table so that a user can only access their own records. I've created a Cognito Identity Pool to limit a user's access and I've configured the method to use AWS IAM for auth. But I don't see a way to tell the integration to use that as the Execution role. As far as I can see, you have to hard-code that.

Is there a way to use the IAM role as the execution role?

Workaround

I'm aware that I can put a Lambda in the middle, getting it to make the DynamoDB call using the user's IAM credentials, but that's an extra hop and more code to look after. If anybody know a way to go IAM -> Gateway -> Dynamo that would be much better.

1 個回答
1

Something worth trying - https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_dynamodb_items.html

Amazon DynamoDB: Allows item-level access to DynamoDB based on an Amazon Cognito ID

profile pictureAWS
專家
已回答 2 年前
  • Interesting suggestion. thanks! +1

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南