aws-amplify / aws-amplify/amplify-hosting

AMPLIFY_DIFF_BACKEND does not work

Open
#2,921 9 comments 0 reactions 0 assignees View on GitHub
backend-builds
Dominant language
Dockerfile
Stars
481
Forks
123
PR merge metrics
No merged PRs in 30d

Description

### Before opening, please confirm:

- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-hosting/blob/master/CONTRIBUTING.md).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

### App Id

_No response_

### Region

us-east-1

### Amplify Hosting feature

Backend builds

### Describe the bug

Docs: https://docs.aws.amazon.com/amplify/latest/userguide/build-settings.html#enable-diff-backend

Backend builds even with:
- `AMPLIFY_DIFF_BACKEND` set to `true`.
- No code changes to `amplify` directory.
- With no custom `backend` commands in `amplify.yml` (apart from `amplifyPush --simple`)

**This often adds 4 min unnecessary overhead to builds.**

![image](https://user-images.githubusercontent.com/3676208/183966280-e5e6c928-5d71-4f00-ac00-cfe8ef33fe53.png)

[In this comment](https://github.com/aws-amplify/amplify-hosting/issues/2385#issuecomment-1006392315) it is stated we can use `amplifyPush --simple` command, and it should still work.

But it does not:
![image](https://user-images.githubusercontent.com/3676208/183966194-8c9e737a-297b-4d0d-bfc4-53255d0eed8d.png)

![image](https://user-images.githubusercontent.com/3676208/183967263-8f9aa4bb-45a5-4e96-a764-67126c8d035d.png)

---

[Docs](https://docs.aws.amazon.com/amplify/latest/userguide/build-settings.html#enable-diff-backend) states the following:
> If you currently have custom commands specified in the build settings of your backend phase, conditional backend builds won't work.

However, we require `aws-exports` as it's deployed to a different environment. So we need to use `amplifyPush --simple`.

### Expected behavior

Skip backend builds if no changes to `amplify` dir, without having to give up `aws-exports` functionality.

### Reproduction steps

See above

### Build Settings

```yaml
version: 1
backend:
phases:
build:
commands:
- amplifyPush --simple
frontend:
phases:
preBuild:
commands:
- yarn install
build:
...
```

### Additional information

A simple workaround could be to add `[skip backend]` to commit messages option. Just like how we can add `[skip-cd]`.

Contributor guide

Open the contributing guide

Research direction

Start with the build-settings documentation for AMPLIFY_DIFF_BACKEND and the provided amplify.yml configuration, then reproduce builds with and without changes to the amplify directory while using amplifyPush --simple. Done means backend builds are skipped when appropriate without losing aws-exports functionality, or the supported configuration and limitation are clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
ci-cd, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.