aws-amplify / aws-amplify/amplify-cli

AWS Amplify CLI always shows "update" when JSON files are formatted

Open
#13,442 3 comments 0 reactions 0 assignees View on GitHub
feature-request platform-push
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### How did you install the Amplify CLI?

npm

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

20.9.0

### Amplify CLI Version

12.8.2

### What operating system are you using?

macOS 14.1.1

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

All files not in the .gitignore were formatted using Prettier. This only updates whitespace, line breaks, and indentation. This was using the default Prettier settings with two overrides in the .prettierrc:

```json
{
"singleQuote": true,
"useTabs": true
}
```

### Describe the bug

We use [Prettier](https://prettier.io) in our development process to automatically keep our code formatting consistent. Amplify doesn't seem to behave correctly when backend JSON files are formatted in any way, shape, or form. After an `amplify push`, Amplify updates all of these files to some other format. At this point `amplify status` shows no changes. After formatting these changes with Prettier to bring everything back to the way it was when we pushed, `amplify status` will then show that everything is going to be updated again.

Because of this, every deployment in our CI/CD will update *every* API and Function unnecessarily.

### Expected behavior

Amplify should not require JSON files to be in a certain format. So long as the JSON is valid, it should not modify files in any way—simply just deploy them.

### Reproduction steps

1. Create an empty Amplify project with `amplify init`
2. Add a Lambda with `amplify add function`
3. Format all code with `npx prettier --write .`
5. Deploy with `amplify push`. Notice that the files have been un-formatted.
6. `amplify status` shows no changes
7. Format again with `npx prettier --write .`. Notice that this is exactly how it looked when we pushed earlier.
8. Run `amplify status`. Once again shows that the function will be updated even though nothing has changed on our end.

### Project Identifier

_No response_

### Log output

_No response_

### Additional information

Workarounds for this exist, but are not ideal. Options are
- Require these JSON files to be in the format that Amplify wants *before* they are pushed
- Breaks the uniformity of code styles in the project
- Requires a separate config just for these JSON files
- What is the format?
- Impossible to use tabs instead of spaces
- Push changed files after every `amplify push` to the originating branch
- Not ideal to have your CI/CD making changes directly. It should simply deploy reproducibly and not make any development changes.

If I'm missing something, please let me know. I tried to find a similar issue, but was unable to find anything.

### Before submitting, please confirm:

- [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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.