Skip to main content

CodeBuild Project

πŸ“¦ Overview​

This Terraform module provisions a fully configurable AWS CodeBuild project, providing flexible build automation for your CI/CD workflows.

It’s ideal for teams that need isolated builds, containerized execution, and full control over environment settings.


βœ… Key Features​

  • Creates a CodeBuild project with customizable environment variables
  • Supports integration with GitHub, CodeCommit, and other source providers
  • Enables artifact output, Docker-in-Docker builds, and IAM role-based execution
  • Works for infrastructure automation, container builds, and testing pipelines

πŸ’Ό Use Cases​

  • Standalone build automation for application or infrastructure code
  • Container image builds and publishing pipelines
  • Cross-environment testing and artifact promotion workflows
  • Integrating with CodePipeline or other CI/CD orchestrators

πŸ“₯ Input Variables​

NameTypeDescription
regionstringAWS region to deploy the CodeBuild project
project_namestringName of the CodeBuild project
source_locationstringURL or location of the source code repository
buildspec_filestringPath to the buildspec file used for defining build steps
compute_typestringCompute type for the build environment (e.g., BUILD_GENERAL1_SMALL)
imagestringDocker image for the build environment
environment_typestringBuild environment type (e.g., LINUX_CONTAINER)
service_role_arnstringARN of the IAM role to be used by CodeBuild
environmentstringTag to specify the deployment environment (e.g., dev, prod)

πŸ“€ Outputs​

NameDescription
codebuild_project_nameThe name of the created CodeBuild project
codebuild_project_arnThe ARN of the created CodeBuild project
service_role_arnThe ARN of the IAM role used by the build process

πŸš€ Deployment Readiness​

  • βœ… Compatible with Terraform 1.0+
  • βœ… Tested with AWS provider 5.x
  • πŸ§ͺ Requires a CodeBuild service role and source repository

πŸ› οΈ Example Usage​

module "codebuild_project" {
source = "git::ssh://git@github.com/archiphire/aws-level-1-modules.git//developer-utilities/codebuild-project?ref=v1.0.0"

region = "us-east-1"
project_name = "my-build-project"
source_location = "https://github.com/my-org/my-repo"
buildspec_file = "buildspec.yml"
compute_type = "BUILD_GENERAL1_SMALL"
image = "aws/codebuild/standard:5.0"
environment_type = "LINUX_CONTAINER"
service_role_arn = "arn:aws:iam::123456789012:role/codebuild-service-role"
environment = "dev"
}
terraform init
terraform plan
terraform apply

or

tofu init
tofu plan
tofu apply

🧹 Cleanup Options​

For testing:

terraform destroy

or

tofu destroy

For production:

Manually delete the CodeBuild project via the AWS Console or CLI if it’s connected to pipelines or automation workflows.

πŸ›‘οΈ Notes​

This is a Level 1 developer utility module for provisioning individual CodeBuild projects. For multi-stage CI/CD, cross-account role usage, or orchestration, use a composed pipeline module or integrate with codepipeline resources.

πŸ”’ Deployment Package Notice​

This module is part of the Level 1 AWS License Tier. To access the full deployment package and source code, subscribe to Archiphire.