amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

Default Lamda Execution Policy Can't Use Global Secondary Indexes

Open johnford2002 opened this issue 7 years ago • 7 comments

Describe the bug Using the amplify-cli to create a REST API backed by DynamoDB, complete with a global secondary index, results in a Lamda IAM role & policy that can't query the GSI.

To Reproduce Steps to reproduce the behavior:

  1. amplify init
  2. amplify add api 2a. Select REST, select CRUD backed by Dynamo, create new table, specify enough columns for a primary key, sort key, and GSI.
  3. amplify push
  4. Attempt to query GSI either through code or direct API endpoint

Expected behavior The Lamda CloudFormation template should add the Dynamo index(es) to the allowed resource section under the lamda-execution-policy.

Desktop (please complete the following information):

  • OS: Mac OS X Sierra
  • Browser: Chrome

johnford2002 avatar Jan 29 '19 22:01 johnford2002

I've just been poking my way around the codebase, but I believe the fix for this will end up in this file if I'm understanding things correctly: https://github.com/aws-amplify/amplify-cli/blob/master/packages/amplify-category-function/provider-utils/awscloudformation/cloudformation-templates/lambda-cloudformation-template.json.ejs#L74

johnford2002 avatar Feb 04 '19 02:02 johnford2002

@johnford2002 You're right. If you can submit a quick PR for the same, I could review it and we could ship this in our next release. Thanks!

kaustavghosh06 avatar Apr 03 '19 05:04 kaustavghosh06

Hi @kaustavghosh06, is there a manual workaround to query on a secondary index? I am struggling for a while on this

dz0l038 avatar Apr 15 '19 12:04 dz0l038

I'm also blocked on this. Any updates?

ryross avatar Jun 18 '19 00:06 ryross

We've merged a fix for this. This would be a part of our next npm release.

kaustavghosh06 avatar Jun 20 '19 18:06 kaustavghosh06

Cool @kaustavghosh06. Patiently waiting this side. Any idea of ETA? Thanks.

jarrettj avatar Jul 05 '19 08:07 jarrettj

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

github-actions[bot] avatar May 27 '21 06:05 github-actions[bot]