hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.84k stars 9.19k forks source link

[Bug]: aws_amplify_branch does not set Production branch when the repository is bitbucket #29687

Open machman22 opened 1 year ago

machman22 commented 1 year ago

Terraform Core Version

1.3.0

AWS Provider Version

3.0

Affected Resource(s)

aws_amplify_branch

Expected Behavior

Production branch should be populated with the branch name image

As you can see from the above it is blank

Actual Behavior

As above, the branch name is not populated.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

variable "git_repository_app" {
  description = "Git repository used by the front-end"
  default     = "https://bitbucket.org/xxxxx/frontend"
}

module "amplify" {
  source      = "./modules/amplify"
  name        = local.name
  environment = local.environment

  dns_name_app    = var.dns_name_app
  git_repository  = var.git_repository_app
  git_branch_name = local.git_branch_name

###
}

resource "aws_amplify_branch" "main" {
  app_id      = aws_amplify_app.main.id
  branch_name = var.git_branch_name

  framework = "React"
  stage     = "PRODUCTION"
}

Note this same code works when it is connecting to github

Steps to Reproduce

I'm not sure if this is an issue with AWS Amplify or Terraform. To reproduce

  1. Go to the AWS Amplify console, and manually create a a New app (Host an app)
  2. Connect it to a Bitbucket Repo, but make sure there is no branch called main in the repo
  3. Select a branch from your repository (in this case UAT)
  4. When it creates the new amplify app. Open up the App settings and select General.
  5. You will see my using the AWS Amplify console it does populate the Production branch with UAT
  6. BUT, the Source repository should NOT read https://bitbucket.org/xxxxxx/frontend/src/main, there is NO branch called main. If you click on the hyperlink you get a 404 from Bitbucket, and that's correct. Yet it still managed to populate Production branch with UAT

Now

  1. delete the Amplify App that you just created manually
  2. recreate from Terraform.
  3. When it finishes the apply, open up the AWS Amplify console. You will it display image
    • Production branch is blank, when I know it can be create manually from the console.
    • But note the source repository, there is no main branch. So I suspect Terraform can't find the source repo so it cannot connect the Production branch.

Workaround

Let me know if you need anymore details

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue