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

updating custom-policies.json on function doesn't update function

Open joekiller opened this issue 3 years ago • 7 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?

v16.16.0

Amplify CLI Version

9.2.1

What operating system are you using?

Arch Linux

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

No manual changes made

Amplify Categories

function

Amplify Commands

push

Describe the bug

I updated the custom-policies.json and amplify push didn't register the change.

Expected behavior

I expected the custom policy to be applied to the cloudformation.

Reproduction steps

  1. Create a function
  2. Push function
  3. Update custom-policies.json
  4. Push

GraphQL schema(s)

# Put schemas below this line


Project Identifier

No response

Log output

# Put your logs below this line


Additional information

No response

joekiller avatar Aug 18 '22 14:08 joekiller

Hey @joekiller, thank you for reaching out. I tried replicating the lambda function in my Amplify application but was unable to reproduce the issue.

Steps utilized:

  1. Created a NodeJs function
  2. Ran amplify push
  3. updated the custom-polices.json
  4. ran amplify push
  5. observed changes in Lambda function role document

image

image

Could you let us know what runtime was utilized when the lambda function was created?

ykethan avatar Aug 18 '22 21:08 ykethan

By runtime do you mean what lambda runtime? It was a nodejs function. When I encountered this is was somewhat of a revert. So maybe that part is what is missing? Ie maybe try:

  1. Create a NodeJs function
  2. run amplify push
  3. update the custom-polices.json
  4. run amplify push
  5. remove custom-policies.json
  6. run amplify push
  7. add same policy back.
  8. run amplify push and it'll report no changes.

if you cannot replicate after that I guess we can just close this.

joekiller avatar Aug 19 '22 01:08 joekiller

Hey @joekiller, Thank you for the information. On further testing I observed that amplify CLI shows the status as no change when we modify the custom-policies.json when a push is currently occurring.

Reproduction steps:

  1. amplify add function select NodeJs runtime.
  2. amplify push
  3. while the push is occurring update the custom-polices.json
  4. amplify status (this should show as no change)

Thank you for reporting. marking this as bug for further investigation.

ykethan avatar Aug 19 '22 14:08 ykethan

Note for fix: this is likely due to this file not being tracked as a part of the collection used to determine resource state

josefaidt avatar Aug 22 '22 18:08 josefaidt

The workaround to this issue would be to make a small update to the source code (e.g. add a newline to src/index.js) or use --force with amplify push

josefaidt avatar Aug 22 '22 18:08 josefaidt

@josefaidt thanks for noting a workaround. I'll keep it in mind if I find myself in the situation again.

joekiller avatar Aug 22 '22 23:08 joekiller

@josefaidt the workaround is not working for me. I can see that a new function created in the CLI is not creating a CustomLambdaExecutionPolicy entry in the function's generated cloudformation-template.json.

  • Amplify CLI v12.10.3

shgamedev avatar Jun 18 '24 11:06 shgamedev