Describe the bug
I upgraded the cli from v3.9 to v3.17 then did an amplify push. The push is failing with:
UPDATE_FAILED Update<redact>RequestResolver AWS::AppSync::Resolver Wed Nov 06 2019 14:36:46 GMT-0700 (Mountain Standard Time) Invalid request template given, must be less than 64kb in size. (Service: AWSAppSync; Status Code: 400; Error Code: BadRequestException; Request ID: d2eec6ea-649e-4dea-b188-d4464fd52e1c)
Amplify CLI Version
v3.17
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
This is an auto-generated resolver with lots of field-level auth directives. Perhaps this is why the resolver is so big? This seems like a new limitation?
-rw-r--r-- 1 hisham staff 64K 6 Nov 14:34 Mutation.updateQuestionnaireRequest.req.vtl
Looking at the resolver size uploaded by the v3.9 cli, it is 50kb:
-rw-r--r-- 1 hisham wheel 50K 6 Nov 15:10 Mutation.old.vtl
I bet the changes involved in implementing https://github.com/aws-amplify/amplify-cli/issues/766 pushed this over the 64kb limit.
I simplified my auth directives a bit and managed to get the file down to 57kb. Good enough for now but it seems like a fix is needed here to optimize your code or use pipeline resolvers or just get rid of this limit. Limits on code size is weird..
To reproduce just put a lot of auth directives on fields in models in the graphql schema. The code will keep growing and growing...
@hisham could you please check the diff of the two resolvers and share it with us? If it's confidential, send it to [email protected] if possible.
Sure @attilah I just sent the files.
@hisham those limits are (presumably) b/c AppSync users don't pay for compute/storage time used in VTL resolvers, and they want to minimize the potential for someone to abuse that. I would not be surprised if those limits are removed in the future and VTL charges are added to the AppSync billing model. But you may be able to open a ticket with the AppSync team and ask them for a code size limit increase, not sure if that's currently a soft or hard limit.
Any updates? I got the same problem..
But you may be able to open a ticket with the AppSync team and ask them for a code size limit increase, not sure if that's currently a soft or hard limit.
fyi I did contact AWS Support and they are not able to change these limits at this time. So the solution is to reduce the number of field-level auths until amplify cli comes up with reduced code to enforce field auths.
Thank you @hisham for the update!
Hmm, the solution AWS offers is hard to do, so I will try override a resolver to make small and optimize...
@rinosamakanata the resolvers have comments blocks, you could run a script to strip the comments?
@RossWilliams
Yes, this way is a little hack, but can reduce comment lines in resolver templates.
Changes:
function printComment(node: CommentNode, indent: string = ''): string {
return '';
}
Note: Don't forget to compile TypeScript to JavaScript.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because of inactivity. Please open a new issue if you are still encountering problems.
This issue has been automatically closed because of inactivity. Please open a new issue if you are still encountering problems.
Yikes. Never got a resolution to this?
+1
Please, I pay it without problem, just give us a solution, modifying the Graphql model is not an option.
Thanks in Advance!
+1 Same I have need to implement field auth rules as well. My next approach may be using a lambda resolver.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
A quick solution to this would be to make a feature flag that makes the VTL file be written with no comments if they get too big...
An even better solution would be to optionally run a minimization script on large files so that variable names are as short as possible...$ownerAuthExpressions => $o
Most helpful comment
+1
Please, I pay it without problem, just give us a solution, modifying the Graphql model is not an option.
Thanks in Advance!