Search code examples
terraformaws-codepipelineaws-codebuild

terraform AWS CodePipeline configuration for CodeBuild source stage


I'm trying to use terraform to create a CodePipeline job. I have a working CodeBuild project already. Here's my resource:

resource "aws_codepipeline" "my-project" {
  name     = "my-project"
  role_arn = "${aws_iam_role.my-project-codepipeline.arn}"

  artifact_store {
    location = "${aws_s3_bucket.my-artifacts.bucket}"
    type     = "S3"
  }

  stage {
    name = "Source"

    action {
      name     = "Source"
      category = "Source"
      owner    = "AWS"
      provider = "CodeCommit"
      version  = "1"

      configuration {
        ProjectName = "my-project"
        Branch      = "master"
      }
    }
  }

  stage {
    name = "Build"

    action {
      name     = "Build"
      category = "Build"
      owner    = "AWS"
      provider = "CodeBuild"
      version  = "1"

      configuration {
        ProjectName = "my-project"
      }
    }
  }
}

When I try terraform apply the error I get is Error creating CodePipeline: InvalidActionDeclarationException: Action configuration for action 'Source' contains unknown configuration 'ProjectName'. Where can I find the proper schema for this configuration section? All the docs and examples I have found so far are generic and omit the specific CodeBuild settings/schema I would need here.


Solution

  • Turns out the settings I need for Source are

    RepositoryName = "my-project"
    BranchName = "master"