Skip to content

Commit

Permalink
Add default values to ENV vars and check if they are not empty (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
aknysh authored Oct 4, 2017
1 parent 41e4860 commit c659c17
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ module "build" {
| 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 |
| aws_region | "" | (Optional) AWS Region, _e.g._ `us-east-1`. Used as `CodeBuild` ENV variable when building Docker images |
| aws_account_id | "" | (Optional) AWS Account ID. Used as `CodeBuild` ENV variable when building Docker images |
| image_repo_name | "" | (Optional) ECR repository name to store the Docker image built by this module. Used as `CodeBuild` ENV variable when building Docker images |
| image_tag | "" | (Optional) Docker image tag in the ECR repository, _e.g._ `latest`. Used as `CodeBuild` ENV variable when building Docker images |
| image_repo_name | "UNSET" | (Optional) ECR repository name to store the Docker image built by this module. Used as `CodeBuild` ENV variable when building Docker images |
| image_tag | "latest" | (Optional) Docker image tag in the ECR repository, _e.g._ `latest`. Used as `CodeBuild` ENV variable when building Docker images |



Expand Down
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ data "aws_region" "default" {

# Define composite variables for resources
module "label" {
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.2.1"
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.2.1"
namespace = "${var.namespace}"
name = "${var.name}"
stage = "${var.stage}"
Expand Down Expand Up @@ -98,12 +98,12 @@ resource "aws_codebuild_project" "default" {

environment_variable {
"name" = "IMAGE_REPO_NAME"
"value" = "${var.image_repo_name}"
"value" = "${signum(length(var.image_repo_name)) == 1 ? var.image_repo_name : "UNSET"}"
}

environment_variable {
"name" = "IMAGE_TAG"
"value" = "${var.image_tag}"
"value" = "${signum(length(var.image_tag)) == 1 ? var.image_tag : "latest"}"
}
}

Expand Down
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ variable "aws_account_id" {

variable "image_repo_name" {
type = "string"
default = ""
default = "UNSET"
description = "(Optional) 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"
}

variable "image_tag" {
type = "string"
default = ""
default = "latest"
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"
}

0 comments on commit c659c17

Please sign in to comment.