Skip to content

Commit

Permalink
Fix eng stds (#2)
Browse files Browse the repository at this point in the history
* remove envs and sort attrs

* sort tags module attr

* add example

* introduce locals

* add outputs
  • Loading branch information
sblack4 authored May 18, 2020
1 parent bbc03ae commit 6be0765
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 14 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module "example" {
```

## About
A bit about this module

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements
Expand All @@ -24,18 +25,19 @@ No provider.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| env | Environment to tag resources with | `string` | `"default"` | no |
| name | Moniker to apply to all resources in the module | `string` | n/a | yes |
| tags | User-Defined tags | `map(string)` | `{}` | no |

## Outputs

No output.
| Name | Description |
|------|-------------|
| tags\_module | Tags Module in it's entirety |

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

## The Giants underneath this module
- pre-commit.com/
- www.terraform.io/
- terraform.io/
- github.com/tfutils/tfenv
- github.com/segmentio/terraform-docs
57 changes: 57 additions & 0 deletions examples/basic/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,59 @@
# basic example
A basic example for this repository

## Code
Look to [main.tf](./main.tf), or be helpful and copy/paste that code here.

## Applying
```
> alias tf="terraform"
> tf apply
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
example = {
"tags_module" = {
"name" = "TEST"
"name32" = "TEST"
"name6" = "TEST"
"namenosymbols" = "TEST"
"tags" = {
"Name" = "TEST"
"terraform_managed" = true
"terraform_module" = "terraform-terraform-tags-1.0.0"
"terraform_root_module" = "."
"terraform_workspace" = "default"
}
"tags_as_list_of_maps" = [
{
"key" = "Name"
"value" = "TEST"
},
{
"key" = "terraform_managed"
"value" = true
},
{
"key" = "terraform_module"
"value" = "terraform-terraform-tags-1.0.0"
},
{
"key" = "terraform_root_module"
"value" = "."
},
{
"key" = "terraform_workspace"
"value" = "default"
},
]
"tags_no_name" = {
"terraform_managed" = true
"terraform_module" = "terraform-terraform-tags-1.0.0"
"terraform_root_module" = "."
"terraform_workspace" = "default"
}
}
}
```
6 changes: 6 additions & 0 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

module "example" {
source = "../.."

name = "test"
}

output "example" {
value = module.example
}
5 changes: 5 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

locals {
name = module.tags.name
tags = module.tags.tags_no_name
}
5 changes: 1 addition & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ module "tags" {
version = "1.0.0"

enforce_case = "UPPER"
names = [var.name]
tags = var.tags
names = [
var.env,
var.name
]
}
5 changes: 5 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

output "tags_module" {
description = "Tags Module in it's entirety"
value = module.tags
}
8 changes: 1 addition & 7 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ variable "name" {
}

variable "tags" {
default = {}
description = "User-Defined tags"
type = map(string)
default = {}
}

variable "env" {
description = "Environment to tag resources with"
type = string
default = "default"
}

0 comments on commit 6be0765

Please sign in to comment.