Skip to content

Commit

Permalink
Fix tags (#43)
Browse files Browse the repository at this point in the history
* Don't include tags with empty values

* Fix README links

* Update README
  • Loading branch information
aknysh authored Sep 11, 2018
1 parent 5d770f4 commit 5fea994
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Cloud Posse](https://cloudposse.com/logo-300x69.svg)](https://cloudposse.com)

# terraform-null-label [![Build Status](https://travis-ci.org/cloudposse/terraform-null-label.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-null-label-cloudtrail) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-null-label.svg)](https://github.com/cloudposse/terraform-null-label/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
# terraform-null-label [![Build Status](https://travis-ci.org/cloudposse/terraform-null-label.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-null-label) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-null-label.svg)](https://github.com/cloudposse/terraform-null-label/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)


Terraform module designed to generate consistent label names and tags for resources. Use `terraform-null-label` to implement a strict naming convention.
Expand Down Expand Up @@ -401,9 +401,9 @@ Available targets:

| Name | Description |
|------|-------------|
| attributes | Normalized attributes |
| context | Context of this module to pass between other modules |
| delimiter | Delimiter used in label ID |
| attributes | List of attributes |
| context | Context of this module to pass to other label modules |
| delimiter | Delimiter between `namespace`, `environment`, `stage`, `name` and `attributes` |
| environment | Normalized environment |
| id | Disambiguated ID |
| label_order | The naming order of the id output and Name tag |
Expand Down
2 changes: 1 addition & 1 deletion README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ github_repo: cloudposse/terraform-null-label
badges:
- name: "Build Status"
image: "https://travis-ci.org/cloudposse/terraform-null-label.svg?branch=master"
url: "https://travis-ci.org/cloudposse/terraform-null-label-cloudtrail"
url: "https://travis-ci.org/cloudposse/terraform-null-label"
- name: "Latest Release"
image: "https://img.shields.io/github/release/cloudposse/terraform-null-label.svg"
url: "https://github.com/cloudposse/terraform-null-label/releases/latest"
Expand Down
6 changes: 3 additions & 3 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

| Name | Description |
|------|-------------|
| attributes | Normalized attributes |
| context | Context of this module to pass between other modules |
| delimiter | Delimiter used in label ID |
| attributes | List of attributes |
| context | Context of this module to pass to other label modules |
| delimiter | Delimiter between `namespace`, `environment`, `stage`, `name` and `attributes` |
| environment | Normalized environment |
| id | Disambiguated ID |
| label_order | The naming order of the id output and Name tag |
Expand Down
12 changes: 5 additions & 7 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ locals {
delimiter = "${var.delimiter != "-" ? var.delimiter : local.delimiter_context_or_default}"
# Merge attributes
attributes = ["${distinct(compact(concat(var.attributes, local.context_local["attributes"])))}"]
# Generate tags
generated_tags = {
"Name" = "${local.id}"
"Namespace" = "${local.namespace}"
"Environment" = "${local.environment}"
"Stage" = "${local.stage}"
}
# Generate tags (don't include tags with empty values)
generated_tags = "${zipmap(
compact(list("Name", local.namespace != "" ? "Namespace" : "", local.environment != "" ? "Environment" : "", local.stage != "" ? "Stage" : "")),
compact(list(local.id, local.namespace, local.environment, local.stage))
)}"
tags = "${merge(zipmap(local.context_local["tags_keys"], local.context_local["tags_values"]), local.generated_tags, var.tags)}"
tags_as_list_of_maps = ["${data.null_data_source.tags_as_list_of_maps.*.outputs}"]
label_order_default_list = "${list("namespace", "environment", "stage", "name", "attributes")}"
Expand Down
6 changes: 3 additions & 3 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ output "environment" {

output "attributes" {
value = "${local.attributes}"
description = "Normalized attributes"
description = "List of attributes"
}

output "delimiter" {
value = "${local.enabled ? local.delimiter : ""}"
description = "Delimiter used in label ID"
description = "Delimiter between `namespace`, `environment`, `stage`, `name` and `attributes`"
}

output "tags" {
Expand All @@ -45,7 +45,7 @@ output "tags_as_list_of_maps" {

output "context" {
value = "${local.output_context}"
description = "Context of this module to pass between other modules"
description = "Context of this module to pass to other label modules"
}

output "label_order" {
Expand Down

0 comments on commit 5fea994

Please sign in to comment.