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β
| Name | Type | Description |
|---|---|---|
region | string | AWS region to deploy the CodeBuild project |
project_name | string | Name of the CodeBuild project |
source_location | string | URL or location of the source code repository |
buildspec_file | string | Path to the buildspec file used for defining build steps |
compute_type | string | Compute type for the build environment (e.g., BUILD_GENERAL1_SMALL) |
image | string | Docker image for the build environment |
environment_type | string | Build environment type (e.g., LINUX_CONTAINER) |
service_role_arn | string | ARN of the IAM role to be used by CodeBuild |
environment | string | Tag to specify the deployment environment (e.g., dev, prod) |
π€ Outputsβ
| Name | Description |
|---|---|
codebuild_project_name | The name of the created CodeBuild project |
codebuild_project_arn | The ARN of the created CodeBuild project |
service_role_arn | The 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.