From 07ef26e9f722295093f49881c6c10a43471551ed Mon Sep 17 00:00:00 2001 From: Jakub Igla Date: Wed, 9 Nov 2022 16:55:38 +0100 Subject: [PATCH 1/2] chore: Change examples folder, move examples section from docs yaml --- .terraform-docs.yml | 5 ----- README.md | 15 +++++++-------- {example => examples}/full-example/context.tf | 0 {example => examples}/full-example/main.tf | 0 {example => examples}/full-example/outputs.tf | 0 {example => examples}/full-example/providers.tf | 0 {example => examples}/full-example/versions.tf | 0 locals.tf | 7 +++++++ main.tf | 2 +- 9 files changed, 15 insertions(+), 14 deletions(-) rename {example => examples}/full-example/context.tf (100%) rename {example => examples}/full-example/main.tf (100%) rename {example => examples}/full-example/outputs.tf (100%) rename {example => examples}/full-example/providers.tf (100%) rename {example => examples}/full-example/versions.tf (100%) create mode 100644 locals.tf diff --git a/.terraform-docs.yml b/.terraform-docs.yml index e884c7d..5d31cc9 100644 --- a/.terraform-docs.yml +++ b/.terraform-docs.yml @@ -7,11 +7,6 @@ sections: show: [all] content: |- - ## EXAMPLES - ```hcl - {{ include "example/full-example/main.tf" }} - ``` - {{ .Header }} {{ .Footer }} diff --git a/README.md b/README.md index 6dfab89..3026805 100644 --- a/README.md +++ b/README.md @@ -31,23 +31,22 @@ _Brief Description of MODULE:_ _Example usage of the module - terraform code snippet_ ```terraform +module "template" { + source = "github.com/getindata/terraform-module-template" + + example_var = "foo" +} ``` ## NOTES _Additional information that should be made public, for ex. how to solve known issues, additional descriptions/suggestions_ - ## EXAMPLES -```hcl -module "terraform_module_template" { - source = "../../" - context = module.this.context - example_var = "This is example value." -} -``` +- [Full example](examples/full-example) + diff --git a/example/full-example/context.tf b/examples/full-example/context.tf similarity index 100% rename from example/full-example/context.tf rename to examples/full-example/context.tf diff --git a/example/full-example/main.tf b/examples/full-example/main.tf similarity index 100% rename from example/full-example/main.tf rename to examples/full-example/main.tf diff --git a/example/full-example/outputs.tf b/examples/full-example/outputs.tf similarity index 100% rename from example/full-example/outputs.tf rename to examples/full-example/outputs.tf diff --git a/example/full-example/providers.tf b/examples/full-example/providers.tf similarity index 100% rename from example/full-example/providers.tf rename to examples/full-example/providers.tf diff --git a/example/full-example/versions.tf b/examples/full-example/versions.tf similarity index 100% rename from example/full-example/versions.tf rename to examples/full-example/versions.tf diff --git a/locals.tf b/locals.tf new file mode 100644 index 0000000..d55ec57 --- /dev/null +++ b/locals.tf @@ -0,0 +1,7 @@ +locals { + # Get a name from the descriptor. If not available, use default naming convention. + # Trim and replace function are used to avoid bare delimiters on both ends of the name and situation of adjacent delimiters. + name_from_descriptor = trim(replace( + lookup(module.this.descriptors, "module-resource-name", module.this.id), "/${module.this.delimiter}${module.this.delimiter}+/", "" + ), module.this.delimiter) +} diff --git a/main.tf b/main.tf index 05de9d9..065807b 100644 --- a/main.tf +++ b/main.tf @@ -2,8 +2,8 @@ # echoes it's base64 encoded version locally resource "null_resource" "output_input" { - triggers = { + name = local.name_from_descriptor input = var.example_var } From d3b6d67b39b2e701790fbd100b2004c5ada69b88 Mon Sep 17 00:00:00 2001 From: Jakub Igla Date: Wed, 9 Nov 2022 16:58:03 +0100 Subject: [PATCH 2/2] chore: Better gitignore file --- .gitignore | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.gitignore b/.gitignore index bd892e0..5a4b0d9 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,21 @@ crash.log # terraform.lock.hcl files .terraform.lock.hcl + +# Exclude all .tfvars files, which are likely to contain sentitive data, such as +# password, private keys, and other secrets. These should not be part of version +# control as they are data points which are potentially sensitive and subject +# to change depending on the environment. +# +terraform.tfvars + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Include override files you do wish to add to version control using negated pattern +# +# !example_override.tf