|
2 | 2 |
|
3 | 3 | Terraform module to provide consistent label names and tags for resources.
|
4 | 4 |
|
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 |
6 | 6 |
|
7 | 7 | All [devops-workflow](https://registry.terraform.io/search?q=devops-workflow&verified=false) modules will eventually use this.
|
8 | 8 |
|
9 | 9 | **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.
|
10 | 10 |
|
11 | 11 | Terraform registry: https://registry.terraform.io/modules/devops-workflow/label/local
|
12 | 12 |
|
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 | +``` |
0 commit comments