aws-amplify / aws-amplify/amplify-hosting
Auto-build not working without 'master' branch (when branch created via Terraform or CDK)
- 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-console/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-console/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-console/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
d3syi3v7n8i9kb
### Region
eu-west-1
### Amplify Console feature
Build settings
### Describe the bug
Builds are not triggered when creating a new app/branch through Terraform, also the BitBucket web hook is not triggering a build (but receives a HTTP 202 response) if _the source repository doesn't have a branch named `master`_. After creating a branch with name `master`, everything works as expected.
In Amplify Console App settings|General the _Source repository_ is always shown ending in `src/master`
```
resource "aws_amplify_app" "app" {
name = "***"
repository = "https://bitbucket.org/***"
oauth_token = "***"
iam_service_role_arn = "arn:aws:iam::***:role/amplifyconsole-backend-role"
build_spec = <<-EOT
version: 1
applications:
- frontend:
phases:
preBuild:
commands:
- yarn install
build:
commands:
- yarn run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
EOT
}
resource "aws_amplify_branch" "main" {
app_id = aws_amplify_app.app.id
branch_name = "main"
display_name = "main"
enable_auto_build = true
framework = "React"
stage = "PRODUCTION"
}
```
### Expected behavior
Creating an app/branch through Amplify API works as expected for repos without a `master` branch:
- source repository is shown without branch (or with the correct branch name, in this case `.../src/main`)
- first build is triggered after creating app and branch
- webhook triggers builds
### Reproduction steps
- Create a source repo with default branch set to `main` and no `master` branch.
- Deploy app with TF code mentioned above, log in to Amplify Console
- Check the Source repository setting in App settings|General -> repo ends in `src/master`
- Check builds -> no build started
- Push change to branch, check web hook execution (ok) -> no build triggered
### Build Settings
_No response_
### Additional information
_No response_
Contributor guide
Research direction
Start with the aws_amplify_app and aws_amplify_branch configuration in the reproduction, then compare Terraform-created apps with apps created through the Amplify API. Verify that repositories whose default branch is main are shown with the correct branch, trigger an initial build, and respond to Bitbucket webhook changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, react, terraform
- Domain
- ci-cd, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100