diff --git a/README.md b/README.md index 39cbec8..eb09a48 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@

- - Logo + + Logo -

Ben's Terraform Null Label Module

+

Ben's Terraform Null Context Module

This is how I do it. @@ -22,57 +22,102 @@

-![Contributors](https://img.shields.io/github/contributors/bendoerr-terraform-modules/terraform-null-label?color=dark-green) ![Issues](https://img.shields.io/github/issues/bendoerr-terraform-modules/terraform-null-label) ![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/bendoerr-terraform-modules/terraform-null-label/test.yml) -![GitHub tag (with filter)](https://img.shields.io/github/v/tag/bendoerr-terraform-modules/terraform-null-label?filter=v*) -![License](https://img.shields.io/github/license/bendoerr-terraform-modules/terraform-null-label) +[GitHub contributors](https://github.com/bendoerr-terraform-modules/terraform-null-label/graphs/contributors) +[GitHub issues](https://github.com/bendoerr-terraform-modules/terraform-null-label/issues) +[GitHub pull requests](https://github.com/bendoerr-terraform-modules/terraform-null-label/pulls) +[GitHub workflow: Terratest](https://github.com/bendoerr-terraform-modules/terraform-null-label/actions/workflows/test.yml) +[GitHub workflow: Linting](https://github.com/bendoerr-terraform-modules/terraform-null-label/actions/workflows/lint.yml) +[GitHub tag (with filter)](https://registry.terraform.io/modules/bendoerr-terraform-modules/label/null/latest) +[OSSF-Scorecard Score](https://securityscorecards.dev/viewer/?uri=github.com/bendoerr-terraform-modules/terraform-null-label) +[GitHub License](https://github.com/bendoerr-terraform-modules/terraform-null-label/blob/main/LICENSE.txt) ## About The Project My opinionated label module. +This Terraform module consumes my `terraform-null-context` and produces +consistent names and tags for all of my resources. It implements a strict naming +and tagging convention that follows the format from +[cloudposse/terraform-null-label](https://github.com/cloudposse/terraform-null-label). + +The Cloud Posse label module provides detailed documentation and reasoning +however by itself it has too many knobs and provides more options that I use. +This module configures the Cloud Posse label exactly how I like it while taking +advantage of my context module to carry standard part of the label around. + + + + Logo + + ## Usage -``` +```terraform module "context" { - source = "git@github.com:bendoerr-terraform-modules/terraform-null-context?ref=v0.4.0" - namespace = "brd" - role = "production' + source = "bendoerr-terraform-modules/context/null" + version = "xxx" + namespace = "bd" + role = "production" region = "us-east-1" - project = "example' + project = "example" } -module "label_thing" { - source = "git@github.com:bendoerr-terraform-modules/terraform-null-label?ref=v0.4.0" +module "label" { + source = "bendoerr-terraform-modules/label/null" + version = "xxx" context = module.context.shared - thing = "thing" + name = "function" } -output "label_id" { - // brd-prod-ue1-example-thing - value = module.label_thing.id +resource "aws_lambda_function" "function" { + function_name = module.label.id # bd-prd-ue1-example-function + tags = module.label.tags # { Name: bd-prd-ue1-example-function, + # Namespace: bd, + # Role: production, + # Region: us-east-1, + # Project: example, + # Environment: prod-ue1, + # } + ... } + +resource "aws_route53_record" "function" { + name = "${module.label.dns_name}.${vars.zone_name}" # function.ue1.cloud.bendoerr.me + # assuming vars.zone_name = cloud.bendoerr.me + ... +} +``` + +### Cost + +infracost + +```text +Project: bendoerr-terraform-modules/terraform-null-label + + Name Monthly Qty Unit Monthly Cost + + OVERALL TOTAL $0.00 +────────────────────────────────── +No cloud resources were detected ``` +This module creates no resources and will not generate any cost against any +cloud provider you use. + + ### Requirements | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13 | -### Providers - -No providers. - ### Modules | Name | Source | Version | |------|--------|---------| | [label](#module\_label) | cloudposse/label/null | 0.25.0 | -### Resources - -No resources. - ### Inputs | Name | Description | Type | Default | Required | @@ -96,18 +141,30 @@ No resources. | [project](#output\_project) | Normalized project | | [tags](#output\_tags) | Normalized Tag map | | [tags\_as\_list\_of\_maps](#output\_tags\_as\_list\_of\_maps) | Additional tags as a list of maps, which can be used in several AWS resources | - + ## Roadmap -See the [open issues](https://github.com/bendoerr-terraform-modules/terraform-null-label/issues) for a list of proposed features (and known issues). +[GitHub issues](https://github.com/bendoerr-terraform-modules/terraform-null-label/issues) + +See the +[open issues](https://github.com/bendoerr-terraform-modules/terraform-null-label/issues) +for a list of proposed features (and known issues). ## Contributing -Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**. -* If you have suggestions for adding or removing projects, feel free to [open an issue](https://github.com/bendoerr-terraform-modules/terraform-null-label/issues/new) to discuss it, or directly create a pull request after you edit the *README.md* file with necessary changes. -* Please make sure you check your spelling and grammar. -* Create individual PR for each suggestion. +[GitHub pull requests](https://github.com/bendoerr-terraform-modules/terraform-null-label/pulls) + +Contributions are what make the open source community such an amazing place to +be learn, inspire, and create. Any contributions you make are **greatly +appreciated**. + +- If you have suggestions for adding or removing projects, feel free to + [open an issue](https://github.com/bendoerr-terraform-modules/terraform-null-label/issues/new) + to discuss it, or directly create a pull request after you edit the + _README.md_ file with necessary changes. +- Please make sure you check your spelling and grammar. +- Create individual PR for each suggestion. ### Creating A Pull Request @@ -119,13 +176,32 @@ Contributions are what make the open source community such an amazing place to b ## License -Distributed under the MIT License. See [LICENSE](https://github.com/bendoerr-terraform-modules/terraform-null-label/blob/main/LICENSE.txt) for more information. +[GitHub License](https://github.com/bendoerr-terraform-modules/terraform-null-label/blob/main/LICENSE.txt) + +Distributed under the MIT License. See +[LICENSE](https://github.com/bendoerr-terraform-modules/terraform-null-label/blob/main/LICENSE.txt) +for more information. ## Authors -* **Benjamin R. Doerr** - *Terraformer* - [Benjamin R. Doerr](https://github.com/bendoerr/) - *Built Ben's Terraform Modules* +[GitHub contributors](https://github.com/bendoerr-terraform-modules/terraform-null-label/graphs/contributors) + +- **Benjamin R. Doerr** - _Terraformer_ - + [Benjamin R. Doerr](https://github.com/bendoerr/) - _Built Ben's Terraform + Modules_ + +## Supported Versions + +Only the latest tagged version is supported. + +## Reporting a Vulnerability + +See [SECURITY.md](SECURITY.md). ## Acknowledgements -* [ShaanCoding (ReadME Generator)](https://github.com/ShaanCoding/ReadME-Generator) -* [CloudPossie (Terraform Null Label - Inspiration)](https://github.com/cloudposse/terraform-null-label) +- [ShaanCoding (ReadME Generator)](https://github.com/ShaanCoding/ReadME-Generator) +- [CloudPossie (Terraform Null Label - Inspiration)](https://github.com/cloudposse/terraform-null-label) +- [OpenSSF - Helping me follow best practices](https://openssf.org/) +- [StepSecurity - Helping me follow best practices](https://app.stepsecurity.io/) +- [Infracost - Better than AWS Calculator](https://www.infracost.io/) diff --git a/docs/usage-dark.png b/docs/usage-dark.png new file mode 100644 index 0000000..4c11670 Binary files /dev/null and b/docs/usage-dark.png differ diff --git a/docs/usage-light.png b/docs/usage-light.png new file mode 100644 index 0000000..ad4183a Binary files /dev/null and b/docs/usage-light.png differ diff --git a/examples/complete/complete.tfvars b/examples/complete/complete.tfvars index 558c962..8cc1b0c 100644 --- a/examples/complete/complete.tfvars +++ b/examples/complete/complete.tfvars @@ -7,7 +7,7 @@ region_short = "uw2" instance = "demo" instance_short = "dmo" project = "test" -attributes = [ +attributes = [ "attr1" ] tags = { diff --git a/examples/complete/ctx.tf b/examples/complete/ctx.tf index b9ff9b6..b5abe5b 100644 --- a/examples/complete/ctx.tf +++ b/examples/complete/ctx.tf @@ -1,6 +1,6 @@ module "context" { - source = "bendoerr-terraform-modules/context/null" - version = "0.4.1" + source = "bendoerr-terraform-modules/context/null" + version = "0.4.1" namespace = var.namespace environment = var.environment role = var.role @@ -18,8 +18,8 @@ output "context" { } module "context_with_proj" { - source = "bendoerr-terraform-modules/context/null" - version = "0.4.1" + source = "bendoerr-terraform-modules/context/null" + version = "0.4.1" namespace = var.namespace environment = var.environment role = var.role diff --git a/examples/complete/variables.tf b/examples/complete/variables.tf index 88e9754..dc03d57 100644 --- a/examples/complete/variables.tf +++ b/examples/complete/variables.tf @@ -1,5 +1,5 @@ variable "namespace" { - type = string + type = string description = <<-EOT Element to ensure resources are generated with names that are globally unique and do not collide. This should be a short key such as initials. @@ -7,8 +7,8 @@ variable "namespace" { } variable "environment" { - type = string - default = "" + type = string + default = "" description = <<-EOT Element to identify the region and/or the role. If not provided this element defaults to -(-). @@ -16,8 +16,8 @@ variable "environment" { } variable "role" { - type = string - default = "" + type = string + default = "" description = <<-EOT A simple name for the hosting provider account or workspace. Included in tags to ensure that identification is simple across accounts. Examples @@ -26,8 +26,8 @@ variable "role" { } variable "role_short" { - type = string - default = "" + type = string + default = "" description = <<-EOT Shortened version of the 'role'. Automatic shortening is done by removal of vowels unless handled by special @@ -36,16 +36,16 @@ variable "role_short" { } variable "region" { - type = string - default = "" + type = string + default = "" description = <<-EOT Key for the hosting provider region. EOT } variable "region_short" { - type = string - default = "" + type = string + default = "" description = <<-EOT Shortened version of the 'region'. Automatic shortening is done by removal of vowels unless handled by special @@ -54,8 +54,8 @@ variable "region_short" { } variable "instance" { - type = string - default = "" + type = string + default = "" description = <<-EOT Element to identify a tenant or copy of an environment (blue-green deployments). This is not used often. @@ -63,8 +63,8 @@ variable "instance" { } variable "instance_short" { - type = string - default = "" + type = string + default = "" description = <<-EOT Shortened version of the 'instance'. Automatic shortening is done by removal of vowels. @@ -72,14 +72,14 @@ variable "instance_short" { } variable "attributes" { - type = list(string) - default = [] + type = list(string) + default = [] description = "Additional id elements that would be appended." } variable "tags" { - type = map(string) - default = {} + type = map(string) + default = {} description = "Additional tags to include." } @@ -103,7 +103,7 @@ variable "context" { } variable "project" { - type = string - default = "" + type = string + default = "" description = "Name of the project or application, this can override the context's project" } diff --git a/main.tf b/main.tf index 4d93945..b644c8a 100644 --- a/main.tf +++ b/main.tf @@ -22,7 +22,7 @@ locals { var.name, local.gvn_project, var.context.dns_namespace - ) : format( + ) : format( "%s.%s", var.name, var.context.dns_namespace diff --git a/outputs.tf b/outputs.tf index ab3f017..a0913bd 100644 --- a/outputs.tf +++ b/outputs.tf @@ -49,6 +49,6 @@ output "label_order" { } output "dns_name" { - value = local.dns_name + value = local.dns_name description = "Normalized DNS Name" } diff --git a/variables.tf b/variables.tf index 26791ff..486daf0 100644 --- a/variables.tf +++ b/variables.tf @@ -14,15 +14,18 @@ variable "context" { tags = map(string) }) description = "Shared Context from Ben's terraform-null-label" + nullable = false } variable "name" { - type = string + type = string description = "Name of this resource" + nullable = false } variable "project" { - type = string - default = "" + type = string + default = "" description = "Name of the project or application, this can override the context's project" + nullable = false }