commit 163879aacac574ec5b602fa7c7a262f15ec45d9f Author: Josuani Date: Mon Feb 19 19:12:32 2024 +0000 Initial commit diff --git a/.terraform-docs.yml b/.terraform-docs.yml new file mode 100644 index 0000000..b844f1f --- /dev/null +++ b/.terraform-docs.yml @@ -0,0 +1,65 @@ +--- +formatter: "markdown table" +version: "0.16" +header-from: ./docs/header.md +sections: + show: + - data-sources + - header + - footer + - inputs + - modules + - outputs + - providers + - requirements + - resources +content: |- + {{ .Header }} + {{ .Requirements }} + {{ .Providers }} + {{ .Modules }} + ## Usage + Basic usage of this module is as follows: + ```hcl + module "example" { + {{"\t"}} source = "" + {{- if .Module.RequiredInputs }} + {{"\n\t"}} # Required variables + {{- range .Module.RequiredInputs }} + {{"\t"}} {{ .Name }} = {{ .GetValue }} + {{- end }} + {{- end }} + {{- if .Module.OptionalInputs }} + {{"\n\t"}} # Optional variables + {{- range .Module.OptionalInputs }} + {{"\t"}} {{ .Name }} = {{ .GetValue | printf "%s" }} + {{- end }} + {{- end }} + } + ``` + {{ .Resources }} + {{ .Inputs }} + {{ .Outputs }} +output: + file: README.md + mode: inject + template: |- + + {{ .Content }} + +sort: + enabled: true + by: name +settings: + anchor: true + color: true + default: true + description: true + escape: false + hide-empty: false + html: true + indent: 2 + lockfile: true + required: true + sensitive: true + type: true diff --git a/README.md b/README.md new file mode 100644 index 0000000..4404c9b --- /dev/null +++ b/README.md @@ -0,0 +1,84 @@ + +Terraform NAME Module +======================== + +## Overview + +Description of what the module does +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement_terraform) | >= 1.0 | +## Providers + +No providers. +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [default_label](#module_default_label) | git@gitlab.com:zulunity/terraform/modules/general/label.git | 0.0.0 | +## Usage +Basic usage of this module is as follows: +```hcl +module "example" { + source = "" + + # Optional variables + account = null + attributes = [] + cloud_provider = null + context = { + "account": null, + "additional_tag_map": {}, + "attributes": [], + "cloud_provider": null, + "delimiter": null, + "enabled": true, + "environment": null, + "id_length_limit": null, + "label_order": [], + "name": null, + "namespace": null, + "regex_replace_chars": null, + "region": null, + "stage": null, + "tags": {} +} + domain = null + enabled = true + environment = null + name = "hi" + namespace = null + region = null + stage = null + tags = {} +} +``` +## Resources + +No resources. +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [account](#input_account) | Name of the account being used (master, nonprod, prod, etc) | `string` | `null` | no | +| [attributes](#input_attributes) | Additional attributes (e.g. `1`) | `list(string)` | `[]` | no | +| [cloud_provider](#input_cloud_provider) | Cloud provider name if any | `string` | `null` | no | +| [context](#input_context) | Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as `null` to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional_tag_map, which are merged. |
object({
enabled = bool
namespace = string
cloud_provider = string
account = string
region = string
environment = string
stage = string
name = string
delimiter = string
attributes = list(string)
tags = map(string)
additional_tag_map = map(string)
regex_replace_chars = string
label_order = list(string)
id_length_limit = number
})
|
{
"account": null,
"additional_tag_map": {},
"attributes": [],
"cloud_provider": null,
"delimiter": null,
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_order": [],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"region": null,
"stage": null,
"tags": {}
}
| no | +| [domain](#input_domain) | TLD to use when deploying assets | `string` | `null` | no | +| [enabled](#input_enabled) | Set to false to prevent the module from creating any resources | `bool` | `true` | no | +| [environment](#input_environment) | Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT' | `string` | `null` | no | +| [name](#input_name) | Module name, e.g. 'app' or 'jenkins' | `string` | `"hi"` | no | +| [namespace](#input_namespace) | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no | +| [region](#input_region) | AWS region to deploy asset into | `string` | `null` | no | +| [stage](#input_stage) | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no | +| [tags](#input_tags) | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no | +## Outputs + +| Name | Description | +|------|-------------| +| [context](#output_context) | Default label context | +| [enabled](#output_enabled) | Whether or not the module is enabled | +| [name](#output_name) | Name of the asset | + \ No newline at end of file diff --git a/docs/header.md b/docs/header.md new file mode 100644 index 0000000..fbbee92 --- /dev/null +++ b/docs/header.md @@ -0,0 +1,6 @@ +Terraform NAME Module +======================== + +## Overview + +Description of what the module does diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..1bc1164 --- /dev/null +++ b/main.tf @@ -0,0 +1,11 @@ +# Local +locals { + tags = {} +} + +# Label +module "default_label" { + source = "git@gitlab.com:zulunity/terraform/modules/general/label.git?ref=0.0.0" + name = var.name + tags = merge(var.tags, local.tags) +} diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..b216383 --- /dev/null +++ b/outputs.tf @@ -0,0 +1,17 @@ +# Standard Outputs +output "name" { + description = "Name of the asset" + value = module.default_label.id +} + +output "context" { + description = "Default label context" + value = module.default_label.context +} + +output "enabled" { + description = "Whether or not the module is enabled" + value = var.enabled +} + +# Module Outputs diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..f10bca3 --- /dev/null +++ b/variables.tf @@ -0,0 +1,122 @@ +### +# Standard Variables +# +# All modules expect these variables to be defined. Omitting them will result in errors or undefined/undesirable behavior. +# +# tflint-ignore: terraform_unused_declarations +variable "account" { + type = string + default = null + description = "Name of the account being used (master, nonprod, prod, etc)" +} + +# tflint-ignore: terraform_unused_declarations +variable "attributes" { + type = list(string) + default = [] + description = "Additional attributes (e.g. `1`)" +} +# tflint-ignore: terraform_unused_declarations +variable "cloud_provider" { + type = string + default = null + description = "Cloud provider name if any" +} +# tflint-ignore: terraform_unused_declarations +variable "context" { + type = object({ + enabled = bool + namespace = string + cloud_provider = string + account = string + region = string + environment = string + stage = string + name = string + delimiter = string + attributes = list(string) + tags = map(string) + additional_tag_map = map(string) + regex_replace_chars = string + label_order = list(string) + id_length_limit = number + }) + default = { + enabled = true + namespace = null + cloud_provider = null + account = null + region = null + environment = null + stage = null + name = null + delimiter = null + attributes = [] + tags = {} + additional_tag_map = {} + regex_replace_chars = null + label_order = [] + id_length_limit = null + } + description = <<-EOT + Single object for setting entire context at once. + See description of individual variables for details. + Leave string and numeric variables as `null` to use default value. + Individual variable settings (non-null) override settings in context object, + except for attributes, tags, and additional_tag_map, which are merged. + EOT +} +# tflint-ignore: terraform_unused_declarations +variable "domain" { + type = string + default = null + description = "TLD to use when deploying assets" +} +# tflint-ignore: terraform_unused_declarations +variable "enabled" { + type = bool + default = true + description = "Set to false to prevent the module from creating any resources" +} +# tflint-ignore: terraform_unused_declarations +variable "environment" { + type = string + default = null + description = "Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT'" +} + +variable "name" { + type = string + default = "hi" + description = "Module name, e.g. 'app' or 'jenkins'" +} +# tflint-ignore: terraform_unused_declarations +variable "namespace" { + type = string + default = null + description = "Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp'" +} +# tflint-ignore: terraform_unused_declarations +variable "region" { + type = string + default = null + description = "AWS region to deploy asset into" +} +# tflint-ignore: terraform_unused_declarations +variable "stage" { + type = string + default = null + description = "Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release'" +} +# tflint-ignore: terraform_unused_declarations +variable "tags" { + type = map(string) + default = {} + description = "Additional tags (e.g. `map('BusinessUnit','XYZ')`" +} + +### +# Module Variables +# +# Variables specific to this module +# diff --git a/versions.tf b/versions.tf new file mode 100644 index 0000000..7117131 --- /dev/null +++ b/versions.tf @@ -0,0 +1,3 @@ +terraform { + required_version = ">= 1.0" +}