-
Notifications
You must be signed in to change notification settings - Fork 822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cognito Trigger templates' return and permissions issue #7582
Comments
is there a suggested workaround for this issue that doesn't involve the console? |
Me too. Presumably a workaround is possible while we wait for this to be merged? |
@Straubulous this is still affecting the
|
this was accidentally closed by PR merge, one outstanding item here, see #7582 (comment) |
The issue described in #7582 (comment) is still not resolved and the ticket is closed. Please reopen and fix the remaining item!!! |
Same issue here with Amplify CLI v7.6.21. |
I "solved" this by modifying
|
@scottmcmaster’s workaround worked for me, though i had to also add [
{
"Action": [
"cognito-idp:AdminAddUserToGroup",
"cognito-idp:CreateGroup",
"cognito-idp:GetGroup"
],
"Resource": [
"<HARD-CODED USERPOOL ARN FROM THE ERROR MESSAGE>"
]
}
] it would solve it for me completely if i could use a string as the resource ARN that would switch between my |
Unfortunately still unsolved with latest amplify cli 8.1.0 |
@acusti Since "Resource" is an array, you can just add each of your user pool ARNs in that array. [
{
"Action": [
"cognito-idp:AdminAddUserToGroup",
"cognito-idp:CreateGroup",
"cognito-idp:GetGroup"
],
"Resource": [
"<DEV USERPOOL ARN>",
"<MAIN USERPOOL ARN>",
]
}
] |
@josefaidt any update on this one? |
people have been reporting this very core issue for over two years and the best solutions are either hard coding arns into |
Is there anyway to have it automatically fill in the resource ARN? My project is open source which means I'm going to have to give extra instructions on doing this part. Seems like this issue has been open for a few years now. Any update from the Amplify team?? |
I'm having the same issue with the circular dependencies, but trying to get access to a DynamoDB table with still no luck, only getting errors when trying to deploy. I think it's extremely bad that this issues has been around since 2019 and there's still no actual fix in the roadmap, we need to do this 'hacky' way to do things as simple as reading from a database before a user signs-up. Even the official documentation has a way of doing this use case, but this wouldn't work on a real world scenario as the selected triggers through the console will be overwritten every time you update any other. I think this should be prioritized as it renders the trigger functions basically useless except for really basic operations like sending e-mails. |
This issue is still not fixed and I'm on Amplify CLI version 10.5.2. I'm having to add a custom policy for the post confirmation lambda since the lambda only has CloudWatch permissions from the lambda execution role. The lambda trigger that invokes this one has the right permissions. Here is the configuration I used: C:\repos\tom\amplify-model>amplify add auth The current configured provider is Amazon Cognito. Do you want to use the default authentication and security configuration? Manual configuration Next steps: ✅ Some next steps: C:\repos\tom\amplify-model> This is the custom policy I added: { This function has these permissions now and completes successfully without error: This is what needs to be added as a fix. |
I have this problem and it involves a lot of manual work. For fresh backend deployment, do amplify push first, update this file with ARN and do another push. When team members deploy their own backend, they have to modify the custom-policies.json file with their ARN and remember not to check it in and back it up during branch switching, etc. It would really help to have this happen automatically when we allow the lambda function to access other resources. |
Amplify team, wanted to ask what's your approach to semi-permanent bugs like this, when Cognito trigger Lambdas can not access GraphQL API? Like everybody else, I've run into number of these, I slowly find and implement workarounds - great its there... somewhere. And sometimes they are in triple-chained closed issues like this one. This is however a very inefficient process of development. These issues been around for so long time that maybe you can get fixed links and the solutions discovered more easily? I'd rather go via official docs that links outstanding ticket that comb through outstanding ticket trying to find a solution to a common problem |
I've just run into this issue not with the Amplify CLI and backend hosting, but with AWS CDK. What a tricky issue! |
This needs fixing urgently. |
FWIW, I fixed this by breaking the cyclic dependency out of the (in my case, not amplify, but CDK, stack), then slurping the stack outputs into environment variables, then consuming those in a script to use the AWS JS SDK v3 to complete the cycle of permissions. Put it on the pile of workarounds! I hope this helps someone. stackOutputsForDotenv.ts:
addDependenciesToCognitoTriggerLambda.ts:
lambda.ts:
iam.ts:
|
I think I found another instance of such circular dependencies: when using CDK to both define a lambda as a DynamoDB stream event handler that tries to write to an OpenSearch Serverless collection defined in the same CDK stack, the collection's data access policy must have the lambda's ARN for the Principal of "aoss:*" permissions on its collection and index, whereas an inline policy on the lambda must have the collection's ARN for the resource of the "aoss:APIAccessAll" permission. So this isn't exclusively a Amplify issue, nor even exclusively a Cognito triggers issue. There are just some cases where your underlying CloudFormation stack will have circular dependencies, and there's no generic way yet to resolve that. |
The solution could be a second sequence of deploying with some dependencies, defined in a separate circular dependency file? The cli is checking for circular dependencies, write it to a separate file, deploy, if the file exists run the second deploy and delete the file. |
Before opening, please confirm:
How did you install the Amplify CLI?
yarn
If applicable, what version of Node.js are you using?
16.3
Amplify CLI Version
5.0.1
What operating system are you using?
Mac
Amplify Categories
auth
Amplify Commands
Not applicable
Describe the bug
Return Issue
Trigger's index.js file calls module handlers by passing
handler(event, context, callback)
without a return, and inside the "module" file (i.e.add-to-group.js
)callback
is not utilized and response is not returned.Permission Issue
In the
add-to-group
Cognito trigger template, it makes a call to create a group, however these permissions are missing #7576 (comment)Expected behavior
Template trigger files should return out-of-the-box and appropriate permissions are attached.
Reproduction steps
(follow steps in issues noted above)
GraphQL schema(s)
# Put schemas below this line
Log output
Additional information
No response
The text was updated successfully, but these errors were encountered: