AWS codebuild github Integration Issue

Hi All,

I am trying to create an AWS codebuild project using terraform using GITHUB as a source

resource “aws_codebuild_project” “training-service” {

name = “${var.github_repository}”

build_timeout = “5”

service_role = “${aws_iam_role.codebuild.arn}”

badge_enabled = “${var.codebuild_badge_enabled}”

source {

type      = "GITHUB"

location  = "${data.template_file.codebuild_source_location.rendered}"

buildspec = "${var.codebuild_buildspec}"



auth {

  type     = "OAUTH"

  resource = "${var.github_oauth_token}"

}

}

environment {

compute_type         = "${var.codebuild_compute_type}"

type                 = "LINUX_CONTAINER"

image                = "${var.codebuild_image}"

privileged_mode      = "${var.codebuild_privileged_mode}"

}

artifacts {

type           = "S3"

location       = "${aws_s3_bucket.training-service-codebuild-bucket.arn}"

name           = "${var.github_repository}"

namespace_type = "BUILD_ID"

packaging      = "ZIP"

}

}

I verified from terraform docs also and this is the correct way of doing it.

variable “github_oauth_token” {

description = “GitHub OAuth token for repository access”

default =“XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”

}

I am getting below exception. can anyone help?

Error: Error creating CodeBuild project: InvalidInputException: No Access token found, please visit AWS CodeBuild console to connect to GitHub

on main.tf line 103, in resource “aws_codebuild_project” “training-service”:
103: resource “aws_codebuild_project” “training-service” {