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

Local changes to Admin Query lambda function is overwritten when 'amplify update auth' is run

Open goldbez opened this issue 3 years ago • 2 comments

Before opening, please confirm:

  • [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • [X] I have searched for duplicate or closed issues.
  • [X] I have read the guide for submitting bug reports.
  • [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • [X] I have removed any sensitive information from my code snippets and submission.

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

v14.21.1

Amplify CLI Version

10.5.1

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

I made a change to the Lambda function in app.js under the directory for the Admin Queries API function.

Amplify Categories

auth

Amplify Commands

update

Describe the bug

Amplify auth update' resets the modified function code used by auth module amplify/backend/function/AdminQueriesXXX/src.

Expected behavior

The modified function code should not be reset.

Reproduction steps

  1. Init Amplify project.
  2. Add auth with admin queries as per the documentation
  3. Change code of the function 'amplify/backend/function/AdminQueriesXXX/src'.
  4. update api -> 'amplify update auth'
  5. Change the auth parameters e.g. add user pool groups.
  6. Local code of the function is rewritten with template code. check 'amplify/backend/function/AdminQueriesXXX/src' to confirm that previous code changes are reset.

GraphQL schema(s)

# Put schemas below this line


Project Identifier

No response

Log output

# Put your logs below this line


Additional information

No response

goldbez avatar Dec 01 '22 20:12 goldbez

Hey @goldbez :wave: I was able to reproduce this using the provided details! Marking as a bug 🙂

josefaidt avatar Dec 01 '22 21:12 josefaidt

Adding on to this "amplify update auth" also reset my Cognito related lambda triggers in dangerous ways. E.g. it deleted all the parameters I had set up for them. And in my pre-token generation lambda, I had added a second module called "verify-email" like so: function-parameters.json

  "modules": ["alter-claims", "verify-email"],

parameters.json:

  "modules": "alter-claims,verify-email",

Both files were reset to the initial state, meaning "verify-email" was removed and thus the module not executed any longer.

amplify-cli version 12.8.2

I had noticed this happening before with older amplify cli versions.

For the sake of reproducing this, what I did today was adding "Sign in with Apple" to social providers (before it was set up with Google and Facebook, only): amplify update auth -> Update OAuth social providers

Note that in my case the changes did NOT happen for local changes to those functions. They had already been deployed like that for ages.

hanna-becker avatar Nov 30 '23 19:11 hanna-becker