Issue Connecting Bitbucket Repository to AWS Amplify via Terraform

I am encountering issues when trying to connect a Bitbucket repository to an AWS Amplify app using Terraform, and I would appreciate your assistance in resolving them.

Scenario 1: Using Access Token

I have successfully deployed an AWS Amplify resource manually through the AWS Console. However, when I attempt to automate the process using Terraform, I receive the following error when trying to use the access_token for Bitbucket repository integration:


> Plan: 2 to add, 0 to change, 0 to destroy.
>
>
>
> module.amplify.aws_amplify_app.default[0]: Creating...
>
>
>
> ╷
>
>
>
> │ Error: creating Amplify App (devlopment-ort-amplify): operation error Amplify: CreateApp, https response error StatusCode: 400, RequestID: b5af611b-2890-4ed7-9b0b-0b3d57547012, BadRequestException: There was an issue setting up your repository. Please try again later.(Invalid Authorization header)
>
>
>
> │
>
>
>
> │ with module.amplify.aws_amplify_app.default[0],
>
>
>
> │ on .terraform\modules\amplify\main.tf line 10, in resource "aws_amplify_app" "default":
>
>
>
> │ 10: resource "aws_amplify_app" "default" {
>
>
>
> │
>
>
>
> ╵
>
>
>
> Releasing state lock. This may take a few moments...
>
>
>
> ```

**Scenario 2: Using OAuth Token**

When I use an `oauth_token` for the Bitbucket repository instead, I encounter a different error message:

Plan: 2 to add, 0 to change, 0 to destroy.

module.amplify.aws_amplify_app.default[0]: Creating…

│ Error: creating Amplify App (devlopment-ort-amplify): operation error Amplify: CreateApp, https response error StatusCode: 400, RequestID: 770b38a0-a987-4a95-8705-8b4c4862b8b9, BadRequestException: There was an issue setting up your repository. Please try again later.({“type”: “error”, “error”: {“message”: “Token is invalid or not supported for this endpoint.”}})

│ with module.amplify.aws_amplify_app.default[0],

│ on .terraform\modules\amplify\main.tf line 10, in resource “aws_amplify_app” “default”:

│ 10: resource “aws_amplify_app” “default” {


**Details of the Terraform Configuration:**

Here is a snippet of the Terraform code I am using to configure the AWS Amplify app and link it to the Bitbucket repository:

module "amplify" {

source = "cloudposse/amplify-app/aws"

version = "1.1.0"

name = "development-ort-amplify"

platform = "WEB"

enable_basic_auth = false

repository = "https://bitbucket.org/onlinereadingtutor/frontend-ort"

oauth_token = "ANVBfdsgf4vn3WsWN98AhxYn4Tp2A44D2C2"
access_token = "asdfsisadlkfjasdfsadkjflasdkjflsakdjflkas"

environments = {

development = {

branch_name = "development"

framework = "React"

stage = "DEVELOPMENT"

enable_auto_build = false

}

}

}

Key Issues:

  1. Invalid Authorization Header: When using the access_token, I get an “Invalid Authorization header” error, suggesting the token might not be recognized by AWS Amplify.

  2. Token Invalid or Unsupported: When using the oauth_token, the error indicates that the token is invalid or not supported for the endpoint.

Additional Information:

  • I have provided the correct access tokens for the Bitbucket repository integration, and the oauth_token is correctly configured as per the documentation.

  • The issue arises only when trying to create the Amplify app through Terraform. I have successfully connected and deployed the same repository to Amplify via the AWS Console manually.

Request:

Can you help identify why the tokens are not working in the Terraform deployment process? Are there specific requirements or changes needed in the configuration for either the access_token or the oauth_token to function correctly?

Any guidance on how to troubleshoot or resolve this issue would be greatly appreciated.

Thank you for your support!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.