Skip to content

Commit

Permalink
add environment_variables parameter (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarkis authored Jul 16, 2018
1 parent 9fc7641 commit 9e10c7c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 17 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ It's 100% Open Source and licensed under the [APACHE2](LICENSE).








## Usage

```hcl
Expand Down Expand Up @@ -69,6 +74,7 @@ Available targets:
| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no |
| ecs_cluster_name | ECS Cluster Name | string | - | yes |
| enabled | Enable `CodePipeline` creation | string | `true` | no |
| environment_variables | A list of maps, that contain both the key 'name' and the key 'value' to be used as additional environment variables for the build. | list | `<list>` | no |
| github_oauth_token | GitHub Oauth Token with permissions to access private repositories | string | - | yes |
| image_repo_name | ECR repository name to store the Docker image built by this module. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | string | `UNSET` | no |
| image_tag | 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) | string | `latest` | no |
Expand Down Expand Up @@ -177,6 +183,13 @@ See [LICENSE](LICENSE) for full details.
under the License.









## Trademarks

All other trademarks referenced herein are the property of their respective owners.
Expand Down
1 change: 1 addition & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no |
| ecs_cluster_name | ECS Cluster Name | string | - | yes |
| enabled | Enable `CodePipeline` creation | string | `true` | no |
| environment_variables | A list of maps, that contain both the key 'name' and the key 'value' to be used as additional environment variables for the build. | list | `<list>` | no |
| github_oauth_token | GitHub Oauth Token with permissions to access private repositories | string | - | yes |
| image_repo_name | ECR repository name to store the Docker image built by this module. Used as CodeBuild ENV variable when building Docker images. [For more info](http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html) | string | `UNSET` | no |
| image_tag | 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) | string | `latest` | no |
Expand Down
35 changes: 18 additions & 17 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -163,23 +163,24 @@ data "aws_iam_policy_document" "codebuild" {
}

module "build" {
source = "git::https://github.com/cloudposse/terraform-aws-codebuild.git?ref=tags/0.7.2"
namespace = "${var.namespace}"
name = "${var.name}"
stage = "${var.stage}"
build_image = "${var.build_image}"
build_compute_type = "${var.build_compute_type}"
buildspec = "${var.buildspec}"
delimiter = "${var.delimiter}"
attributes = "${concat(var.attributes, list("build"))}"
tags = "${var.tags}"
privileged_mode = "${var.privileged_mode}"
aws_region = "${signum(length(var.aws_region)) == 1 ? var.aws_region : data.aws_region.default.name}"
aws_account_id = "${signum(length(var.aws_account_id)) == 1 ? var.aws_account_id : data.aws_caller_identity.default.account_id}"
image_repo_name = "${var.image_repo_name}"
image_tag = "${var.image_tag}"
github_token = "${var.github_oauth_token}"
enabled = "${var.enabled}"
source = "git::https://github.com/cloudposse/terraform-aws-codebuild.git?ref=tags/0.7.2"
namespace = "${var.namespace}"
name = "${var.name}"
stage = "${var.stage}"
build_image = "${var.build_image}"
build_compute_type = "${var.build_compute_type}"
buildspec = "${var.buildspec}"
delimiter = "${var.delimiter}"
attributes = "${concat(var.attributes, list("build"))}"
tags = "${var.tags}"
privileged_mode = "${var.privileged_mode}"
aws_region = "${signum(length(var.aws_region)) == 1 ? var.aws_region : data.aws_region.default.name}"
aws_account_id = "${signum(length(var.aws_account_id)) == 1 ? var.aws_account_id : data.aws_caller_identity.default.account_id}"
image_repo_name = "${var.image_repo_name}"
image_tag = "${var.image_tag}"
github_token = "${var.github_oauth_token}"
enabled = "${var.enabled}"
environment_variables = "${var.environment_variables}"
}

resource "aws_iam_role_policy_attachment" "codebuild_s3" {
Expand Down
11 changes: 11 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,14 @@ variable "image_tag" {
default = "latest"
description = "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)"
}

variable "environment_variables" {
type = "list"

default = [{
"name" = "NO_ADDITIONAL_BUILD_VARS"
"value" = "TRUE"
}]

description = "A list of maps, that contain both the key 'name' and the key 'value' to be used as additional environment variables for the build."
}

0 comments on commit 9e10c7c

Please sign in to comment.