-
Notifications
You must be signed in to change notification settings - Fork 824
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
Multi-env layers always updating without changes. Environments hardcoded makes productive working impossible #9386
Comments
Hey @chris-mds 👋 thanks for raising this! I have been able to reproduce this behavior, where checking out an Amplify environment will produce updates to the layer's CloudFormation template and updates the layer's Here is a sample diff after switching environments: josefaidt/9386@86a6995 And if we then check out the same environment again we will see changes to the |
Hi @josefaidt, Thank you for your answer. Yes I am always selecting latest layer version. |
Hey @chris-mds thank you for that clarification! Ideally the layer version would not be updated when checking out an existing environment given no changes were made to the layer. For the npm issue, I would recommend updating npm as a part of your buildspec ( version: 1
backend:
phases:
# IMPORTANT - Please verify your build commands
build:
commands:
- npm i -g npm@7
- '# Execute Amplify CLI with the helper script'
- amplifyPush --simple
# ... Marking as a bug 🙂 |
Hi @josefaidt , |
related to #8216 |
Thanks for catching the lambda layer increment. We are sorry that it bothers you. Here's what we found about the issue:
Note: The local command would create a new version and delete all the old versions. It creates a new layer because Amplify CLI detected code change (code). It looks like a design because it would print "Content changes in Lambda layers detected." (code) when it detects layer change, but no matter if there's any layer change, it always create a new layer (code). After more investigation, I found it's because if we create a new folder and
It can not be resolved by a quick fix and need to re-design how we should handle the situation. |
Would be very nice if it would not always redeploy the layer(s) when no change has happened to them. |
I add to @Nxtra comment above. My production deploy are now taking over 30 min so to pass through a staging and pre-live set now takes an hour and a half. This seems crazy for a 1 line change in a single lambda. |
Before opening, please confirm:
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
16.10.0
Amplify CLI Version
7.6.4
What operating system are you using?
Mac
Amplify Categories
function
Amplify Commands
env, pull, push, status, update
Describe the bug
Our plan was to use lambda layers to improve productivity and share code across multiple functions. We are working in an multi-env project, where we are facing a lot of issues with layers.
amplify env checkout xyz
all lambda layer versions are getting updated to new versions with new descriptions/timestamps without any change in the source code from the layer. So when a team member switches from e.g. dev to sandbox1 environment, all layer files are modified and needs to be committed with git, without any change in the code. Because we are using multiple layers tracking all files and check if everything is fine is a lot of work.amplify status
all functions with layers and the layers itself are onUpdate
because local and cloud backends are always differentThese continuous updating layers and git modifications by the amplify cli makes working nearly impossible.
When a team member wants to merge code from e.g. dev to staging the following workflows are necessary
git checkout staging
git merge dev
-> Sometimes this is causing conflicts in git with layer versions even though we didn't made any change in the layer configamplify env checkout staging
-> Now in every layer everyparameters.json
file gets automatically modified with the current timestamp at thedescription
property.amplify push
-> Amplify CLI detects changes in layers, but we didn't make any changes. Next update of the layer. No we are out of sync from local layer versionsgit add . && commit -m "merged from dev in staging" && git push
-> This fires the CD-Pipeline in the amplify console. At the build step amplify is building the backend again and updates again the lambda layers.Now local and cloud layers are completely different versions, but we didn't change anything in there code!
amplify pull
to get the updated layer versions from the build pipeline again to the local projectgit add. && commit -m" fetching new layer versions
-> Committing the new versionsNow if we push it again to the cloud we would began at number 5 again
With this incredible bad developer experience we have to delete all layers and copy the desired code directly into the different lambda functions. This is very time consuming but makes less headache to work with our team than using layers.
Expected behavior
When working with different environments and team members, the environment shouldn't be hardcoded due to changes in git.
Deploying to the cloud should not update all layers again so the local configuration is always wrong after deploying the app.
Deploying to cloud and working on different environments shouldn't trigger any change in git tracked files.
This should only, of course, happen, when we really change the code of the layer and not only the environment without touching the layer
Reproduction steps
amplify add function
amplify add function
amplify update function
amplify add env test
amplify env checkout test
You can see that the environment is hardcoded and was modified automatically by the CLI
amplify status
You can see that the function status is
update
because the CI/CD builded the backend again and updated the layer and is now one version before the local oneGraphQL schema(s)
# Put schemas below this line
Log output
Additional information
No response
The text was updated successfully, but these errors were encountered: