From 5bf40e23ac8da13c54f9528635cbf02bd646e6ec Mon Sep 17 00:00:00 2001 From: drewmullen Date: Thu, 28 Apr 2022 08:13:31 -0400 Subject: [PATCH 1/6] rm embedded provider --- versions.tf | 8 -------- 1 file changed, 8 deletions(-) diff --git a/versions.tf b/versions.tf index 73c4f88..63dde1b 100644 --- a/versions.tf +++ b/versions.tf @@ -10,11 +10,3 @@ terraform { } } } - -provider "awscc" { - user_agent = [{ - product_name = "terraform-awscc-label" - product_version = "0.0.4" - comment = "V1/AWS-D69B4015/376222271" - }] -} From 5c77db357e4d43ab252799dbdc24937183382909 Mon Sep 17 00:00:00 2001 From: drewmullen Date: Thu, 28 Apr 2022 08:18:11 -0400 Subject: [PATCH 2/6] fmt --- variable.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/variable.tf b/variable.tf index 25d9a58..76f5502 100644 --- a/variable.tf +++ b/variable.tf @@ -47,8 +47,8 @@ variable "tags" { 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"), From 9ec6a658f1320efc9a29af2bc2e9b4338d16ba7e Mon Sep 17 00:00:00 2001 From: drewmullen Date: Thu, 28 Apr 2022 08:33:06 -0400 Subject: [PATCH 3/6] include pre-commit --- .pre-commit-config.yaml | 10 +++++++ .tflint.hcl | 66 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 .tflint.hcl 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 +} From d29c1b1d5510d605651af324ffb1167654790cea Mon Sep 17 00:00:00 2001 From: drewmullen Date: Thu, 28 Apr 2022 08:34:36 -0400 Subject: [PATCH 4/6] Update descriptions --- variable.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/variable.tf b/variable.tf index 76f5502..da004b8 100644 --- a/variable.tf +++ b/variable.tf @@ -29,18 +29,18 @@ 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 = [] } From 0ee6300b45e817c2c843d0fa10a392d951a1405d Mon Sep 17 00:00:00 2001 From: drewmullen Date: Thu, 28 Apr 2022 08:43:47 -0400 Subject: [PATCH 5/6] tflint --- examples/basic/outputs.tf | 6 ++++-- locals.tf => main.tf | 0 output.tf | 27 --------------------------- outputs.tf | 34 ++++++++++++++++++++++++++++++++++ versions.tf => provider.tf | 1 + variable.tf => variables.tf | 5 ----- 6 files changed, 39 insertions(+), 34 deletions(-) rename locals.tf => main.tf (100%) delete mode 100644 output.tf create mode 100644 outputs.tf rename versions.tf => provider.tf (85%) rename variable.tf => variables.tf (96%) diff --git a/examples/basic/outputs.tf b/examples/basic/outputs.tf index 506bb5e..fdde41a 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..34aec67 --- /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 85% rename from versions.tf rename to provider.tf index 63dde1b..e2d2acc 100644 --- a/versions.tf +++ b/provider.tf @@ -1,4 +1,5 @@ terraform { + required_version = ">= 0.15.0" required_providers { awscc = { source = "hashicorp/awscc" diff --git a/variable.tf b/variables.tf similarity index 96% rename from variable.tf rename to variables.tf index da004b8..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" From 27b1c703e40e3d44887d333d21afbc141eba2816 Mon Sep 17 00:00:00 2001 From: drewmullen Date: Thu, 28 Apr 2022 10:16:08 -0400 Subject: [PATCH 6/6] output sentence casing --- examples/basic/outputs.tf | 4 ++-- outputs.tf | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/basic/outputs.tf b/examples/basic/outputs.tf index fdde41a..709af85 100644 --- a/examples/basic/outputs.tf +++ b/examples/basic/outputs.tf @@ -1,9 +1,9 @@ output "tags" { - description = "output of tags." + description = "Output of tags." value = module.labels.tags } output "id" { - description = "computed id." + description = "Computed id." value = module.labels.id } diff --git a/outputs.tf b/outputs.tf index 34aec67..0b8265f 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,34 +1,34 @@ output "tags" { - description = "output of tags in awscc provider format." + description = "Output of tags in awscc provider format." value = local.tags } output "tags_aws" { - description = "output of tags in aws provider format." + description = "Output of tags in aws provider format." value = local.tags_aws } output "id" { - description = "output of computed id based on inputs to module." + description = "Output of computed id based on inputs to module." value = local.ordered_id } output "name" { - description = "name of workload." + description = "Name of workload." value = local.vars["name"] } output "namespace" { - description = "namespace of workload." + description = "Namespace of workload." value = local.vars["namespace"] } output "account" { - description = "account of workload." + description = "Account of workload." value = local.vars["account"] } output "env" { - description = "environment of workload." + description = "Environment of workload." value = local.vars["env"] }