This template creates a CodeStar connection for Bitbucket and integrates it with a CodePipeline for continuous integration and deployment.

Terraform Template

resource "aws_codepipeline" "example" {
  name = "tf-test-pipeline"
  role_arn = "aws_iam_role.codepipeline_role.arn"

  stage {

    action {
      category = "Source"

      configuration = {
        BranchName = "main"
        ConnectionArn = aws_codestarconnections_connection.example.arn
        FullRepositoryId = "my-organization/test"
      }
      name = "Source"
      output_artifacts = ["source_output"]
      owner = "AWS"
      provider = "CodeStarSourceConnection"
      version = "1"
    }
    name = "Source"
  }

  stage {
    name = "Build"
  }

  stage {
    name = "Deploy"
  }
}

resource "aws_codestarconnections_connection" "example" {
  name = "example-connection"
  provider_type = "Bitbucket"
  provider = ""
}