Skip to content

Commit 629b3b5

Browse files
author
Steven Nemetz
committed
Improving doc
1 parent 90a2160 commit 629b3b5

File tree

3 files changed

+64
-10
lines changed

3 files changed

+64
-10
lines changed

README.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,64 @@
22

33
Terraform module to provide consistent label names and tags for resources.
44

5-
A single name format will not solve every use case, so multiple variants are returned and there is a few options to affect how they get build. The general name convention is `{organization}-{environment}-{name}-{attributes}`. `Name` is required, the other 3 can be turned on/off indivisually. The delimiter (`-`) can be changed
5+
A single name format will not solve every use case, so multiple variants are returned and there is a few options to affect how they get build. The general name convention is `{organization}-{environment}-{name}-{attributes}`. `Name` is required, the other 3 can be turned on/off individually. The delimiter (`-`) can be changed
66

77
All [devops-workflow](https://registry.terraform.io/search?q=devops-workflow&verified=false) modules will eventually use this.
88

99
**NOTE:** `local` refers to this using [locals](https://www.terraform.io/docs/configuration/locals.html) and does not create any resources. It just builds new variables.
1010

1111
Terraform registry: https://registry.terraform.io/modules/devops-workflow/label/local
1212

13-
## TODO: Add usage/examples
13+
## Usage:
14+
15+
### Basic Example
16+
17+
```hcl
18+
module "name" {
19+
source = "devops-workflow/label/local"
20+
version = "0.1.2"
21+
name = "name"
22+
environment = "qa"
23+
}
24+
```
25+
This will create an `id` with the value of `qa-name`
26+
27+
### S3 Example
28+
29+
```hcl
30+
module "s3-name" {
31+
source = "devops-workflow/label/local"
32+
version = "0.1.2"
33+
name = "data"
34+
environment = "qa"
35+
organization = "corp"
36+
namespace-org = "true"
37+
}
38+
```
39+
This will create an `id` with the value of `corp-qa-data`
40+
41+
Now reference `label` outputs to create the S3 bucket
42+
43+
```hcl
44+
resource "aws_s3_bucket" "data" {
45+
bucket = "${module.s3-name.id}"
46+
tags = "${module.s3-name.tags}"
47+
```
48+
49+
### All Variables Example
50+
Using in a module and exposing all settings to upstream caller.
51+
52+
```hcl
53+
module "label" {
54+
source = "devops-workflow/label/local"
55+
version = "0.1.2"
56+
organization = "${var.organization}"
57+
name = "${var.name}"
58+
namespace-env = "${var.namespace-env}"
59+
namespace-org = "${var.namespace-org}"
60+
environment = "${var.environment}"
61+
delimiter = "${var.delimiter}"
62+
attributes = "${var.attributes}"
63+
tags = "${var.tags}"
64+
}
65+
```

outputs.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ output "tags" {
4949
}
5050
//debugging
5151
output "org_attr_20" {
52-
value = "${local.org_attr_20}"
52+
description = "Internal debugging. DO NOT USE"
53+
value = "${local.org_attr_20}"
5354
}
5455
output "org_attr_32" {
55-
value = "${local.org_attr_32}"
56+
description = "Internal debugging. DO NOT USE"
57+
value = "${local.org_attr_32}"
5658
}

variables.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@ variable "attributes" {
44
default = []
55
}
66
variable "autoscaling_group" {
7-
description = "If true, generate ASG tags map resource"
7+
description = "DOES NOTHING YET. If true, generate ASG tags map resource"
88
default = false
99
}
1010
variable "delimiter" {
1111
description = "Delimiter to be used between `name`, `namespaces`, `attributes`, etc."
1212
default = "-"
1313
}
1414
variable "environment" {
15-
description = "Environment (ex: dev, qa, stage, prod)"
15+
description = "Environment (ex: `dev`, `qa`, `stage`, `prod`). (Second or top level namespace. Depending on namespacing options)"
1616
}
1717
variable "name" {
1818
description = "Base name for resource"
1919
}
2020
variable "namespace-env" {
21-
description = "Prefix name with the environment"
21+
description = "Prefix name with the environment. If true, format is: <env>-<name>"
2222
default = true
2323
}
2424
variable "namespace-org" {
25-
description = "Prefix name with the organization. If both env and org namespaces are used, format will be <org>-<env>-<name>"
25+
description = "Prefix name with the organization. If true, format is: <org>-<env namespaced name>. If both env and org namespaces are used, format will be <org>-<env>-<name>"
2626
default = false
2727
}
2828
variable "organization" {
29-
description = "Organization name"
29+
description = "Organization name (Top level namespace)."
3030
default = ""
3131
}
3232
variable "tags" {
33-
description = "A map of tags to add to all resources"
33+
description = "A map of additional tags"
3434
type = "map"
3535
default = {}
3636
}

0 commit comments

Comments
 (0)