Skip to content

bendoerr-terraform-modules/terraform-null-context

Repository files navigation


Logo

Ben's Terraform Null Context Module

This is how I do it.

Explore the docs »

Report Bug . Request Feature

GitHub contributors GitHub issues GitHub pull requests GitHub workflow: Terratest GitHub workflow: Linting GitHub tag (with filter) OSSF-Scorecard Score GitHub License

About The Project

My opinionated context module that integrates with my other Terraform modules.

Logo

This Terraform module simplifies the process of passing common values, such as project names and namespaces, to ensure consistent naming and tagging across various Terraform modules. The module normalizes and carries these values in a compact, ready-to-use format. It's designed to be consumed in conjunction with the terraform-null-label module. The context generated by terraform-null-context is utilized by terraform-null-label to produce consistent names and tags for different components.

Usage

module "context" {
  source  = "bendoerr-terraform-modules/context/null"
  version = "xxx"

  namespace = "bd"
  role      = "production"
  region    = "us-east-1"
  project   = "example"
}

Cost

infracost

Project: bendoerr-terraform-modules/terraform-null-context

 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 >= 0.13

Inputs

Name Description Type Default Required
attributes Additional id elements that would be appended. list(string) [] no
context Allows the merging of an existing context with this one. any
{
"attributes": [],
"dns_namespace": "",
"environment": "",
"instance": "",
"instance_short": "",
"namespace": "",
"project": "",
"region": "",
"region_short": "",
"role": "",
"role_short": "",
"tags": {}
}
no
environment Element to identify the region and/or the role. If not provided this element
defaults to <role_short>-<region_short>(-<instance_short>).
string "" no
instance Element to identify a tenant or copy of an environment (blue-green
deployments). This is not used often.
string "" no
instance_short Shortened version of the 'instance'.
Automatic shortening is done by removal of vowels.
string "" no
namespace 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.
string n/a yes
project Unique identifier for this project string "" no
region Key for the hosting provider region. string n/a yes
region_short Shortened version of the 'region'.
Automatic shortening is done by removal of vowels unless handled by special
cases such as 'us-east-1' => 'ue1', or 'us-west-2' => 'uw2'.
string "" no
role A simple name for the hosting provider account or workspace. Included in
tags to ensure that identification is simple across accounts. Examples
'production', 'development', 'main'.
string n/a yes
role_short Shortened version of the 'role'.
Automatic shortening is done by removal of vowels unless handled by special
cases such as 'production' => 'prod', or 'development' => 'dev'.
string "" no
tags Additional tags to include. map(string) {} no

Outputs

Name Description
attributes The evaluated attributes
dns_namespace A DNS namespace
environment The evaluated environment
instance The evaluated instance
instance_short The evaluated instance
namespace The evaluated namespace
project The evaluated project
region The evaluated region
region_short The evaluated region
role The evaluated role
role_short The evaluated role
shared Used for sharing the context with other modules
tags The evaluated tags

Roadmap

GitHub issues

See the open issues for a list of proposed features (and known issues).

Contributing

GitHub pull requests

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 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

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

GitHub License

Distributed under the MIT License. See LICENSE for more information.

Authors

GitHub contributors

  • Benjamin R. Doerr - Terraformer - Benjamin R. Doerr - Built Ben's Terraform Modules

Supported Versions

Only the latest tagged version is supported.

Reporting a Vulnerability

See SECURITY.md.

Acknowledgements