Skip to content

Commit 0d4d833

Browse files
atkinchrisosterman
authored andcommitted
Add support for CodeBuild source location and type (#22)
* Add support for CodeBuild source location and type This adds support for specifying a location and type for the CodeBuild source, to support building from sources other than CodePipeline, such as GitHub or S3. * Remove optional/required and regenerate README
1 parent 4767ce7 commit 0d4d833

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ Available targets:
117117
| name | Solution name, e.g. 'app' or 'jenkins' | string | `codebuild` | no |
118118
| namespace | Namespace, which could be your organization name, e.g. 'cp' or 'cloudposse' | string | `global` | no |
119119
| privileged_mode | (Optional) If set to true, enables running the Docker daemon inside a Docker container on the CodeBuild instance. Used when building Docker images | string | `false` | no |
120+
| source_location | The location of the source code from git or s3. | string | `` | no |
121+
| source_type | The type of repository that contains the source code to be built. Valid values for this parameter are: CODECOMMIT, CODEPIPELINE, GITHUB, GITHUB_ENTERPRISE, BITBUCKET or S3. | string | `CODEPIPELINE` | no |
120122
| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | `default` | no |
121123
| tags | Additional tags (e.g. `map('BusinessUnit', 'XYZ')` | map | `<map>` | no |
122124

docs/terraform.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
| name | Solution name, e.g. 'app' or 'jenkins' | string | `codebuild` | no |
2222
| namespace | Namespace, which could be your organization name, e.g. 'cp' or 'cloudposse' | string | `global` | no |
2323
| privileged_mode | (Optional) If set to true, enables running the Docker daemon inside a Docker container on the CodeBuild instance. Used when building Docker images | string | `false` | no |
24+
| source_location | The location of the source code from git or s3. | string | `` | no |
25+
| source_type | The type of repository that contains the source code to be built. Valid values for this parameter are: CODECOMMIT, CODEPIPELINE, GITHUB, GITHUB_ENTERPRISE, BITBUCKET or S3. | string | `CODEPIPELINE` | no |
2426
| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | `default` | no |
2527
| tags | Additional tags (e.g. `map('BusinessUnit', 'XYZ')` | map | `<map>` | no |
2628

main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ locals {
4949
cache_bucket_name_normalised = "${substr(join("-", split("_", lower(local.cache_bucket_name))), 0, min(length(local.cache_bucket_name),63))}"
5050

5151
## This is the magic where a map of a list of maps is generated
52-
## and used to conditionally add the cache bucket option to the
52+
## and used to conditionally add the cache bucket option to the
5353
## aws_codebuild_project
5454
cache_def = {
5555
"true" = [{
@@ -205,7 +205,8 @@ resource "aws_codebuild_project" "default" {
205205

206206
source {
207207
buildspec = "${var.buildspec}"
208-
type = "CODEPIPELINE"
208+
type = "${var.source_type}"
209+
location = "${var.source_location}"
209210
}
210211

211212
tags = "${module.label.tags}"

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,15 @@ variable "image_tag" {
122122
default = "latest"
123123
description = "(Optional) Docker image tag in the ECR repository, e.g. 'latest'. Used as CodeBuild ENV variable when building Docker images. For more info: http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html"
124124
}
125+
126+
variable "source_type" {
127+
type = "string"
128+
default = "CODEPIPELINE"
129+
description = "The type of repository that contains the source code to be built. Valid values for this parameter are: CODECOMMIT, CODEPIPELINE, GITHUB, GITHUB_ENTERPRISE, BITBUCKET or S3."
130+
}
131+
132+
variable "source_location" {
133+
type = "string"
134+
default = ""
135+
description = "The location of the source code from git or s3."
136+
}

0 commit comments

Comments
 (0)