terraform-aws-amplify-app icon indicating copy to clipboard operation
terraform-aws-amplify-app copied to clipboard

fix: Basic authentication configuration at the branch level

Open sestrella opened this issue 2 years ago • 31 comments

what

Module consumers cannot pass a custom basic_auth_credentials per branch using the existing variables. At the branch level, there is also a typo on enable_basic_auth.

why

The changes made in this PR allow consumers to configure different basic authentication credentials for each branch.

sestrella avatar Oct 16 '23 20:10 sestrella

Please review this, it would be really helpful!

skilef avatar Nov 01 '23 09:11 skilef

@sestrella can you please update base branch and I will look to get this merged

kevcube avatar Dec 27 '23 13:12 kevcube

/terratest

kevcube avatar Dec 28 '23 16:12 kevcube

@sestrella tests failing and readme is out of date, can you locally run make init; make readme (on macOS brew install make; gmake init; gmake readme)

kevcube avatar Dec 28 '23 16:12 kevcube

@kevcube done. Would you mind taking a second look, please?

sestrella avatar Dec 29 '23 01:12 sestrella

/terratest

kevcube avatar Dec 29 '23 06:12 kevcube

@sestrella tests are still failing. It doesn't appear to be related to your PR but if you have time to investigate that would be appreciated. Otherwise I'll check it out when I'm able to.

kevcube avatar Dec 30 '23 10:12 kevcube

@kevcube After taking a closer look at the job log, I found the following relevant information:

