-
Notifications
You must be signed in to change notification settings - Fork 825
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
fix(auth): standardize CloudFormation trigger templates, prevent errors at runtime #7219
fix(auth): standardize CloudFormation trigger templates, prevent errors at runtime #7219
Conversation
event
event
This also explains why the "Add CAPTCHA" never worked for me, and always just let me through - as an async function called in a synchronous context, it would never throw because it would immediately resolve without being |
4e47f2e
to
f3d3ad8
Compare
event
event
, make async
Codecov Report
@@ Coverage Diff @@
## master #7219 +/- ##
=======================================
Coverage 51.79% 51.79%
=======================================
Files 547 547
Lines 27626 27626
Branches 5342 5342
=======================================
Hits 14308 14308
Misses 12326 12326
Partials 992 992 Continue to review full report at Codecov.
|
event
, make asyncevent
, make async
event
, make asyncevent
* The context for this Lambda. See: | ||
* https://docs.aws.amazon.com/lambda/latest/dg/nodejs-context.html | ||
* | ||
* @param {function} callback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this PR is migrating to async/await
style, are the leftover callbacks still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left it in for backwards compatibility. In the linked issues, the way we all worked around was with a context.done()
call (though this breaks stacks with more than one handler, since it terminates the entire context), so there is utility in not breaking support if we can leave it in.
My understanding was the callback
param was the async handler equivalent of resolving synchronously without context.done()
- if someone passes the callback
param, it should work as expected, seemed like a good idea to leave it in just for compatibility.
See that we actually do pass the callback param to each handler:
Line 56 in d89542f
await Promise.all(modules.map(module => module.handler(event, context, callback))); |
If it's not passed, it doesn't make a difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left it in for backwards compatibility.
My understanding is that this code is only generated once, and that users updating their projects will not regenerate it. If that's the case, then I think we should really discourage using both callbacks and async/await.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's immediately obvious what we should do here:
- If we remove it, we basically kill support for any old patterns (new projects will be generated with the new template but old patterns exist in guides and blog posts published on AWS), and we'd want to make it very clear to users that the handlers generated by the CLI will use the async/await form, throw any errors, return values directly.
- If we don't remove it, old code using the callback will still work as written, but we might not be able to guarantee execution order (I think?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The more I think about this, the more I think it's a bad idea to intermingle callbacks and promises like this. For example, the trigger-index files will now be expecting the modules it invokes to return a value to indicate completion. However, if one of those modules does something like this, I think it could cause problems:
setTimeout(() => { callback(); }, 1000);
// Implicit return
...-utils/awscloudformation/triggers/CreateAuthChallenge/function-template-dir/trigger-index.js
Outdated
Show resolved
Hide resolved
...auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/captcha-verify.js
Show resolved
Hide resolved
...wscloudformation/triggers/VerifyAuthChallengeResponse/function-template-dir/trigger-index.js
Outdated
Show resolved
Hide resolved
...-utils/awscloudformation/triggers/CreateAuthChallenge/function-template-dir/trigger-index.js
Outdated
Show resolved
Hide resolved
3b2ef5b
to
63e647b
Compare
OK, since there were notes on the trigger template, which was pasted into 10 trigger template directories, rather than manually copy-paste the updates I just went ahead and added support for a default trigger template with ctjlewis#1, which involved very few changes.
Now there is one |
event
Hi @ctjlewis. Just following up - are you planning to remove the callbacks in this PR? |
@cjihrig - Could you maybe make the change? I will be unavailable for the next few days. I would also add a comment to clarify it should not be used. |
@cjihrig Any updates? |
@ctjlewis I also have not had time to work on this yet. |
@cjihrig This has been updated. |
@@ -1,4 +1,4 @@ | |||
exports.handler = (event, context, callback) => { | |||
exports.handler = async (event, context, callback) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove callback
.
@@ -1,13 +1,13 @@ | |||
exports.handler = (event, context, callback) => { | |||
exports.handler = async (event, context, callback) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove callback
here.
@@ -1,13 +1,13 @@ | |||
exports.handler = (event, context, callback) => { | |||
exports.handler = async (event, context, callback) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove callback
.
@@ -6,8 +6,8 @@ exports.handler = (event, context, callback) => { | |||
const domain = email.substring(email.indexOf('@') + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change the signature of this function to match the others.
@@ -1,13 +1,13 @@ | |||
exports.handler = (event, context, callback) => { | |||
exports.handler = async (event, context, callback) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove callback
.
@@ -0,0 +1,39 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change the _default
part of the file path. The leading underscore looks a bit off.
* {triggerDir}/../_default/{templateFile} if {triggerDir}/{templateFile} | ||
* override does not exist. | ||
*/ | ||
const templateFiles = ['trigger-index.js', 'package.json.ejs', 'event.json']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const templateFiles = ['trigger-index.js', 'package.json.ejs', 'event.json']; | |
const templateFiles = Object.keys(templateMap); |
* The function template dir for the default trigger template, i.e. | ||
* _default/function-template-dir. | ||
*/ | ||
const defaultRoot = path.resolve(triggerDir, '..', '_default', 'function-template-dir'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here about changing _default
.
exports.handler = async (event, context) => { | ||
const cognitoidentityserviceprovider = new aws.CognitoIdentityServiceProvider({ apiVersion: '2016-04-18' }); | ||
exports.handler = async event => { | ||
const cognitoidentityserviceprovider = new aws.CognitoIdentityServiceProvider({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be moved outside of the handler?
const defaultTemplate = path.resolve(defaultRoot, file); | ||
const overrideTemplate = path.resolve(sourceRoot, file); | ||
const templateToUse = fs.existsSync(overrideTemplate) ? overrideTemplate : defaultTemplate; | ||
return path.relative(sourceRoot, templateToUse); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like sourceFiles
here is a relative path, but in the previous version, it was just the file's basename. Is that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The comments could be updated for clarity, but it resolves each file to the default template if an override isn't found, and then resolves it relative to sourceRoot
for the following call:
amplify-cli/packages/amplify-cli/src/extensions/amplify-helpers/trigger-flow.ts
Lines 99 to 103 in 56c139d
functionTemplate: { | |
sourceRoot, | |
sourceFiles, | |
destMap, | |
}, |
Hi @ctjlewis - thank you again for this contribution and apologies on the turnaround time. I think we're in the final stretch of the PR here and we would be happy to finish this work during next Friday's bug bash session. Please let us know if you are okay with that. |
Just a heads up, I'm going to start working on this today. Sorry for the delay. |
No worries. I just stopped using the product when I ran into this, like most other users in that thread. And like I said, not you who should be apologizing. |
/** * For some reason, naively returning a value / Promise or throwing an error * will not work as it is specified in the Lambda docs: * @see https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html * * This causes an "Invalid JSON" error which can, so far, only be worked * around by resolving with deprecated non-async `callback`: * @see aws-amplify#2735 * @see aws-amplify#4341 * @see aws-amplify#7179 */
Use async/await with concurrent resolution via `Promise.all()`; make sure to return the event for additional layers in the stack
In addition to all top-level trigger Lambdas being async and returning the event, the generated modules should all be async Lambdas which avoid synchronous `context` and `callback` calls for performance / compatibility reasons.
* feat: support _default CloudFormation trigger template * chore: remove unnecessary `trigger-index.js` templates
Drop support for `context` and `callback`, only supporting async handlers.
aa85712
to
6d0a22a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one nit, otherwise LGTM
...rovider-utils/awscloudformation/triggers/CreateAuthChallenge/boilerplate-create-challenge.js
Outdated
Show resolved
Hide resolved
Hi @edwardfoyle and @ctjlewis , for those (like me) that are already facing this issue, what would be steps to fix an existing project after the release of this PR? |
@fbdo - look for Lines 1 to 39 in 3e2e630
Various features (CAPTCHA, Add User to Group, etc.) also had their handlers updated, see the 24 changed files as part of this PR. They are relatively well-commented. @renebrandel I would recommend that (even very light) documentation be added to the README / Amplify docs about how these triggers work. It should:
|
…rs at runtime (aws-amplify#7219) * fix: add-to-group PostConfirmation Lambda should not throw Co-authored-by: Colin Ihrig <colihrig@amazon.com>
👋 Hi, this pull request was referenced in the v5.1.2 release! Check out the release notes here https://github.com/aws-amplify/amplify-cli/releases/tag/v5.1.2. |
…rs at runtime (aws-amplify#7219) * fix: add-to-group PostConfirmation Lambda should not throw Co-authored-by: Colin Ihrig <colihrig@amazon.com>
* fix(amplify-category-auth): check for siwa Cognito idp params (#7678) Need to check for siwa params because privateKey is not returned from Cognito, so it may not always be available. Worst case the user will need to re-configure SIWA in a new environment for amplify init. Co-authored-by: David Lopez <lopezbnd@amazon.com> * chore(release): Publish [ci skip] - amplify-app@3.0.3 - amplify-appsync-simulator@1.27.2 - amplify-category-api@2.31.14 - amplify-category-auth@2.35.0 - @aws-amplify/cli@5.1.1 - amplify-console-integration-tests@1.8.0 - amplify-container-hosting@1.3.14 - amplify-e2e-core@1.23.0 - amplify-e2e-tests@2.45.0 - amplify-frontend-javascript@2.23.0 - amplify-go-function-runtime-provider@1.8.6 - @aws-amplify/graphql-function-transformer@0.3.5 - @aws-amplify/graphql-http-transformer@0.4.1 - @aws-amplify/graphql-model-transformer@0.4.4 - @aws-amplify/graphql-predictions-transformer@0.2.0 - @aws-amplify/graphql-searchable-transformer@0.3.0 - @aws-amplify/graphql-transformer-core@0.7.0 - @aws-amplify/graphql-transformer-interfaces@1.7.0 - amplify-headless-interface@1.8.0 - amplify-migration-tests@3.1.0 - amplify-provider-awscloudformation@4.55.0 - amplify-util-headless-input@1.5.1 - amplify-util-mock@3.33.4 * fix(auth): standardize CloudFormation trigger templates, prevent errors at runtime (#7219) * fix: add-to-group PostConfirmation Lambda should not throw Co-authored-by: Colin Ihrig <colihrig@amazon.com> * fix(amplify-cli): remove redundant prompt #6535 (#7098) * fix: remove redundant prompt #6535 * fix(amplify-category-notifications): trim whitespace from fcm keys (#7456) this commit prevents a copy/paste issue where an extra newline character comes along with an fcm key. fix #7440 * fix(amplify-provider-awscloudformation): rebase code and fixed yaml template load (#7518) rebase code from latest updates and fixed yaml template load * fix: check for undefined permissions when removing dependent permissions (#7594) * fix: check for undefined permissions when removing dependent permissions * fix(amplify-appsync-simulator): string functions not called on items … (#7636) * fix(amplify-appsync-simulator): string functions not called on items of JavaArray<string> in the resolvers * feat(amplify-appsync-simulator): added toJavaString that accepts a string and returns a JavaString * feat(amplify-appsync-simulator): map.keySet returns an a JavaArray with elements of type JavaString * feat(amplify-appsync-simulator): using this.mapper in map.keySet * docs(cli): add 'future' to post-'amplify pull' success message for clarity (#7647) change `Run 'amplify pull' to sync upstream changes.` -> `Run 'amplify pull' to sync future upstream changes.` as desired in #5202 re #5202 Co-authored-by: Stuti Prasad <43947328+studpeps@users.noreply.github.com> * Create: BatchSize and MaximumBatchingWindow parameters, V2 streaming lambda (#7651) * fix: Move credential validation to the top function call getProfileCredentials isn't always pulling from a file with an access key/secret key, so validation can error out in the case of source profiles. Moving this to the top function getProfiledAwsConfig and performing the validation on the AWS config instead means we can accommodate source profiles. * Change: Make batch size parameterized on streaming * Change: batch size and batching window duration are parameters * Change: Decrease searchable streaming MaximumBatchingWindow to 1 second Co-authored-by: Vandenberg <mvanden@88665a1e266e.ant.amazon.com> * fix: show friendly error message when pull fails with EPERM (#7653) * fix: show friendly error message when pull fails with EPERM fix #7448 Co-authored-by: Colin Ihrig <cjihrig@gmail.com> * fix(amplify-category-auth): \n made OS specific (#7663) * style:removed extra whitespaces and standardized tabs in auth-templates * fix(amplify-category-auth): fixed newline escape sequence to be os specific fix #7662 * fix: add/update function when some LL are not yet migrated (#7674) * fix: add/update function when some LL are not yet migrated * ci: add support for automatic tagged release (#7691) Do an automatic tagged NPM release when a branch name is prefixed with tagged-release/ * fix: #7441 - init from git prompts for credentials twice (#7682) * chore: update yarn.lock file (#7644) Co-authored-by: Colin Ihrig <colihrig@amazon.com> * test(amplify-console-integration-tests): update the add environment fn ref pr#7098 (#7719) * fix: checkout into existing env with new LL (#7687) * fix: checkout into existing env with new LL * test: update lambda function for auth schema tests, add optional types to LayerOptions, fix typos (#7728) * fix(amplify-category-auth): added passrole policy to MFALambaRole (#7729) Added policy with action iam:PassRole for MFALambdaRole * chore(release): Publish [ci skip] - amplify-app@3.0.4 - amplify-appsync-simulator@1.27.3 - amplify-category-analytics@2.21.13 - amplify-category-api@2.31.15 - amplify-category-auth@2.35.1 - amplify-category-function@2.33.1 - amplify-category-hosting@2.7.13 - amplify-category-notifications@2.19.4 - amplify-category-predictions@2.9.4 - amplify-category-storage@2.12.1 - amplify-category-xr@2.8.13 - amplify-cli-core@1.24.1 - @aws-amplify/cli@5.1.2 - amplify-console-hosting@1.9.4 - amplify-console-integration-tests@1.8.1 - amplify-container-hosting@1.3.15 - amplify-dotnet-function-template-provider@1.5.13 - amplify-dynamodb-simulator@1.19.4 - amplify-e2e-core@1.23.1 - amplify-e2e-tests@2.45.1 - amplify-frontend-ios@2.20.6 - amplify-frontend-javascript@2.23.1 - amplify-go-function-runtime-provider@1.8.7 - @aws-amplify/graphql-function-transformer@0.3.6 - @aws-amplify/graphql-http-transformer@0.4.2 - @aws-amplify/graphql-model-transformer@0.4.5 - @aws-amplify/graphql-predictions-transformer@0.2.1 - @aws-amplify/graphql-searchable-transformer@0.3.1 - @aws-amplify/graphql-transformer-core@0.7.1 - amplify-java-function-runtime-provider@1.8.6 - amplify-migration-tests@3.1.1 - amplify-nodejs-function-runtime-provider@1.6.3 - amplify-nodejs-function-template-provider@1.6.13 - amplify-provider-awscloudformation@4.55.1 - amplify-python-function-runtime-provider@1.9.3 - amplify-util-import@1.5.4 - amplify-util-mock@3.33.5 - graphql-auth-transformer@6.24.14 - graphql-connection-transformer@4.21.14 - graphql-dynamodb-transformer@6.22.14 - graphql-elasticsearch-transformer@4.11.14 - graphql-function-transformer@2.5.13 - graphql-http-transformer@4.18.1 - graphql-key-transformer@2.23.14 - graphql-predictions-transformer@2.5.13 - graphql-relational-schema-transformer@2.18.2 - graphql-transformer-common@4.19.5 - graphql-transformer-core@6.28.13 - graphql-transformers-e2e-tests@6.24.4 - graphql-versioned-transformer@4.17.14 * Fix typos in Cognito triggers (#7745) * test(cli): add test for resource-status extensions (#7744) * feat(cli): amplify folder deletes regardless of presence in the cloud (#7740) `amplify delete` now deletes the local `amplify` folder even if the project has been deleted in the cloud. close #7631 * bug(amplify-cli):resource-test file location issue resolved (#7712) * bug(amplify-cli):resource-test file location issue resolved * Changed to '' for standard practice * style(amplify-cli): Moved path import to top of the file * fix: upgrade node default runtime to 14 (#7700) * fix: upgrade node runtime to 14 As we approach the EOL for node 12 security updates new lambdas should be ideally be on node 14 * test: set nodejs14 as the detault * Category graphql/searchable enum filter (#7683) * feat(cli): searchable enum generates string filterinput * feat(cli): searchable enum generates string filterinput * remove unwanted imports * remove unwanted imports * set improvePluralization default value to true * chore: upgrade yarn packages recommended by dependabot (#7670) * ci: add support for e2e token rotation (#7665) * ci: add support for e2e token rotation Currently we use long-lived, manually generated access tokens to set up AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables allowing our tests to run. This is a bad practice - authorization tokens should be automatically rotated to minimize risk of the tokens landing in the wrong hands. This PR sets up the Amplify CLI codebase to use temporary credentials during CI. Temporary STS credentials use an additional parameter, AWS_SESSION_TOKEN, to authorize the requests. This has been tested in CI on my fork and all tests pass: https://app.circleci.com/pipelines/github/johnpc/amplify-cli/144/workflows/fb12f075-d881-4c92-8cf7-f8647afb909e The token rotator itself is a lambda that runs every hour: https://github.com/johnpc/amplify-e2e-token-rotation-lambda * chore: use ini lib instead of manually updating file * chore: update injectSessionToken calls * Feature/rds utils (#7650) * fix(amplify-appsync-simulator): string functions not called on items of JavaArray<string> in the resolvers * feat(amplify-appsync-simulator): add support for rdsUtils.toJsonString * feat(amplify-appsync-simulator): added toJavaString that accepts a string and returns a JavaString * feat(amplify-appsync-simulator): map.keySet returns an a JavaArray with elements of type JavaString * feat(amplify-appsync-simulator): map.keySet returns an a JavaArray with elements of type JavaString * feat(amplify-appsync-simulator): using this.mapper in map.keySet * feat(amplify-appsync-simulator): cleanup * Revert "chore: upgrade yarn packages recommended by dependabot (#7670)" (#7758) This reverts commit 6d16146. * feat: add @aws_lambda to GQL transformer pass through directive list (#7757) Updated GraphQL transformer to pass through @aws_lambda directive to output schema * fix: disable layer version removal if fn depends on pinned version (#7627) * fix: disable layer version removal when lambda fn depends on pinned version * test(amplify-category-function): update remove walkthrough unit tests * test(amplify-category-function): update amplify-meta mock value * fix: display all dependent lambda fn in message * test: add e2e test to verify dependency check * fix(cli): use more explicit amplify pragma in .gitignore (#7568) * fix(cli): use more explicit amplify pragma in .gitignore Previously, we used the #amplify pragma to show which block of .gitignore was managed by amplify. This causes confusion for customers who think it is safe to add or remove lines this section of their gitignore. The cli will blitz any changes to this section on amplify init or amplify pull. By using a more explicit pragma, customers will realize they should not touch this section of the gitignore. fix #7250 * test(cli): add coverage of legacy case * chore: address nits * chore: s/removeAmplifyIgnore/rebuildAmplifyIgnore * fix(graphql-searchable-transformer): fix for awstimestamp issues with elastic search (#7534) * feat(graphql-searchable-transformer): fix _lastChangedAt type for version control * feat(graphql-searchable-transformer): more generic fix for all epoch fields * fix(graphql-searchable-transformer): prevent int cast from truncating decimals if they exist * feat(graphql-searchable-transformer): changed fix to use is_integer() * Revert "ci: add support for e2e token rotation (#7665)" (#7759) This reverts commit 57c0a03. Co-authored-by: Ammar <56042290+ammarkarachi@users.noreply.github.com> * Revert "fix: upgrade node default runtime to 14 (#7700)" (#7763) This reverts commit 47968cc. * Revert "Revert "ci: add support for e2e token rotation (#7665)" (#7759)" (#7762) This reverts commit aadc915. * test(amplify-console-integration-tests): handle no session token * feat(amplify-category-function): skip unnecessary prompt for 'amplify update function' * feat(amplify-category-function): skip unnecessary prompt for 'amplify update function' * test: remove additional prompt from e2e * feat(amplify-category-auth): enable alternative signup/signin options (#7461) * feat(amplify-category-auth): enable alternative signup/signin options this commit mirrors the options presented to users when creating a cognito user pool in the aws console. alternative sign in options allow developers to create a coginito user that can sign in using their preferred username, phone number, or email address. re #1546 * feat(amplify-category-auth): add autoVerifiedAttributes for aliasAttributes * chore(amplify-headless-interface): update schema * chore(amplify-category-auth): get aliasAttributes _instead_ of signInOptions * chore: use constants instead of magic strings * fix(cli): prevent re-prompt of info on `amplify pull` (#7730) * fix(cli): prevent re-prompt of info on `amplify pull` When the developer runs `amplify pull` and chooses "no" when prompted: "Do you plan on modifying this backend?", the cli should not prompt for all the project configuration settings when `amplify pull` is called again to receive updates. Since the entire `amplify/` dir is removed when this option is selected, we lose project configuration context. This change keeps the `amplify/` dir around, only deleting the backend directories, and maintains the state of the project configuration. * chore: use more explicit names * test: add integ test * test: remove extra push * fix(cli): make delete clean local project if already deleted in cloud (#7551) this commit adds NotFoundException handling to the `amplify delete` operation. If cloud resources are not found, then that part of the delete must already be done, so we should move on and continue deletion. fix #7515 * test(amplify-e2e-tests): remove unneeded deleteProject call (#7769) * chore(amplify-category-auth): use constants instead of magic strings (#7770) * chore: remove stalebot config (#7768) * test(amplify-category-auth): use AttributeType enum in test (#7773) * bug(amplify-cli):Solved Windows compatibility issue, made location pa… (#7710) * bug(amplify-cli):Solved Windows compatibility issue, made location paths os-specific * Removed resource-test updation * bug(amplify-cli):added addSnapshotSerializer functionality * Updating "" to '' for standardization Co-authored-by: Colin Ihrig <cjihrig@gmail.com> * Fixed indentation * fix(amplify-cli):Moved function to seperate file * bug(amplify-cli):Created an object for addSnapshotSerializer() * Fixed spaces in path.join() * bug(amplify-cli):test function added to snapshot-serializer * Removed extra space in .json file Co-authored-by: Colin Ihrig <cjihrig@gmail.com> * fix(amplify-category-auth): add handling for undefined autoVerifiedAttributes (#7780) * test(amplify-e2e-tests): assume function and layer lambdas are not being tested simultaneously (#7782) * test(amplify-e2e-tests): add layerAndFunctionExist param to trigger capability selection (#7784) * feat(amplify-category-auth): use EnabledMFAs to only configure TOTP (#7779) * feat(amplify-category-auth): use EnabledMFAs to only configure TOTP * fix(amplify-category-auth): creation of SNS role only when phone no is configured * refactor(amplify-e2e-tests): address PR comments * Revert "feat(amplify-category-auth): use EnabledMFAs to only configure TOTP (#7779)" (#7790) This reverts commit c2102c5. * build: fix typo in publish script (#7788) * test: turn off e2e test coverage, enable and fix import test (#7776) * chore(release): Publish [ci skip] - amplify-app@3.0.5 - amplify-appsync-simulator@1.27.4 - amplify-category-analytics@2.21.14 - amplify-category-api@2.31.16 - amplify-category-auth@2.36.0 - amplify-category-function@2.34.0 - amplify-category-hosting@2.7.14 - amplify-category-predictions@2.9.5 - amplify-category-storage@2.12.2 - amplify-category-xr@2.8.14 - amplify-cli-core@1.25.0 - @aws-amplify/cli@5.2.0 - amplify-console-hosting@1.9.5 - amplify-console-integration-tests@1.8.2 - amplify-container-hosting@1.3.16 - amplify-dotnet-function-template-provider@1.5.14 - amplify-dynamodb-simulator@1.19.5 - amplify-e2e-core@1.24.0 - amplify-e2e-tests@2.46.0 - amplify-frontend-ios@2.20.7 - amplify-frontend-javascript@2.23.2 - amplify-go-function-runtime-provider@1.8.8 - @aws-amplify/graphql-function-transformer@0.3.7 - @aws-amplify/graphql-http-transformer@0.4.3 - @aws-amplify/graphql-model-transformer@0.4.6 - @aws-amplify/graphql-predictions-transformer@0.2.2 - @aws-amplify/graphql-searchable-transformer@0.3.2 - @aws-amplify/graphql-transformer-core@0.7.2 - amplify-headless-interface@1.9.0 - amplify-java-function-runtime-provider@1.8.7 - amplify-migration-tests@3.1.2 - amplify-nodejs-function-runtime-provider@1.6.4 - amplify-nodejs-function-template-provider@1.6.14 - amplify-provider-awscloudformation@4.55.2 - amplify-python-function-runtime-provider@1.9.4 - amplify-util-headless-input@1.5.2 - amplify-util-import@1.5.5 - amplify-util-mock@3.33.6 - graphql-auth-transformer@6.24.15 - graphql-connection-transformer@4.21.15 - graphql-dynamodb-transformer@6.22.15 - graphql-elasticsearch-transformer@4.11.15 - graphql-function-transformer@2.5.14 - graphql-http-transformer@4.18.2 - graphql-key-transformer@2.23.15 - graphql-predictions-transformer@2.5.14 - graphql-relational-schema-transformer@2.18.3 - graphql-transformer-common@4.19.6 - graphql-transformer-core@6.29.0 - graphql-transformers-e2e-tests@6.24.5 - graphql-versioned-transformer@4.17.15 * feat: add @PrimaryKey directive to Transformer v2 (#7797) * fix: lambda timeout should be an integer type (#7699) * fix: #7696 - support production package install for function category (#7812) * fix: move storage check in @predictions v2 (#7816) @predictions requires that storage is configured. This commit moves the check out of the before() phase, as that is invoked even if @predictions is not used in the schema, leading to unnecessary errors. Co-authored-by: Colin Ihrig <colihrig@amazon.com> * fix(amplify-cli-core): new-line escape sequence made os-specific (#7814) * fix(amplify-graphql-types-generator): path-format to match snapshot (#7800) * chore: fixed typo (#7786) * feat: capability injection for the vNext GraphQL Transformer (#7735) * fix: correct behavior of --yes on push when missing env var (#7826) * chore(release): Publish [ci skip] - amplify-app@3.0.6 - amplify-appsync-simulator@1.27.5 - amplify-category-analytics@2.21.15 - amplify-category-api@2.31.17 - amplify-category-auth@2.36.1 - amplify-category-function@2.34.1 - amplify-category-hosting@2.7.15 - amplify-category-interactions@2.6.3 - amplify-category-predictions@2.9.6 - amplify-category-storage@2.12.3 - amplify-category-xr@2.8.15 - amplify-cli-core@1.25.1 - @aws-amplify/cli@5.2.1 - amplify-console-hosting@1.9.6 - amplify-console-integration-tests@1.8.3 - amplify-container-hosting@1.3.17 - amplify-dotnet-function-runtime-provider@1.6.2 - amplify-dotnet-function-template-provider@1.5.15 - amplify-dynamodb-simulator@1.19.6 - amplify-e2e-core@1.24.1 - amplify-e2e-tests@2.46.1 - amplify-frontend-ios@2.20.8 - amplify-frontend-javascript@2.23.3 - amplify-function-plugin-interface@1.9.1 - amplify-go-function-runtime-provider@1.8.9 - amplify-go-function-template-provider@1.3.10 - @aws-amplify/graphql-function-transformer@0.4.0 - @aws-amplify/graphql-http-transformer@0.5.0 - @aws-amplify/graphql-index-transformer@0.2.0 - @aws-amplify/graphql-model-transformer@0.5.0 - @aws-amplify/graphql-predictions-transformer@0.3.0 - @aws-amplify/graphql-searchable-transformer@0.4.0 - @aws-amplify/graphql-transformer-core@0.8.0 - @aws-amplify/graphql-transformer-interfaces@1.8.0 - amplify-graphql-types-generator@2.8.4 - amplify-java-function-runtime-provider@1.8.8 - amplify-java-function-template-provider@1.5.9 - amplify-migration-tests@3.1.3 - amplify-nodejs-function-runtime-provider@1.6.5 - amplify-nodejs-function-template-provider@1.6.15 - amplify-provider-awscloudformation@4.56.0 - amplify-python-function-runtime-provider@1.9.5 - amplify-python-function-template-provider@1.3.12 - amplify-util-import@1.5.6 - amplify-util-mock@3.33.7 - graphql-auth-transformer@6.24.16 - graphql-connection-transformer@4.21.16 - graphql-dynamodb-transformer@6.22.16 - graphql-elasticsearch-transformer@4.11.16 - graphql-function-transformer@2.5.15 - graphql-http-transformer@4.18.3 - graphql-key-transformer@2.23.16 - graphql-predictions-transformer@2.5.15 - graphql-transformer-core@6.29.1 - graphql-transformers-e2e-tests@6.24.6 - graphql-versioned-transformer@4.17.16 * test: improve schema validation in tests (#7845) This commit exposes the validateModelSchema() function from the GraphQL Transformer core. This function is helpful for validating the Transformer output schema's correctness. This commit also applies the validation to @predictions v2 test suite. Co-authored-by: Colin Ihrig <colihrig@amazon.com> * fix: add DDB params to model v2 (#7827) This commit updates @model in GraphQL Transformer v2 to create the DynamoDB related CloudFormation parameters and conditions. Co-authored-by: Colin Ihrig <colihrig@amazon.com> * feat: make cognito userpool id optional for headless mode (#7820) * chore: update lerna and chalk dependencies, remove unused chalk-pipe (#7823) * feat(amplify-util-mock): support pseudo parameters in environment variables when running `amplify mock function` (#7804) * fix(amplify-category-auth): add auth user selections to aws-exports/amplifyconfiguration files (#7807) * fix(graphql-auth-transformer): extend isOptional subscription owner check (#7765) * fix: misc @model v2 VTL cleanup (#7856) @model v2 was generating incorrect VTL in a large number of cases. This commit fixes many of the cases found while working on the @Index directive. It also moves some repeated code blocks into functions. Co-authored-by: Colin Ihrig <colihrig@amazon.com> * fix: use improved pluralization in graphql transformer v2 (#7817) This commit updates GraphQL Transformer v2 to use the newly improved pluralization rules by default. Co-authored-by: Colin Ihrig <colihrig@amazon.com> * fix: multi-env container hosting (#7009) (#7346) * fix: #7009 - Bug Fix for Multi-Env Container Hosting * Update packages/amplify-cli/src/initialize-env.ts Co-authored-by: John Hockett <jhockett@users.noreply.github.com> * fix: multi-Env container hosting - format fixed * Update to use hosting key from TPI * add domain and restrictAccess to the template * fix lint errors * fix lint errors * add allowed values for restrictAccess * added tests for container based testing * update tests Co-authored-by: John Hockett <jhockett@users.noreply.github.com> * Category graphql/searchable aggregate functions (#7764) * feat(graphql-searchable): Aggregate support * added enum type for aggregate type * updated aggregate types to lowercase * correct lint fix * remove unused comments * remove unwanted comments * updated test snapshots * update tests to include aggregate * created new function for v2 searchTemplate * organize imports * Update packages/amplify-graphql-searchable-transformer/src/definitions.ts Co-authored-by: Colin Ihrig <cjihrig@gmail.com> * added e2e tests for aggregates * remove unused imports * update error handling Co-authored-by: Colin Ihrig <cjihrig@gmail.com> * test(graphql-model-transformer): graphql model transformer tests (#7836) * Add .circleci/config.yml * test: ported @model v1 test suite to v2 * chore(graphql-model-transformer): removed improvePluralization check, V2 uses improvePluralization * chore(graphql-model-transformer): added parse() to tests that generate a valid schema * test(graphql-model-transformer): added validateModelSchema check to existing model v2 tests * feat: create new amplify-prompts package to handle all terminal interactions (#7774) * feat: working on prompts package * feat: add list picker methods * feat: autocomplete for all pick types * feat: fancy types * test: restructure interface a bit and scaffold unit tests * test: adding a bunch of tests * chore: mark deprecated methods / functions * chore: adding some comments * Update packages/amplify-prompts/src/__tests__/prompter.test.ts Co-authored-by: John Hockett <jhockett@users.noreply.github.com> * chore: rename multiselect => multiSelect * feat: better support for --yes and support input list * fix: use EOL as line ending Co-authored-by: John Hockett <jhockett@users.noreply.github.com> * test(amplify-e2e-tests): add force push e2e with no change to functions and api (#7847) * fix(graphql-model-transformer): model input fields transform (#7857) * Add .circleci/config.yml * test: ported @model v1 test suite to v2 * chore(graphql-model-transformer): removed improvePluralization check, V2 uses improvePluralization * chore(graphql-model-transformer): added parse() to tests that generate a valid schema * test(graphql-model-transformer): added validateModelSchema check to existing model v2 tests * fix(graphql-model-transformer): fixed @model transform input object fields type Converted fields of input type objects to also be of input type. Small typo fixes. * Add .circleci/config.yml * Add .circleci/config.yml * chore(graphql-model-transformer): removed test for deprecated @model feature flag * chore(amplify-provider-awscloudformation): reduce log level (#7864) since cfn-lint is deprecated, it does not always proper validate cloudformation. we've made validation errors non-blocking already in [#7132](#7132). This commit also addresses the log level so as not to confuse customers with a red error message. #7831 * fix(amplify-category-function): Storage env vars not added to lambda function (#7785) * fix(7718) Storage env vars not added to lambda function * unit-tests Co-authored-by: Sachin Panemangalore <sachinrp@amazon.com> * chore: rename master -> main branch (#7811) * fix(amplify-frontend-ios): amplify-xcode, add files to primary target (#7738) * fix: improve size checks before packaging Lambda resources (#7756) * fix: improve size checks before packaging Lambda resources * refactor: move folderSize to utils function, add limit const * refactor: call getFolderSize with array of paths * refactor: remove unused path import * fix: lint ignore (#7871) * test: fix test line trim (#7872) * test: force chalk colors in test in CCI (#7875) * Revert "chore: rename master -> main branch (#7811)" (#7868) This reverts commit 9c4cd82. * test(amplify-e2e-tests): fix casing for api name (#7885) * fix: fiux e2e tests by passing categoryName for the resource (#7886) * fix(container-hosting): e2e test fix (#7889) * Revert "fix(container-hosting): e2e test fix (#7889)" (#7894) This reverts commit f9d7983. * fix(container-hosting): ignore test cases (#7895) * fix(container-hosting): ignore test cases * used it.skip instead of comments * used it.skip instead of comments * chore(release): Publish [ci skip] - amplify-app@3.0.7 - amplify-appsync-simulator@1.27.6 - amplify-category-analytics@2.21.16 - amplify-category-api@2.31.18 - amplify-category-auth@2.36.2 - amplify-category-function@2.34.2 - amplify-category-hosting@2.7.16 - amplify-category-predictions@2.9.7 - amplify-category-storage@2.12.4 - amplify-category-xr@2.8.16 - amplify-cli-core@1.26.0 - @aws-amplify/cli@5.3.0 - amplify-codegen-appsync-model-plugin@1.22.4 - amplify-console-hosting@1.9.7 - amplify-console-integration-tests@1.8.4 - amplify-container-hosting@1.3.18 - amplify-dotnet-function-template-provider@1.5.16 - amplify-dynamodb-simulator@1.19.7 - amplify-e2e-core@1.24.2 - amplify-e2e-tests@2.46.2 - amplify-frontend-android@2.15.4 - amplify-frontend-flutter@0.4.4 - amplify-frontend-ios@2.20.9 - amplify-frontend-javascript@2.23.4 - amplify-go-function-runtime-provider@1.8.10 - @aws-amplify/graphql-function-transformer@0.4.1 - @aws-amplify/graphql-http-transformer@0.5.1 - @aws-amplify/graphql-index-transformer@0.2.1 - @aws-amplify/graphql-model-transformer@0.5.1 - @aws-amplify/graphql-predictions-transformer@0.3.1 - @aws-amplify/graphql-searchable-transformer@0.4.1 - @aws-amplify/graphql-transformer-core@0.8.1 - @aws-amplify/graphql-transformer-interfaces@1.8.1 - amplify-headless-interface@1.10.0 - amplify-java-function-runtime-provider@1.8.9 - amplify-migration-tests@3.1.4 - amplify-nodejs-function-runtime-provider@1.6.6 - amplify-nodejs-function-template-provider@1.6.16 - amplify-prompts@1.1.0 - amplify-provider-awscloudformation@4.56.1 - amplify-python-function-runtime-provider@1.9.6 - amplify-util-headless-input@1.5.3 - amplify-util-import@1.5.7 - amplify-util-mock@3.34.0 - graphql-auth-transformer@6.24.17 - graphql-connection-transformer@4.21.17 - graphql-dynamodb-transformer@6.22.17 - graphql-elasticsearch-transformer@4.11.17 - graphql-function-transformer@2.5.16 - graphql-http-transformer@4.18.4 - graphql-key-transformer@2.23.17 - graphql-mapping-template@4.18.2 - graphql-predictions-transformer@2.5.16 - graphql-relational-schema-transformer@2.18.4 - graphql-transformer-common@4.19.7 - graphql-transformer-core@6.29.2 - graphql-transformers-e2e-tests@6.24.7 - graphql-versioned-transformer@4.17.17 * feat: add @Index directive (#7887) * feat: add @Index directive * fix(graphql-model-transformer): fixed input type field generation for enum types * fix: update @searchable v2 snapshot * fix: address lgtm bot messages * fix: update deps after latest release Co-authored-by: Colin Ihrig <colihrig@amazon.com> Co-authored-by: lazpavel <85319655+lazpavel@users.noreply.github.com> * Feature/amplify enhanced status (#7698) * enhanced amplify status * help and test * show summary view on amplify push * Fixed s3 * unit test for showStatusTable * fixed ViewResourceTableParams * Converted cloudformation file-path to use Glob * cleanup and headers * 1. removed custom yaml handling and used library code. 2. Used readCFNTemplate to load templates. 3. Cleaned up unused code * addressed PR comments * Added types to template, diff * addressed more PR comments * updated unit test coverage and fixed test errors * fix multi-env diffs for new resources * 1. category filters for summary. 2. removed spacing between categories in detail-view. 3. updated help for summary. 4. added case normalization for options * updated help to indicate summary filters * Update Readme.md Added category filters for summary table * fixed unit tests and merge errors * Update Readme.md fixed case * Update packages/amplify-cli-core/src/cliViewAPI.ts Co-authored-by: akshbhu <39866697+akshbhu@users.noreply.github.com> * Update packages/amplify-cli/src/extensions/amplify-helpers/resource-status-view.ts Co-authored-by: akshbhu <39866697+akshbhu@users.noreply.github.com> * addressed CR comments * lgtm:fix:removed unused variable * unit-tests for cliViewAPI * removed styling from help test * unit-test for detailed cloudformation-diff for one resource Co-authored-by: Sachin Panemangalore <sachinrp@amazon.com> Co-authored-by: akshbhu <39866697+akshbhu@users.noreply.github.com> * chore(amplify-category-auth): updated login mechanisms label (#7878) * fix(graphql-model-transformer): fixed input type field generation for enum types (#7879) * fix(graphql-model-transformer): added @model name reserved words validation (#7877) * fix(graphql-model-transformer): added @model name reserved words validation * fix(graphql-model-transformer): added @model name reserved words validation * Update packages/amplify-graphql-model-transformer/src/__tests__/model-transformer.test.ts Co-authored-by: Colin Ihrig <cjihrig@gmail.com> Co-authored-by: Colin Ihrig <cjihrig@gmail.com> * Rename elasticsearch to @searchable & opensearch in v2 transformer (#7775) * refactor(graphql-searchable-transformer): change Elasticsearch refs to @searchable and OpenSearch * refactor(graphql-transformer-core): change Elasticsearch refs to @searchable and OpenSearch * refactor(graphql-transformer-interfaces): change Elasticsearch refs to @searchable and OpenSearch * refactor(graphql-model-transformer): change Elasticsearch refs to @searchable and OpenSearch * refactor(graphql-mapping-template): add OpenSearch template that extends from Elasticsearch * refactor(graphql-mapping-template): create Searchable template and extend for Elasticsearch template * refactor(graphql-searchable-transformer): use Searchable mapping template * refactor(graphql-searchable-transformer): update additional refs to Elasticsearch in python script * refactor(graphql-transformer-common): add OpenSearch to resource constants file * refactor(graphql-searchable-transformer): swap out Elasticsearch constants with OpenSearch * refactor(graphql-transformer-core): fix typo * refactor(graphql-transformer-core): change AMAZON_OPENSEARCH back to AMAZON_ELASTICSEARCH * refactor(graphql-searchable-transformer): change AMAZON_OPENSEARCH back to AMAZON_ELASTICSEARCH * refactor(graphql-transformer-interfaces): change AMAZON_OPENSEARCH back to AMAZON_ELASTICSEARCH * Update packages/amplify-graphql-searchable-transformer/streaming-lambda/python_streaming_function.py Co-authored-by: Colin Ihrig <cjihrig@gmail.com> * refactor(graphql-transformer-core): fix rebase * refactor(graphql-searchable-transformer): change ES_ env vars to OPENSEARCH_ * refactor(graphql-transformer-core): rename elastic search to searchble in code comments Co-authored-by: Colin Ihrig <cjihrig@gmail.com> * build(deps): bump tar from 4.4.13 to 4.4.15 (#7867) Bumps [tar](https://github.com/npm/node-tar) from 4.4.13 to 4.4.15. - [Release notes](https://github.com/npm/node-tar/releases) - [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md) - [Commits](isaacs/node-tar@v4.4.13...v4.4.15) --- updated-dependencies: - dependency-name: tar dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: add deprecated tag to context.print (#7911) * chore: mark context print deprecated * chore: remove test prompts from demo * feat(amplify-go-function-runtime-provider): add support for go1.16, install deps before build (#7617) * fix(amplify-category-function): fixed issue for removing function env variable (#7917) cloudformation-template.json file has the env variable in camel case format, so env variable deletion should look for camel case version of the variable name fix #7777 * fix: added await to init invocation (#7919) * test: fix e2e and unit test failures related to status changes (#7936) * test: fix auth e2e expect text (#7944) * chore: add aws-cdk dep in amplify-cli (#7951) * chore: add uuid in amplify-cli deps (#7955) * fix: specify default auth role name on import auth (#7921) * feat: model transformer advanced subscriptions (#7927) * test: fix flaky add auth test (#7969) * fix(amplify-category-auth): fixed no parameter when hostedui is not present (#7914) * chore: add missing dependency, fix cdk version (#7980) * chore: revert awscdk to 1.118.0, upgrade pkg to latest (#7983) * feat: amplify add override root command and skeleton generation (#7684) * feat: amplify add override root command and skeleton generation * feat: build and package overrides directory * test: add unit tests * fix: updates with PR comments * test: fix unit tests Co-authored-by: Ghosh <kaustavg@3c22fb229ff6.ant.amazon.com> * chore: publish ext branch as a tag (#7689) Co-authored-by: Ghosh <kaustavg@3c22fb229ff6.ant.amazon.com> * test: cci publish for ext branch * test: pubish ext branch to npm * feat: add helper util package for overrides (#7726) * feat: add helper util package for overrides * fix: remove lib files * fix: add overrides helper lib to gitignore * fix: namespace overrides package * fix: fix eslint errors in lib/ files Co-authored-by: Ghosh <kaustavg@3c22fb229ff6.ant.amazon.com> * chore(release): Publish [ci skip] - @aws-amplify/cli-overrides-helper@1.1.0-ext.0 * feat: Override functionality enabled for Root stack (#7702) * feat: initial commit * feat: root stack creation on init with cdk * feat: enable for push * feat: added build command for root stack override * fix: authrole and Unauthrole Names * feat: added synthesizer and address comments * feat: added hash for root stack * feat: deploy root stack to disk * feat: updated amplifyMeta after root override * feat: update curren-cloud-backend * feat: refractor Root transform and added unit tests * fix: removes Template from Cloudform * feat: added build step in overrides * fix: unit tests Co-authored-by: David Lopez <letsbelopez@gmail.com> Co-authored-by: David Lopez <lopezbnd@amazon.com> Co-authored-by: aws-amplify-bot <aws@amazon.com> Co-authored-by: C. Lewis <1657236+ctjlewis@users.noreply.github.com> Co-authored-by: Colin Ihrig <colihrig@amazon.com> Co-authored-by: Gita Alekhya Paul <54375111+gitaalekhyapaul@users.noreply.github.com> Co-authored-by: John Corser <john@johncorser.com> Co-authored-by: Rafael M. Koike <koiker@users.noreply.github.com> Co-authored-by: Mohammed Ali Chherawalla <mohammed.ali.chherawalla@gmail.com> Co-authored-by: Bentheburrito <33915719+Bentheburrito@users.noreply.github.com> Co-authored-by: Stuti Prasad <43947328+studpeps@users.noreply.github.com> Co-authored-by: Marc VandenBerg <marc.vandenberg1@gmail.com> Co-authored-by: Vandenberg <mvanden@88665a1e266e.ant.amazon.com> Co-authored-by: Yathi <511386+yuth@users.noreply.github.com> Co-authored-by: Colin Ihrig <cjihrig@gmail.com> Co-authored-by: John Hockett <jhockett@users.noreply.github.com> Co-authored-by: Attila Hajdrik <hajdrik@amazon.com> Co-authored-by: Josue Ruiz <josurui@amazon.com> Co-authored-by: Ammar <56042290+ammarkarachi@users.noreply.github.com> Co-authored-by: Luke Seemann <luke.seemann@vokal.io> Co-authored-by: MURAKAMI Masahiko <m-murakami@esm.co.jp> Co-authored-by: Michael Brewer <michael.brewer@gyft.com> Co-authored-by: Christopher Sundersingh <83315412+sundersc@users.noreply.github.com> Co-authored-by: John Corser <johnpc@umich.edu> Co-authored-by: jcbdev <james@jcbdevelopment.co.uk> Co-authored-by: josef <josef.aidt@gmail.com> Co-authored-by: Yoshiaki Togami <62130798+togami2864@users.noreply.github.com> Co-authored-by: Edward Foyle <foyleef@amazon.com> Co-authored-by: Sam Patzer <wizagesmax@gmail.com> Co-authored-by: lazpavel <85319655+lazpavel@users.noreply.github.com> Co-authored-by: Josue Ruiz <7465495+SwaySway@users.noreply.github.com> Co-authored-by: Sachin Panemangalore <83682223+sachscode@users.noreply.github.com> Co-authored-by: Sachin Panemangalore <sachinrp@amazon.com> Co-authored-by: Diego Costantino <diegoco@amazon.com> Co-authored-by: Danielle Adams <6271256+danielleadams@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jainam Shah <jainam.2000@yahoo.com> Co-authored-by: Kaustav Ghosh <kaustav.ghosh19@gmail.com> Co-authored-by: Ghosh <kaustavg@3c22fb229ff6.ant.amazon.com>
When using the "Add User to Group" functionality with
amplify add auth
, the sign-up process would throw 400 ("Invalid JSON") at the PostConfirmation Lambda, where the user was to be added to a given group (see #7179).After working on this for a day or two and speaking with @edwardfoyle, it seemed there were two issues here:
The triggers (
index-trigger.js
in varioustemplate-dir/
directories) did not support async/await, which resulted in conflicts because many of these Lambdas used async/await syntax.The top-level Lambda function in
index-trigger.js
, which loads various modules in the same directory (./verification-link.js
), was not returning anything, which was what appears to actually have been causing the "Invalid JSON" error, as CloudFormation expects a response from async handlers. Sadly, this was present across all of the top-level auth CloudFormation triggers, which would imply that anyamplify add auth
stack with more than one "advanced feature" enabled would be broken by default. This appears to have been an issue for some time.This PR addresses both issues. All of the hardcoded
index-trigger.js
files were manually overwritten to use the updated source, and return theevent
that triggered them.The auth templates were refactored to remove redundant copies of templates which contributed to this issue (see below).
This issue causes runtime failures in Lambda for any user who enables more than one "advanced feature" in the Amplify CLI ("Add User to Group", etc.).
Description of changes
Before, each template directory had the same
trigger-index.js
copy-pasted into it. It had been edited in a few places to use the async handler format, and this inconsistency is what is causing this/these errors.Now, there is a
_default
template, and if it is not overridden in the given template, it will pull from the default, meaning there will no longer be redundant/inconsistent copies oftrigger-index.js
, and they will all follow the async handler format.Issue #, if available
See PR #7180
Closes #7179, closes #4341, #2735 (closed)
Description of how you validated changes
I created ctjlewis/amplify-dev to test the CLI for now; the relevant branch for this issue is @cloudformation-trigger.
The
amplify/
directory was deleted, and then the updatedamplify-dev
used to add the Verification Link and Add User to Group features, pushed withamplify push
, and worked as expected out-of-the-box; this can be found on the @cloudformation-triggers-patched branch. I plan to enable all other "advanced features" for auth withamplify update auth
to test that their updated templates also work as expected.Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.