aws-amplify / aws-amplify/amplify-cli
Multi-env layers always updating without changes. Environments hardcoded makes productive working impossible
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### 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](https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-cli/blob/master/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
### 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.
- When switching between environments via `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.
- We are hosting the app on amplify as well and everytime we deploy a new version triggered by a change on GitHub, the backend is building in the amplify deployment workflow again and **updates again all layers**. So **everytime** we push our code to git and amplify deploys it, the backend is due to the automatic layer updates on a different version than our local amplify project. This means if we check the status of the amplify environment with `amplify status` all functions with layers and the layers itself are on `Update` because local and cloud backends are always different
These 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
1. `git checkout staging`
2. `git merge dev` -> Sometimes this is causing conflicts in git with layer versions even though we didn't made **any** change in the layer config
3. `amplify env checkout staging` -> Now in every layer every `parameters.json` file gets automatically modified with the current timestamp at the `description` property.
4. `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 versions
5. `git 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!**
6. `amplify pull` to get the updated layer versions from the build pipeline again to the local project
7. `git add. && commit -m" fetching new layer versions` -> Committing the new versions
Now 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
- Create new function with `amplify add function`
- Create new layer with `amplify add function`
- Attach the layer to the function `amplify update function`
- Create new env `amplify add env test`
- Switch to the env `amplify env checkout test`
You can see that the environment is hardcoded and was modified automatically by the CLI
- Add hosting in the console for CI/CD
- Push your changes to the cloud
- Wait that the deployment finishes
- Check the status with `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 one
### GraphQL schema(s)
```graphql
# Put schemas below this line
```
### Log output
```
# Put your logs below this line
```
### Additional information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.