TestExamplesComplete 2023-12-29T06:54:08Z logger.go:66: │ Error: creating Amplify App (eg-ue2-test-amplify-jrjxrn): BadRequestException: There was an issue setting up your repository. Please try again later.({"message":"Moved Permanently","url":"https://api.github.com/repositories/498423879/hooks","documentation_url":"https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api#follow-redirects"})
TestExamplesComplete 2023-12-29T06:54:08Z logger.go:66: │ 
TestExamplesComplete 2023-12-29T06:54:08Z logger.go:66: │   with module.amplify_app.aws_amplify_app.default[0],
TestExamplesComplete 2023-12-29T06:54:08Z logger.go:66: │   on ../../main.tf line 10, in resource "aws_amplify_app" "default":
TestExamplesComplete 2023-12-29T06:54:08Z logger.go:66: │   10: resource "aws_amplify_app" "default" {
TestExamplesComplete 2023-12-29T06:54:08Z logger.go:66: │ 
TestExamplesComplete 2023-12-29T06:54:08Z logger.go:66: ╵
TestExamplesComplete 2023-12-29T06:54:08Z retry.go:99: Returning due to fatal error: FatalError{Underlying: error while running command: exit status 1; ╷
│ Error: creating Amplify App (eg-ue2-test-amplify-jrjxrn): BadRequestException: There was an issue setting up your repository. Please try again later.({"message":"Moved Permanently","url":"https://api.github.com/repositories/498423879/hooks","documentation_url":"https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api#follow-redirects"})

I'm wondering if this is related to the fact that the amplify-test2 appears to be transferred from the cloudposse organization to the cloudposse-archives organization. I submitted a commit updating the URL for the repository found in the complete example.

sestrella avatar Jan 03 '24 03:01 sestrella

/terratest

kevcube avatar Jan 03 '24 03:01 kevcube

@kevcube I got a different error this time. Perhaps is related to the permissions associated with the GH token?

TestExamplesComplete 2024-01-03T03:18:06Z logger.go:66: │ Error: creating Amplify App (eg-ue2-test-amplify-t9vp6d): BadRequestException: There was an issue setting up your repository. Please try again later.({"message":"Not Found","documentation_url":"https://docs.github.com/rest/repos/webhooks#create-a-repository-webhook"})
TestExamplesComplete 2024-01-03T03:18:06Z logger.go:66: │ 
TestExamplesComplete 2024-01-03T03:18:06Z logger.go:66: │   with module.amplify_app.aws_amplify_app.default[0],
TestExamplesComplete 2024-01-03T03:18:06Z logger.go:66: │   on ../../main.tf line 10, in resource "aws_amplify_app" "default":
TestExamplesComplete 2024-01-03T03:18:06Z logger.go:66: │   10: resource "aws_amplify_app" "default" {
TestExamplesComplete 2024-01-03T03:18:06Z logger.go:66: │ 
TestExamplesComplete 2024-01-03T03:18:06Z logger.go:66: ╵
TestExamplesComplete 2024-01-03T03:18:06Z retry.go:99: Returning due to fatal error: FatalError{Underlying: error while running command: exit status 1; ╷
│ Error: creating Amplify App (eg-ue2-test-amplify-t9vp6d): BadRequestException: There was an issue setting up your repository. Please try again later.({"message":"Not Found","documentation_url":"https://docs.github.com/rest/repos/webhooks#create-a-repository-webhook"})
│ 
│   with module.amplify_app.aws_amplify_app.default[0],
│   on ../../main.tf line 10, in resource "aws_amplify_app" "default":
│   10: resource "aws_amplify_app" "default" {
│ 
╵}

sestrella avatar Jan 03 '24 03:01 sestrella

@sestrella not sure how to proceed with that one. for a shorter debug loop you can try just terraform apply-ing the examples/complete into your own AWS and GitHub accounts until you find a working solution. I'm not an admin in Cloudposse so if it's a token issue I can call in someone else.

kevcube avatar Jan 03 '24 12:01 kevcube

@kevcube I finally made it back to this PR. I made it work by creating a fork of https://github.com/cloudposse-archives/amplify-test2 to which I had write access; the following GH token permissions were required to make the complete/example work:

image

On a side note, according to the official documentation, a token with write access is required to set up a webhook, so my guess is that the token used by the CI lacks the necessary permissions:

image

Reference: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/amplify_app#access_token

sestrella avatar Jan 23 '24 04:01 sestrella

Hi @kevcube, I'm wondering if there is anything else I can do on my end to help get this PR move forward. Please let me know.

sestrella avatar Feb 29 '24 02:02 sestrella

/terratest

hans-d avatar Mar 02 '24 18:03 hans-d

/terratest

hans-d avatar Mar 02 '24 22:03 hans-d

@kevcube Thank you for triggering the CI again. I realized the check for the README was failing, so I re-ran gmake init; gmake readme.

sestrella avatar Mar 04 '24 14:03 sestrella

/terratest

kevcube avatar Mar 04 '24 14:03 kevcube

I look closely at the error message:

BadRequestException: There was an issue setting up your repository. Please try again later

However, it appears to be a little misleading because the GH status page has not revealed any recent issues. Based on my tests a few weeks ago, I continue to believe this is related to token permissions. I'm wondering if the token was revisited.

sestrella avatar Mar 04 '24 15:03 sestrella

@sestrella the repo has been moved from cloudposse-archives back to cloudposse, can you please update the reference in this PR and we will try tests again

kevcube avatar Mar 04 '24 16:03 kevcube

@kevcube done! Let's see how it goes 🤞🏼

sestrella avatar Mar 04 '24 16:03 sestrella

/terratest

kevcube avatar Mar 04 '24 16:03 kevcube

Hello, @kevcube. I tested this PR by applying the Terraform code in "examples/complete" and was able to use it with our AWS and GH accounts.

image

I also ran the tests, and they work as expected. For this, I created a personal GitHub token with the permissions mentioned by @sestrella in a previous comment and forked the amplify-test2 repository. After changing the repository URL in the test fixtures to my fork, the tests passed.

image

Please let me know if I can provide additional information that will allow us to move forward with this PR.

fm7-1 avatar Mar 07 '24 21:03 fm7-1

/terratest

hans-d avatar Mar 07 '24 22:03 hans-d

@hans-d - Perhaps the token used for testing is missing the public_repo permission?

image

fm7-1 avatar Mar 07 '24 22:03 fm7-1

@fm7-1 could be.We need to check various options re this.

hans-d avatar Mar 08 '24 19:03 hans-d

Hello, @hans-d. Is there anything we could do from our side to move forward with this PR? Please let me know.

fm7-1 avatar Mar 15 '24 16:03 fm7-1

💥 This pull request now has conflicts. Could you fix it @sestrella? 🙏

mergify[bot] avatar Mar 15 '24 17:03 mergify[bot]

[!IMPORTANT]

Cloud Posse Engineering Team Review Required

This pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes.

To expedite this process, reach out to us on Slack in the #pr-reviews channel.

mergify[bot] avatar Apr 30 '24 19:04 mergify[bot]

/terratest

goruha avatar May 02 '24 17:05 goruha

@goruha terratest appears to be failing for the same reasons that it fails on #32. Here are the links to the runs:

image

sestrella avatar May 02 '24 19:05 sestrella