AWS CodeBuild Project
This page shows how to write Terraform and CloudFormation for CodeBuild Project and write them securely.
aws_codebuild_project (Terraform)
The Project in CodeBuild can be configured in Terraform with the resource name aws_codebuild_project. The following sections describe 4 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_codebuild_project" "my_project_noUsage" {
name = "test-project-cache"
description = "test_codebuild_project_cache"
service_role = ""
resource "aws_codebuild_project" "allowed" {
artifacts {
type = "NO_ARTIFACTS"
}
}
resource "aws_codebuild_project" "denied" {
artifacts {
type = "S3"
encryption_disabled = true
}
}
resource "aws_codebuild_project" "tf-plan" {
name = "tf-cicd-plan2"
description = "Plan stage for terraform"
service_role = aws_iam_role.tf-codebuild-role.arn
artifacts {
Security Best Practices for aws_codebuild_project
There is 1 setting in aws_codebuild_project that should be taken care of for security reasons. The following section explain an overview and example code.
Ensure to enable encryption of CodeBuild artifacts
It's better to protect CodeBuild project artifacts with default encryption.
Parameters
-
arnoptional computed - string -
badge_enabledoptional - bool -
badge_urloptional computed - string -
build_timeoutoptional - number -
descriptionoptional computed - string -
encryption_keyoptional computed - string -
idoptional computed - string -
namerequired - string -
queued_timeoutoptional - number -
service_rolerequired - string -
source_versionoptional - string -
tagsoptional - map from string to string -
artifactslist block-
artifact_identifieroptional - string -
encryption_disabledoptional - bool -
locationoptional - string -
nameoptional - string -
namespace_typeoptional - string -
override_artifact_nameoptional - bool -
packagingoptional - string -
pathoptional - string -
typerequired - string
-
-
cachelist block -
environmentlist block-
certificateoptional - string -
compute_typerequired - string -
imagerequired - string -
image_pull_credentials_typeoptional - string -
privileged_modeoptional - bool -
typerequired - string -
environment_variablelist block -
registry_credentiallist block-
credentialrequired - string -
credential_providerrequired - string
-
-
-
logs_configlist block-
cloudwatch_logslist block-
group_nameoptional - string -
statusoptional - string -
stream_nameoptional - string
-
-
s3_logslist block-
encryption_disabledoptional - bool -
locationoptional - string -
statusoptional - string
-
-
-
secondary_artifactsset block-
artifact_identifierrequired - string -
encryption_disabledoptional - bool -
locationoptional - string -
nameoptional - string -
namespace_typeoptional - string -
override_artifact_nameoptional - bool -
packagingoptional - string -
pathoptional - string -
typerequired - string
-
-
secondary_sourcesset block-
buildspecoptional - string -
git_clone_depthoptional - number -
insecure_ssloptional - bool -
locationoptional - string -
report_build_statusoptional - bool -
source_identifierrequired - string -
typerequired - string -
authlist block -
git_submodules_configlist block-
fetch_submodulesrequired - bool
-
-
-
sourcelist block-
buildspecoptional - string -
git_clone_depthoptional - number -
insecure_ssloptional - bool -
locationoptional - string -
report_build_statusoptional - bool -
typerequired - string -
authlist block -
git_submodules_configlist block-
fetch_submodulesrequired - bool
-
-
-
vpc_configlist block-
security_group_idsrequired - set of string -
subnetsrequired - set of string -
vpc_idrequired - string
-
Explanation in Terraform Registry
Provides a CodeBuild Project resource. See also the
aws_codebuild_webhookresource, which manages the webhook to the source (e.g., the "rebuild every time a code change is pushed" option in the CodeBuild web console).
AWS::CodeBuild::Project (CloudFormation)
The Project in CodeBuild can be configured in CloudFormation with the resource name AWS::CodeBuild::Project. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
-
Descriptionoptional - String -
ResourceAccessRoleoptional - String -
VpcConfigoptional - VpcConfig -
SecondarySourcesoptional - List of Source -
EncryptionKeyoptional - String -
SourceVersionoptional - String -
Triggersoptional - ProjectTriggers -
SecondaryArtifactsoptional - List of Artifacts -
Sourcerequired - Source -
Nameoptional - String -
Artifactsrequired - Artifacts -
BadgeEnabledoptional - Boolean -
LogsConfigoptional - LogsConfig -
ServiceRolerequired - String -
QueuedTimeoutInMinutesoptional - Integer -
FileSystemLocationsoptional - List of ProjectFileSystemLocation -
Environmentrequired - Environment -
SecondarySourceVersionsoptional - List of ProjectSourceVersion -
ConcurrentBuildLimitoptional - Integer -
Visibilityoptional - String -
BuildBatchConfigoptional - ProjectBuildBatchConfig -
Tagsoptional - List of Tag -
TimeoutInMinutesoptional - Integer -
Cacheoptional - ProjectCache
Explanation in CloudFormation Registry
The
AWS::CodeBuild::Projectresource configures how AWS CodeBuild builds your source code. For example, it tells CodeBuild where to get the source code and which build environment to use.
Frequently asked questions
What is AWS CodeBuild Project?
AWS CodeBuild Project is a resource for CodeBuild of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS CodeBuild Project?
For Terraform, the gilyas/infracost, snyk-labs/infrastructure-as-code-goof and snyk-labs/infrastructure-as-code-goof source code examples are useful. See the Terraform Example section for further details.