1

I am trying to provision the AWS amplify using Terraform and when I do terraform init and terraform plan there is no error but when applying (terraform apply) it is giving me error

Error: creating Amplify App (nextjs_app_amplify): BadRequestException: You should at least provide one valid token with aws_amplify_app.nextjs_app, on main.tf line 7, in resource aws_amplify_app" "nextjs_app": 7: resource "aws_amplify_app" "nextjs_app" {

This is only message is printing

My Main.tf file

provider "aws" {
  region = "ap-south-1"
  access_key = "xxxxx"
  secret_key = "xxxxx"
}

resource "aws_amplify_app" "nextjs_app" {
    name     = "nextjs_app_amplify"
    platform = "WEB"
    repository = "https://github.com/xxx/nectjs-example.git"
    }

Note:- My repo is Public repo.

  • 2
    There is a note in the documentation about the error you are referencing. And here's the section you need to read through: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/amplify_app#repository-with-tokens. – Marko E Jun 22 '23 at 08:08
  • Yes, that solves my problem, Just need to create a auth token on my github and use it in my main.tf file. Thanks – Akshay Jain Jun 22 '23 at 10:06

1 Answers1

0

If you create a new Amplify App with the repository argument, you also need to set oauth_token or access_token for authentication. For GitHub, get a personal access token and set access_token as follows:

resource "aws_amplify_app" "nextjs_app" {
  name     = "nextjs_app_amplify"
  platform = "WEB"
  repository = "https://github.com/xxx/nectjs-example.git"

  # GitHub personal access token
  access_token = "..."
}

You can omit access_token if you import an existing Amplify App created by the Amplify Console (using OAuth for authentication).

Source: Terraform aws_amplyfy_app documentation

Dennis Traub
  • 50,557
  • 7
  • 93
  • 108