diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..83b8bcc --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,10 @@ +--- + +fail_fast: false +minimum_pre_commit_version: "2.6.0" + +repos: + - repo: https://github.com/aws-ia/pre-commit-configs + rev: ce5b80d2643c3510bd17bb309cb767b6b21dc5ea # frozen: 1.4 + hooks: + - id: aws-ia-meta-hook diff --git a/.tflint.hcl b/.tflint.hcl new file mode 100644 index 0000000..063055a --- /dev/null +++ b/.tflint.hcl @@ -0,0 +1,66 @@ +# https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/module-inspection.md +# borrowed & modified indefinitely from https://github.com/ksatirli/building-infrastructure-you-can-mostly-trust/blob/main/.tflint.hcl + +plugin "aws" { + enabled = true + version = "0.12.0" + source = "github.com/terraform-linters/tflint-ruleset-aws" +} + +config { + module = true + force = false +} + +rule "terraform_required_providers" { + enabled = true +} + +rule "terraform_required_version" { + enabled = true +} + +rule "terraform_naming_convention" { + enabled = true + format = "snake_case" +} + +rule "terraform_typed_variables" { + enabled = true +} + +rule "terraform_unused_declarations" { + enabled = true +} + +rule "terraform_comment_syntax" { + enabled = true +} + +rule "terraform_deprecated_index" { + enabled = true +} + +rule "terraform_deprecated_interpolation" { + enabled = true +} + +rule "terraform_documented_outputs" { + enabled = true +} + +rule "terraform_documented_variables" { + enabled = true +} + +rule "terraform_module_pinned_source" { + enabled = true +} + +rule "terraform_standard_module_structure" { + enabled = true +} + +rule "terraform_workspace_remote" { + enabled = true +} diff --git a/examples/basic/outputs.tf b/examples/basic/outputs.tf index 506bb5e..709af85 100644 --- a/examples/basic/outputs.tf +++ b/examples/basic/outputs.tf @@ -1,7 +1,9 @@ output "tags" { - value = module.labels.tags + description = "Output of tags." + value = module.labels.tags } output "id" { - value = module.labels.id + description = "Computed id." + value = module.labels.id } diff --git a/locals.tf b/main.tf similarity index 100% rename from locals.tf rename to main.tf diff --git a/output.tf b/output.tf deleted file mode 100644 index 549cf73..0000000 --- a/output.tf +++ /dev/null @@ -1,27 +0,0 @@ -output "tags" { - value = local.tags -} - -output "tags_aws" { - value = local.tags_aws -} - -output "id" { - value = local.ordered_id -} - -output "name" { - value = local.vars["name"] -} - -output "namespace" { - value = local.vars["namespace"] -} - -output "account" { - value = local.vars["account"] -} - -output "env" { - value = local.vars["env"] -} diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..0b8265f --- /dev/null +++ b/outputs.tf @@ -0,0 +1,34 @@ +output "tags" { + description = "Output of tags in awscc provider format." + value = local.tags +} + +output "tags_aws" { + description = "Output of tags in aws provider format." + value = local.tags_aws +} + +output "id" { + description = "Output of computed id based on inputs to module." + value = local.ordered_id +} + +output "name" { + description = "Name of workload." + value = local.vars["name"] +} + +output "namespace" { + description = "Namespace of workload." + value = local.vars["namespace"] +} + +output "account" { + description = "Account of workload." + value = local.vars["account"] +} + +output "env" { + description = "Environment of workload." + value = local.vars["env"] +} diff --git a/versions.tf b/provider.tf similarity index 53% rename from versions.tf rename to provider.tf index 73c4f88..e2d2acc 100644 --- a/versions.tf +++ b/provider.tf @@ -1,4 +1,5 @@ terraform { + required_version = ">= 0.15.0" required_providers { awscc = { source = "hashicorp/awscc" @@ -10,11 +11,3 @@ terraform { } } } - -provider "awscc" { - user_agent = [{ - product_name = "terraform-awscc-label" - product_version = "0.0.4" - comment = "V1/AWS-D69B4015/376222271" - }] -} diff --git a/variable.tf b/variables.tf similarity index 85% rename from variable.tf rename to variables.tf index 25d9a58..d9446a0 100644 --- a/variable.tf +++ b/variables.tf @@ -1,8 +1,3 @@ -variable "region" { - type = string - default = "us-west-1" -} - variable "namespace" { type = string description = "namespace, which could be your organization name, e.g. amazon" @@ -29,26 +24,26 @@ variable "name" { variable "delimiter" { type = string - description = "delimiter, which could be used between name, namespace and env" + description = "delimiter, which could be used between name, namespace and env." default = "-" } variable "attributes" { type = list(any) default = [] - description = "attributes, which could be used for additional attributes" + description = "attributes, which could be used for additional attributes." } variable "tags" { - description = "tags, which could be used for additional tags" + description = "tags, which could be used for additional tags." type = any default = [] } variable "id_order" { description = "The order in which the `id` is constructed. Default yields `namespace-account-env-name` if your var.delimiter is `-`. Variables that are not populated but order is preserved. Eg: If no `var.namespace` and `var.account` are not specified, yields `env-name`." - type = list(any) - default = ["namespace", "account", "env", "name"] + type = list(any) + default = ["namespace", "account", "env", "name"] validation { condition = anytrue([ contains(var.id_order, "namespace"),