diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml
index 22fbe6c..7db5a4a 100644
--- a/.github/workflows/pre-commit.yml
+++ b/.github/workflows/pre-commit.yml
@@ -8,7 +8,6 @@ on:
env:
TERRAFORM_DOCS_VERSION: v0.16.0
- # TFLINT_VERSION: v0.41.0 # use this version with "Invicton-Labs/deepmerge/null" module
jobs:
collectInputs:
diff --git a/.gitignore b/.gitignore
index 5a4b0d9..31f9544 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,7 @@ override.tf.json
# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf
+
+# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
+# example: *tfplan*
+*tfplan*
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index ef1de7a..087cdd1 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -16,9 +16,10 @@ repos:
args: ["."]
- repo: https://github.com/bridgecrewio/checkov.git
- rev: "2.2.168" # Get the latest from: https://github.com/bridgecrewio/checkov/releases
+ rev: "2.2.246" # Get the latest from: https://github.com/bridgecrewio/checkov/releases
hooks:
- id: checkov
+ args: [--skip-check, "CKV2_GHA_1"] #Flase positive for top-level permissions
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.3.0" # Get the latest from: https://github.com/pre-commit/pre-commit-hooks/releases
diff --git a/.tflint.hcl b/.tflint.hcl
index e3aef49..b3cc62f 100644
--- a/.tflint.hcl
+++ b/.tflint.hcl
@@ -1,3 +1,9 @@
+config {
+ ignore_module = {
+ "Invicton-Labs/deepmerge/null" = true
+ }
+}
+
rule "terraform_deprecated_interpolation" {
enabled = true
}
diff --git a/README.md b/README.md
index 8b92dc8..f3bd620 100644
--- a/README.md
+++ b/README.md
@@ -36,7 +36,8 @@ _Example usage of the module - terraform code snippet_
```terraform
module "template" {
- source = "github.com/getindata/terraform-module-template"
+ source = "getindata/template/null"
+ # version = "x.x.x"
example_var = "foo"
}
@@ -48,7 +49,8 @@ _Additional information that should be made public, for ex. how to solve known i
## EXAMPLES
-- [Full example](examples/full-example)
+- [Simple](examples/simple) - Basic usage of the module
+- [Complete](examples/complete) - Advanced usage of the module
@@ -101,7 +103,7 @@ _Additional information that should be made public, for ex. how to solve known i
| Name | Version |
|------|---------|
-| [terraform](#requirement\_terraform) | >= 0.13.0 |
+| [terraform](#requirement\_terraform) | >= 0.15.0 |
| [null](#requirement\_null) | 3.1.1 |
## Resources
diff --git a/examples/complete/.env.dist b/examples/complete/.env.dist
new file mode 100644
index 0000000..e69de29
diff --git a/examples/complete/.envrc b/examples/complete/.envrc
new file mode 100644
index 0000000..e948662
--- /dev/null
+++ b/examples/complete/.envrc
@@ -0,0 +1,2 @@
+#Override defaults
+command -v dotenv && test -f .env && dotenv
diff --git a/examples/complete/Makefile b/examples/complete/Makefile
new file mode 100644
index 0000000..e5cd98f
--- /dev/null
+++ b/examples/complete/Makefile
@@ -0,0 +1,11 @@
+init:
+ terraform init
+
+plan:
+ terraform plan -var-file fixtures.tfvars -out tfplan
+
+apply:
+ terraform apply tfplan
+
+destroy:
+ terraform destroy -var-file fixtures.tfvars
diff --git a/examples/complete/README.md b/examples/complete/README.md
new file mode 100644
index 0000000..ef8f8b0
--- /dev/null
+++ b/examples/complete/README.md
@@ -0,0 +1,17 @@
+# Complete Example
+
+```terraform
+module "terraform_module_template" {
+ source = "../../"
+ context = module.this.context
+
+ example_var = "This is a example value."
+}
+```
+
+## Usage
+```
+terraform init
+terraform plan -var-file fixtures.tfvars -out tfplan
+terraform apply tfplan
+```
diff --git a/examples/full-example/context.tf b/examples/complete/context.tf
similarity index 100%
rename from examples/full-example/context.tf
rename to examples/complete/context.tf
diff --git a/examples/complete/fixtures.tfvars b/examples/complete/fixtures.tfvars
new file mode 100644
index 0000000..11358b0
--- /dev/null
+++ b/examples/complete/fixtures.tfvars
@@ -0,0 +1,7 @@
+descriptor_formats = {
+
+}
+
+tags = {
+ Terraform = "True"
+}
diff --git a/examples/full-example/main.tf b/examples/complete/main.tf
similarity index 100%
rename from examples/full-example/main.tf
rename to examples/complete/main.tf
diff --git a/examples/full-example/outputs.tf b/examples/complete/outputs.tf
similarity index 100%
rename from examples/full-example/outputs.tf
rename to examples/complete/outputs.tf
diff --git a/examples/full-example/providers.tf b/examples/complete/providers.tf
similarity index 100%
rename from examples/full-example/providers.tf
rename to examples/complete/providers.tf
diff --git a/examples/full-example/versions.tf b/examples/complete/versions.tf
similarity index 78%
rename from examples/full-example/versions.tf
rename to examples/complete/versions.tf
index ea4e1c7..45a914e 100644
--- a/examples/full-example/versions.tf
+++ b/examples/complete/versions.tf
@@ -1,5 +1,5 @@
terraform {
- required_version = ">= 0.13.0"
+ required_version = ">= 0.15.0"
required_providers {
null = {
diff --git a/examples/simple/.env.dist b/examples/simple/.env.dist
new file mode 100644
index 0000000..e69de29
diff --git a/examples/simple/.envrc b/examples/simple/.envrc
new file mode 100644
index 0000000..e948662
--- /dev/null
+++ b/examples/simple/.envrc
@@ -0,0 +1,2 @@
+#Override defaults
+command -v dotenv && test -f .env && dotenv
diff --git a/examples/simple/Makefile b/examples/simple/Makefile
new file mode 100644
index 0000000..9d9205a
--- /dev/null
+++ b/examples/simple/Makefile
@@ -0,0 +1,11 @@
+init:
+ terraform init
+
+plan:
+ terraform plan -out tfplan
+
+apply:
+ terraform apply tfplan
+
+destroy:
+ terraform destroy
diff --git a/examples/simple/README.md b/examples/simple/README.md
new file mode 100644
index 0000000..4d14a83
--- /dev/null
+++ b/examples/simple/README.md
@@ -0,0 +1,16 @@
+# Simple Example
+
+```terraform
+module "terraform_module_template" {
+ source = "../../"
+
+ example_var = "This is a example value."
+}
+```
+
+## Usage
+```
+terraform init
+terraform plan -out tfplan
+terraform apply tfplan
+```
diff --git a/examples/simple/main.tf b/examples/simple/main.tf
new file mode 100644
index 0000000..ca1dd7c
--- /dev/null
+++ b/examples/simple/main.tf
@@ -0,0 +1,5 @@
+module "terraform_module_template" {
+ source = "../../"
+
+ example_var = "This is a example value."
+}
diff --git a/examples/simple/outputs.tf b/examples/simple/outputs.tf
new file mode 100644
index 0000000..c2007a2
--- /dev/null
+++ b/examples/simple/outputs.tf
@@ -0,0 +1,4 @@
+output "example_output" {
+ description = "Example output of the module"
+ value = module.terraform_module_template
+}
diff --git a/examples/simple/providers.tf b/examples/simple/providers.tf
new file mode 100644
index 0000000..c793099
--- /dev/null
+++ b/examples/simple/providers.tf
@@ -0,0 +1,3 @@
+provider "null" {
+ # Configuration options
+}
diff --git a/examples/simple/versions.tf b/examples/simple/versions.tf
new file mode 100644
index 0000000..45a914e
--- /dev/null
+++ b/examples/simple/versions.tf
@@ -0,0 +1,10 @@
+terraform {
+ required_version = ">= 0.15.0"
+
+ required_providers {
+ null = {
+ source = "hashicorp/null"
+ version = "3.1.1"
+ }
+ }
+}
diff --git a/locals.tf b/locals.tf
index d55ec57..c457489 100644
--- a/locals.tf
+++ b/locals.tf
@@ -2,6 +2,8 @@ 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}+/", ""
+ lookup(module.this.descriptors, "module-resource-name", module.this.id), "/${module.this.delimiter}${module.this.delimiter}+/", module.this.delimiter
), module.this.delimiter)
+
+ enabled = module.this.enabled
}
diff --git a/main.tf b/main.tf
index 065807b..12bec12 100644
--- a/main.tf
+++ b/main.tf
@@ -2,6 +2,8 @@
# echoes it's base64 encoded version locally
resource "null_resource" "output_input" {
+ count = local.enabled ? 1 : 0
+
triggers = {
name = local.name_from_descriptor
input = var.example_var
diff --git a/outputs.tf b/outputs.tf
index 6f13a49..b1bbafe 100644
--- a/outputs.tf
+++ b/outputs.tf
@@ -2,5 +2,5 @@
output "example_output" {
description = "Example output of the module"
- value = var.example_var
+ value = one(null_resource.output_input[*].id)
}
diff --git a/versions.tf b/versions.tf
index 32b2f24..b3db12c 100644
--- a/versions.tf
+++ b/versions.tf
@@ -1,7 +1,7 @@
# Example configuration of terraform providers
terraform {
- required_version = ">= 0.13.0"
+ required_version = ">= 0.15.0"
required_providers {
null = {