From 69fd155ad4105843797e2a37d175a55371f49ad2 Mon Sep 17 00:00:00 2001 From: Konrad Obal Date: Wed, 6 Nov 2019 22:33:22 +0100 Subject: [PATCH] feat(label): Expose variable "regex_replace_chars" to allow changing label module behaviour (#34) --- README.md | 1 + docs/terraform.md | 1 + main.tf | 17 +++++++++-------- variables.tf | 7 +++++++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7e478d2..ae1a8d4 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,7 @@ Available targets: | namespace | Namespace (e.g. `eg` or `cp`) | string | `` | no | | principals_full_access | Principal ARNs to provide with full access to the ECR | list(string) | `` | no | | principals_readonly_access | Principal ARNs to provide with readonly access to the ECR | list(string) | `` | no | +| regex_replace_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`. By default only hyphens, letters and digits are allowed, all other chars are removed | string | `/[^a-zA-Z0-9-]/` | no | | scan_images_on_push | Indicates whether images are scanned after being pushed to the repository (true) or not (false) | bool | `false` | no | | stage | Stage (e.g. `prod`, `dev`, `staging`) | string | `` | no | | tags | Additional tags (e.g. `map('BusinessUnit','XYZ')`) | map(string) | `` | no | diff --git a/docs/terraform.md b/docs/terraform.md index 8a839de..4a9924f 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -10,6 +10,7 @@ | namespace | Namespace (e.g. `eg` or `cp`) | string | `` | no | | principals_full_access | Principal ARNs to provide with full access to the ECR | list(string) | `` | no | | principals_readonly_access | Principal ARNs to provide with readonly access to the ECR | list(string) | `` | no | +| regex_replace_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`. By default only hyphens, letters and digits are allowed, all other chars are removed | string | `/[^a-zA-Z0-9-]/` | no | | scan_images_on_push | Indicates whether images are scanned after being pushed to the repository (true) or not (false) | bool | `false` | no | | stage | Stage (e.g. `prod`, `dev`, `staging`) | string | `` | no | | tags | Additional tags (e.g. `map('BusinessUnit','XYZ')`) | map(string) | `` | no | diff --git a/main.tf b/main.tf index ec9e9b0..cf55a24 100755 --- a/main.tf +++ b/main.tf @@ -5,14 +5,15 @@ locals { } module "label" { - source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.16.0" - enabled = var.enabled - namespace = var.namespace - stage = var.stage - name = var.name - delimiter = var.delimiter - attributes = var.attributes - tags = var.tags + source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.16.0" + enabled = var.enabled + namespace = var.namespace + stage = var.stage + name = var.name + delimiter = var.delimiter + attributes = var.attributes + tags = var.tags + regex_replace_chars = var.regex_replace_chars } resource "aws_ecr_repository" "default" { diff --git a/variables.tf b/variables.tf index 44b8fcd..ea6e73b 100755 --- a/variables.tf +++ b/variables.tf @@ -67,3 +67,10 @@ variable "max_image_count" { description = "How many Docker Image versions AWS ECR will store" default = 500 } + +variable "regex_replace_chars" { + type = string + default = "/[^a-zA-Z0-9-]/" + description = "Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`. By default only hyphens, letters and digits are allowed, all other chars are removed" +} +