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.86k stars 9.2k forks source link

AWS Amplify - Build not triggering when aws_amplify_branch first provisioned #19870

Open mattk-ce opened 3 years ago

mattk-ce commented 3 years ago

Community Note

Affected Resource(s)

aws_amplify_app aws_amplify_branch

Expected Behavior

When specifying enable_auto_build, a build should be triggered when the branch is provisioned.

Actual Behavior

A build is not triggered

nicholasrobertson commented 2 years ago

I run into the same issue when I use the AWS_CLI and need to run a start-job after a create-branch.

aws amplify create-branch --app-id exampleappid --branch-name dev --description dev --stage DEVELOPMENT --framework "Next.js - SSR" --no-enable-notification --enable-auto-build --no-enable-basic-auth --no-enable-performance-mode --ttl 5 --display-name dev --no-enable-pull-request-preview
aws amplify start-job --app-id exampleappid --branch-name dev --job-type RELEASE

I've read through the AWS Go SDK docs and think the following acceptance criteria would work. Forgive me for not doing a pull-request, I'm not a very confident dev so hoping someone will the skills will be able to pick-up.

Given an aws_amplify_branch resource is planned to be created And enable_auto_build is set to true When func (*Amplify) CreateBranch is successful Then func (*Amplify) StartJob is run And AppId equals the aws_amplify_branch's app_id And BranchName equals the aws_amplify_branch's branch_name And JobType equals JobTypeRelease (JobTypeRelease = "RELEASE")

Amplify.StartJob Go SDK

a0s commented 1 year ago

Same here, enable_auto_build=true is not helping

yuyokk commented 1 year ago

Sharing my findings on this issue.

For me root of the issue was that I copy pasted a url from github

Screenshot 2023-06-25 at 19 47 26

in the following format https://github.com/hashicorp/terraform-provider-aws.git (notice .git in the end)

main.tf that does not trigger builds

resource "aws_amplify_app" "example" {
  name        = "example"
  repository = "https://github.com/hashicorp/terraform-provider-aws.git"
}

removing .git from url solved the issue for me.

main.tf that triggers builds

resource "aws_amplify_app" "example" {
  name        = "example"
  repository = "https://github.com/hashicorp/terraform-provider-aws"
}
rameshcreations commented 1 year ago

@yuyokk Thanks. Removing .git helps.

gardiantnikhil commented 8 months ago

enable_auto_build still does nothing on initial creation of the branch (it doesn't trigger a build). Removing .git doesn't help that either.

sakihayashi commented 8 months ago

enable_auto_build still does nothing on initial creation of the branch (it doesn't trigger a build). Removing .git doesn't help that either.

Same here. I tried:

My environment NextJS 13 SSR

Does enable_auto_build mean building the app on terraform apply? It looks some could make it but I do not see why it's not working on my end... Can anyone help with this?

dev-2null commented 8 months ago

enable_auto_build still does nothing on initial creation of the branch (it doesn't trigger a build). Removing .git doesn't help that either.

Same here. I tried:

  • Admin access for IAM so the policy is "Action": "*" which should allow anything but no luck. It says it is stuck 'your build is queued'.
  • I use the URL without git.
  • If I push a change to the branch then it triggers build and successfully deployed. Yes, the website is up and running. (the build command is fine)

My environment NextJS 13 SSR

Does enable_auto_build mean building the app on terraform apply? It looks some could make it but I do not see why it's not working on my end... Can anyone help with this?

same here, always get "Your build is being queued. If your build has not started in over a minute, click the button below." It works only if I click the build button manually.

skrapidinnovation commented 5 months ago

Any update on this

DevanTurtle7 commented 1 month ago

I was able to force an initial build by adding the following:

resource "null_resource" "trigger_amplify_deployment" {
  depends_on = [aws_amplify_branch.main]

  # Force this command to be triggered every time this terraform file is ran
  triggers = {
    always_run = "${timestamp()}"
  }

  # The command to be ran
  provisioner "local-exec" {
    command = "aws amplify start-job --app-id ${aws_amplify_app.example.id} --branch-name ${aws_amplify_branch.main.branch_name} --job-type RELEASE"
  }
}