diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8fbf9401..a0f27228 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,14 +3,17 @@ repos: rev: v1.96.1 hooks: - id: terraform_fmt + - id: terraform_wrapper_module_for_each - id: terraform_docs args: - '--args=--lockfile=false' - id: terraform_validate - exclude: '^modules/_templates/[^/]+$' + exclude: '^modules/_templates/[^/]+$|^wrappers/.+$' - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 hooks: - id: check-merge-conflict - id: end-of-file-fixer - id: trailing-whitespace + - id: mixed-line-ending + args: [--fix=lf] diff --git a/wrappers/README.md b/wrappers/README.md new file mode 100644 index 00000000..1fde665b --- /dev/null +++ b/wrappers/README.md @@ -0,0 +1,100 @@ +# Wrapper for the root module + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/_templates/README.md b/wrappers/_templates/README.md new file mode 100644 index 00000000..4880c4df --- /dev/null +++ b/wrappers/_templates/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/_templates` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/_templates" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/_templates?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/_templates" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/_templates/main.tf b/wrappers/_templates/main.tf new file mode 100644 index 00000000..a63ed9f1 --- /dev/null +++ b/wrappers/_templates/main.tf @@ -0,0 +1,67 @@ +module "wrapper" { + source = "../../modules/_templates" + + for_each = var.items + + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/_templates/outputs.tf b/wrappers/_templates/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/_templates/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/_templates/variables.tf b/wrappers/_templates/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/_templates/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/_templates/versions.tf b/wrappers/_templates/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/_templates/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/activemq/README.md b/wrappers/activemq/README.md new file mode 100644 index 00000000..310b5e9d --- /dev/null +++ b/wrappers/activemq/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/activemq` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/activemq" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/activemq?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/activemq" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/activemq/main.tf b/wrappers/activemq/main.tf new file mode 100644 index 00000000..a8e048ba --- /dev/null +++ b/wrappers/activemq/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/activemq" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["activemq-5671-tcp", "activemq-8883-tcp", "activemq-61614-tcp", "activemq-61617-tcp", "activemq-61619-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/activemq/outputs.tf b/wrappers/activemq/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/activemq/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/activemq/variables.tf b/wrappers/activemq/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/activemq/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/activemq/versions.tf b/wrappers/activemq/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/activemq/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/alertmanager/README.md b/wrappers/alertmanager/README.md new file mode 100644 index 00000000..4810b02e --- /dev/null +++ b/wrappers/alertmanager/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/alertmanager` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/alertmanager" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/alertmanager?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/alertmanager" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/alertmanager/main.tf b/wrappers/alertmanager/main.tf new file mode 100644 index 00000000..93e495cf --- /dev/null +++ b/wrappers/alertmanager/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/alertmanager" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["alertmanager-9093-tcp", "alertmanager-9094-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/alertmanager/outputs.tf b/wrappers/alertmanager/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/alertmanager/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/alertmanager/variables.tf b/wrappers/alertmanager/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/alertmanager/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/alertmanager/versions.tf b/wrappers/alertmanager/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/alertmanager/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/carbon-relay-ng/README.md b/wrappers/carbon-relay-ng/README.md new file mode 100644 index 00000000..71246ee8 --- /dev/null +++ b/wrappers/carbon-relay-ng/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/carbon-relay-ng` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/carbon-relay-ng" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/carbon-relay-ng?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/carbon-relay-ng" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/carbon-relay-ng/main.tf b/wrappers/carbon-relay-ng/main.tf new file mode 100644 index 00000000..a54d5b8f --- /dev/null +++ b/wrappers/carbon-relay-ng/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/carbon-relay-ng" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["carbon-line-in-tcp", "carbon-line-in-udp", "carbon-pickle-tcp", "carbon-pickle-udp", "carbon-gui-udp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/carbon-relay-ng/outputs.tf b/wrappers/carbon-relay-ng/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/carbon-relay-ng/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/carbon-relay-ng/variables.tf b/wrappers/carbon-relay-ng/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/carbon-relay-ng/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/carbon-relay-ng/versions.tf b/wrappers/carbon-relay-ng/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/carbon-relay-ng/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/cassandra/README.md b/wrappers/cassandra/README.md new file mode 100644 index 00000000..8edfb5b3 --- /dev/null +++ b/wrappers/cassandra/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/cassandra` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/cassandra" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/cassandra?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/cassandra" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/cassandra/main.tf b/wrappers/cassandra/main.tf new file mode 100644 index 00000000..c7c2854d --- /dev/null +++ b/wrappers/cassandra/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/cassandra" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["cassandra-clients-tcp", "cassandra-thrift-clients-tcp", "cassandra-jmx-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/cassandra/outputs.tf b/wrappers/cassandra/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/cassandra/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/cassandra/variables.tf b/wrappers/cassandra/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/cassandra/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/cassandra/versions.tf b/wrappers/cassandra/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/cassandra/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/consul/README.md b/wrappers/consul/README.md new file mode 100644 index 00000000..dd8324ff --- /dev/null +++ b/wrappers/consul/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/consul` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/consul" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/consul?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/consul" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/consul/main.tf b/wrappers/consul/main.tf new file mode 100644 index 00000000..f094982f --- /dev/null +++ b/wrappers/consul/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/consul" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["consul-tcp", "consul-grpc-tcp", "consul-grpc-tcp-tls", "consul-webui-http-tcp", "consul-webui-https-tcp", "consul-dns-tcp", "consul-dns-udp", "consul-serf-lan-tcp", "consul-serf-lan-udp", "consul-serf-wan-tcp", "consul-serf-wan-udp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/consul/outputs.tf b/wrappers/consul/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/consul/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/consul/variables.tf b/wrappers/consul/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/consul/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/consul/versions.tf b/wrappers/consul/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/consul/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/dax-cluster/README.md b/wrappers/dax-cluster/README.md new file mode 100644 index 00000000..a9207bde --- /dev/null +++ b/wrappers/dax-cluster/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/dax-cluster` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/dax-cluster" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/dax-cluster?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/dax-cluster" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/dax-cluster/main.tf b/wrappers/dax-cluster/main.tf new file mode 100644 index 00000000..9bec23c7 --- /dev/null +++ b/wrappers/dax-cluster/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/dax-cluster" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["dax-cluster-unencrypted-tcp", "dax-cluster-encrypted-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/dax-cluster/outputs.tf b/wrappers/dax-cluster/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/dax-cluster/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/dax-cluster/variables.tf b/wrappers/dax-cluster/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/dax-cluster/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/dax-cluster/versions.tf b/wrappers/dax-cluster/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/dax-cluster/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/docker-swarm/README.md b/wrappers/docker-swarm/README.md new file mode 100644 index 00000000..b4b3a6e0 --- /dev/null +++ b/wrappers/docker-swarm/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/docker-swarm` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/docker-swarm" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/docker-swarm?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/docker-swarm" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/docker-swarm/main.tf b/wrappers/docker-swarm/main.tf new file mode 100644 index 00000000..0f867d10 --- /dev/null +++ b/wrappers/docker-swarm/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/docker-swarm" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["docker-swarm-mngmt-tcp", "docker-swarm-node-tcp", "docker-swarm-node-udp", "docker-swarm-overlay-udp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/docker-swarm/outputs.tf b/wrappers/docker-swarm/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/docker-swarm/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/docker-swarm/variables.tf b/wrappers/docker-swarm/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/docker-swarm/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/docker-swarm/versions.tf b/wrappers/docker-swarm/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/docker-swarm/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/elasticsearch/README.md b/wrappers/elasticsearch/README.md new file mode 100644 index 00000000..d1c1dccb --- /dev/null +++ b/wrappers/elasticsearch/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/elasticsearch` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/elasticsearch" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/elasticsearch?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/elasticsearch" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/elasticsearch/main.tf b/wrappers/elasticsearch/main.tf new file mode 100644 index 00000000..324df290 --- /dev/null +++ b/wrappers/elasticsearch/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/elasticsearch" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["elasticsearch-rest-tcp", "elasticsearch-java-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/elasticsearch/outputs.tf b/wrappers/elasticsearch/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/elasticsearch/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/elasticsearch/variables.tf b/wrappers/elasticsearch/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/elasticsearch/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/elasticsearch/versions.tf b/wrappers/elasticsearch/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/elasticsearch/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/etcd/README.md b/wrappers/etcd/README.md new file mode 100644 index 00000000..a7d3590f --- /dev/null +++ b/wrappers/etcd/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/etcd` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/etcd" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/etcd?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/etcd" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/etcd/main.tf b/wrappers/etcd/main.tf new file mode 100644 index 00000000..ef6995fd --- /dev/null +++ b/wrappers/etcd/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/etcd" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["etcd-client-tcp", "etcd-peer-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/etcd/outputs.tf b/wrappers/etcd/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/etcd/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/etcd/variables.tf b/wrappers/etcd/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/etcd/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/etcd/versions.tf b/wrappers/etcd/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/etcd/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/grafana/README.md b/wrappers/grafana/README.md new file mode 100644 index 00000000..fbbbdc93 --- /dev/null +++ b/wrappers/grafana/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/grafana` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/grafana" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/grafana?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/grafana" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/grafana/main.tf b/wrappers/grafana/main.tf new file mode 100644 index 00000000..90732969 --- /dev/null +++ b/wrappers/grafana/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/grafana" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["grafana-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/grafana/outputs.tf b/wrappers/grafana/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/grafana/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/grafana/variables.tf b/wrappers/grafana/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/grafana/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/grafana/versions.tf b/wrappers/grafana/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/grafana/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/graphite-statsd/README.md b/wrappers/graphite-statsd/README.md new file mode 100644 index 00000000..489a1bb1 --- /dev/null +++ b/wrappers/graphite-statsd/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/graphite-statsd` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/graphite-statsd" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/graphite-statsd?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/graphite-statsd" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/graphite-statsd/main.tf b/wrappers/graphite-statsd/main.tf new file mode 100644 index 00000000..5a84f89e --- /dev/null +++ b/wrappers/graphite-statsd/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/graphite-statsd" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["graphite-webui", "graphite-2003-tcp", "graphite-2004-tcp", "graphite-2023-tcp", "graphite-2024-tcp", "graphite-8080-tcp", "graphite-8125-tcp", "graphite-8125-udp", "graphite-8126-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/graphite-statsd/outputs.tf b/wrappers/graphite-statsd/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/graphite-statsd/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/graphite-statsd/variables.tf b/wrappers/graphite-statsd/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/graphite-statsd/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/graphite-statsd/versions.tf b/wrappers/graphite-statsd/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/graphite-statsd/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/http-80/README.md b/wrappers/http-80/README.md new file mode 100644 index 00000000..bf497445 --- /dev/null +++ b/wrappers/http-80/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/http-80` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/http-80" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/http-80?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/http-80" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/http-80/main.tf b/wrappers/http-80/main.tf new file mode 100644 index 00000000..fd4161d5 --- /dev/null +++ b/wrappers/http-80/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/http-80" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["http-80-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/http-80/outputs.tf b/wrappers/http-80/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/http-80/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/http-80/variables.tf b/wrappers/http-80/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/http-80/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/http-80/versions.tf b/wrappers/http-80/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/http-80/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/http-8080/README.md b/wrappers/http-8080/README.md new file mode 100644 index 00000000..e78611f1 --- /dev/null +++ b/wrappers/http-8080/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/http-8080` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/http-8080" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/http-8080?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/http-8080" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/http-8080/main.tf b/wrappers/http-8080/main.tf new file mode 100644 index 00000000..c86eab72 --- /dev/null +++ b/wrappers/http-8080/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/http-8080" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["http-8080-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/http-8080/outputs.tf b/wrappers/http-8080/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/http-8080/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/http-8080/variables.tf b/wrappers/http-8080/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/http-8080/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/http-8080/versions.tf b/wrappers/http-8080/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/http-8080/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/https-443/README.md b/wrappers/https-443/README.md new file mode 100644 index 00000000..99cd9573 --- /dev/null +++ b/wrappers/https-443/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/https-443` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/https-443" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/https-443?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/https-443" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/https-443/main.tf b/wrappers/https-443/main.tf new file mode 100644 index 00000000..b8a4d6f2 --- /dev/null +++ b/wrappers/https-443/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/https-443" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["https-443-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/https-443/outputs.tf b/wrappers/https-443/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/https-443/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/https-443/variables.tf b/wrappers/https-443/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/https-443/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/https-443/versions.tf b/wrappers/https-443/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/https-443/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/https-8443/README.md b/wrappers/https-8443/README.md new file mode 100644 index 00000000..12bd280a --- /dev/null +++ b/wrappers/https-8443/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/https-8443` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/https-8443" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/https-8443?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/https-8443" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/https-8443/main.tf b/wrappers/https-8443/main.tf new file mode 100644 index 00000000..55ffa4f5 --- /dev/null +++ b/wrappers/https-8443/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/https-8443" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["https-8443-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/https-8443/outputs.tf b/wrappers/https-8443/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/https-8443/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/https-8443/variables.tf b/wrappers/https-8443/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/https-8443/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/https-8443/versions.tf b/wrappers/https-8443/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/https-8443/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/ipsec-4500/README.md b/wrappers/ipsec-4500/README.md new file mode 100644 index 00000000..b79037ac --- /dev/null +++ b/wrappers/ipsec-4500/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/ipsec-4500` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/ipsec-4500" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/ipsec-4500?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/ipsec-4500" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/ipsec-4500/main.tf b/wrappers/ipsec-4500/main.tf new file mode 100644 index 00000000..884769c8 --- /dev/null +++ b/wrappers/ipsec-4500/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/ipsec-4500" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["ipsec-4500-udp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/ipsec-4500/outputs.tf b/wrappers/ipsec-4500/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/ipsec-4500/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/ipsec-4500/variables.tf b/wrappers/ipsec-4500/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/ipsec-4500/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/ipsec-4500/versions.tf b/wrappers/ipsec-4500/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/ipsec-4500/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/ipsec-500/README.md b/wrappers/ipsec-500/README.md new file mode 100644 index 00000000..6bdfbf0e --- /dev/null +++ b/wrappers/ipsec-500/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/ipsec-500` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/ipsec-500" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/ipsec-500?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/ipsec-500" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/ipsec-500/main.tf b/wrappers/ipsec-500/main.tf new file mode 100644 index 00000000..3ddecd6b --- /dev/null +++ b/wrappers/ipsec-500/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/ipsec-500" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["ipsec-500-udp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/ipsec-500/outputs.tf b/wrappers/ipsec-500/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/ipsec-500/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/ipsec-500/variables.tf b/wrappers/ipsec-500/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/ipsec-500/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/ipsec-500/versions.tf b/wrappers/ipsec-500/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/ipsec-500/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/kafka/README.md b/wrappers/kafka/README.md new file mode 100644 index 00000000..1dc88b03 --- /dev/null +++ b/wrappers/kafka/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/kafka` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/kafka" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/kafka?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/kafka" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/kafka/main.tf b/wrappers/kafka/main.tf new file mode 100644 index 00000000..d654f96d --- /dev/null +++ b/wrappers/kafka/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/kafka" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["kafka-broker-tcp", "kafka-broker-tls-tcp", "kafka-broker-tls-public-tcp", "kafka-broker-sasl-scram-tcp", "kafka-broker-sasl-scram-tcp", "kafka-broker-sasl-iam-tcp", "kafka-broker-sasl-iam-public-tcp", "kafka-jmx-exporter-tcp", "kafka-node-exporter-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/kafka/outputs.tf b/wrappers/kafka/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/kafka/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/kafka/variables.tf b/wrappers/kafka/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/kafka/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/kafka/versions.tf b/wrappers/kafka/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/kafka/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/kibana/README.md b/wrappers/kibana/README.md new file mode 100644 index 00000000..27fa0227 --- /dev/null +++ b/wrappers/kibana/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/kibana` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/kibana" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/kibana?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/kibana" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/kibana/main.tf b/wrappers/kibana/main.tf new file mode 100644 index 00000000..dd3dab8f --- /dev/null +++ b/wrappers/kibana/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/kibana" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["kibana-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/kibana/outputs.tf b/wrappers/kibana/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/kibana/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/kibana/variables.tf b/wrappers/kibana/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/kibana/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/kibana/versions.tf b/wrappers/kibana/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/kibana/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/kubernetes-api/README.md b/wrappers/kubernetes-api/README.md new file mode 100644 index 00000000..bf613a72 --- /dev/null +++ b/wrappers/kubernetes-api/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/kubernetes-api` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/kubernetes-api" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/kubernetes-api?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/kubernetes-api" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/kubernetes-api/main.tf b/wrappers/kubernetes-api/main.tf new file mode 100644 index 00000000..eab20653 --- /dev/null +++ b/wrappers/kubernetes-api/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/kubernetes-api" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["kubernetes-api-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/kubernetes-api/outputs.tf b/wrappers/kubernetes-api/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/kubernetes-api/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/kubernetes-api/variables.tf b/wrappers/kubernetes-api/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/kubernetes-api/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/kubernetes-api/versions.tf b/wrappers/kubernetes-api/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/kubernetes-api/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/ldap/README.md b/wrappers/ldap/README.md new file mode 100644 index 00000000..cf571a85 --- /dev/null +++ b/wrappers/ldap/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/ldap` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/ldap" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/ldap?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/ldap" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/ldap/main.tf b/wrappers/ldap/main.tf new file mode 100644 index 00000000..6e239b82 --- /dev/null +++ b/wrappers/ldap/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/ldap" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["ldap-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/ldap/outputs.tf b/wrappers/ldap/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/ldap/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/ldap/variables.tf b/wrappers/ldap/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/ldap/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/ldap/versions.tf b/wrappers/ldap/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/ldap/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/ldaps/README.md b/wrappers/ldaps/README.md new file mode 100644 index 00000000..40733627 --- /dev/null +++ b/wrappers/ldaps/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/ldaps` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/ldaps" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/ldaps?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/ldaps" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/ldaps/main.tf b/wrappers/ldaps/main.tf new file mode 100644 index 00000000..812457ba --- /dev/null +++ b/wrappers/ldaps/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/ldaps" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["ldaps-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/ldaps/outputs.tf b/wrappers/ldaps/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/ldaps/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/ldaps/variables.tf b/wrappers/ldaps/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/ldaps/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/ldaps/versions.tf b/wrappers/ldaps/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/ldaps/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/logstash/README.md b/wrappers/logstash/README.md new file mode 100644 index 00000000..55f47cec --- /dev/null +++ b/wrappers/logstash/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/logstash` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/logstash" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/logstash?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/logstash" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/logstash/main.tf b/wrappers/logstash/main.tf new file mode 100644 index 00000000..d3489369 --- /dev/null +++ b/wrappers/logstash/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/logstash" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["logstash-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/logstash/outputs.tf b/wrappers/logstash/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/logstash/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/logstash/variables.tf b/wrappers/logstash/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/logstash/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/logstash/versions.tf b/wrappers/logstash/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/logstash/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/loki/README.md b/wrappers/loki/README.md new file mode 100644 index 00000000..ae96802f --- /dev/null +++ b/wrappers/loki/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/loki` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/loki" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/loki?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/loki" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/loki/main.tf b/wrappers/loki/main.tf new file mode 100644 index 00000000..85fcacea --- /dev/null +++ b/wrappers/loki/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/loki" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["loki-grafana", "loki-grafana-grpc"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/loki/outputs.tf b/wrappers/loki/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/loki/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/loki/variables.tf b/wrappers/loki/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/loki/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/loki/versions.tf b/wrappers/loki/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/loki/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/main.tf b/wrappers/main.tf new file mode 100644 index 00000000..83712d17 --- /dev/null +++ b/wrappers/main.tf @@ -0,0 +1,562 @@ +module "wrapper" { + source = "../" + + for_each = var.items + + auto_groups = try(each.value.auto_groups, var.defaults.auto_groups, { + activemq = { + ingress_rules = ["activemq-5671-tcp", "activemq-8883-tcp", "activemq-61614-tcp", "activemq-61617-tcp", "activemq-61619-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + alertmanager = { + ingress_rules = ["alertmanager-9093-tcp", "alertmanager-9094-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + carbon-relay-ng = { + ingress_rules = ["carbon-line-in-tcp", "carbon-line-in-udp", "carbon-pickle-tcp", "carbon-pickle-udp", "carbon-gui-udp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + cassandra = { + ingress_rules = ["cassandra-clients-tcp", "cassandra-thrift-clients-tcp", "cassandra-jmx-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + consul = { + ingress_rules = ["consul-tcp", "consul-grpc-tcp", "consul-grpc-tcp-tls", "consul-webui-http-tcp", "consul-webui-https-tcp", "consul-dns-tcp", "consul-dns-udp", "consul-serf-lan-tcp", "consul-serf-lan-udp", "consul-serf-wan-tcp", "consul-serf-wan-udp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + dax-cluster = { + ingress_rules = ["dax-cluster-unencrypted-tcp", "dax-cluster-encrypted-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + docker-swarm = { + ingress_rules = ["docker-swarm-mngmt-tcp", "docker-swarm-node-tcp", "docker-swarm-node-udp", "docker-swarm-overlay-udp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + etcd = { + ingress_rules = ["etcd-client-tcp", "etcd-peer-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + elasticsearch = { + ingress_rules = ["elasticsearch-rest-tcp", "elasticsearch-java-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + grafana = { + ingress_rules = ["grafana-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + graphite-statsd = { + ingress_rules = ["graphite-webui", "graphite-2003-tcp", "graphite-2004-tcp", "graphite-2023-tcp", "graphite-2024-tcp", "graphite-8080-tcp", "graphite-8125-tcp", "graphite-8125-udp", "graphite-8126-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + http-80 = { + ingress_rules = ["http-80-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + http-8080 = { + ingress_rules = ["http-8080-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + https-443 = { + ingress_rules = ["https-443-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + https-8443 = { + ingress_rules = ["https-8443-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + ipsec-500 = { + ingress_rules = ["ipsec-500-udp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + ipsec-4500 = { + ingress_rules = ["ipsec-4500-udp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + kafka = { + ingress_rules = ["kafka-broker-tcp", "kafka-broker-tls-tcp", "kafka-broker-tls-public-tcp", "kafka-broker-sasl-scram-tcp", "kafka-broker-sasl-scram-tcp", "kafka-broker-sasl-iam-tcp", "kafka-broker-sasl-iam-public-tcp", "kafka-jmx-exporter-tcp", "kafka-node-exporter-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + kubernetes-api = { + ingress_rules = ["kubernetes-api-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + kibana = { + ingress_rules = ["kibana-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + ldap = { + ingress_rules = ["ldap-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + ldaps = { + ingress_rules = ["ldaps-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + logstash = { + ingress_rules = ["logstash-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + loki = { + ingress_rules = ["loki-grafana", "loki-grafana-grpc"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + memcached = { + ingress_rules = ["memcached-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + minio = { + ingress_rules = ["minio-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + mongodb = { + ingress_rules = ["mongodb-27017-tcp", "mongodb-27018-tcp", "mongodb-27019-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + mysql = { + ingress_rules = ["mysql-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + mssql = { + ingress_rules = ["mssql-tcp", "mssql-udp", "mssql-analytics-tcp", "mssql-broker-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + nfs = { + ingress_rules = ["nfs-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + nomad = { + ingress_rules = ["nomad-http-tcp", "nomad-rpc-tcp", "nomad-serf-tcp", "nomad-serf-udp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + openvpn = { + ingress_rules = ["openvpn-udp", "openvpn-tcp", "openvpn-https-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + postgresql = { + ingress_rules = ["postgresql-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + oracle-db = { + ingress_rules = ["oracle-db-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + ntp = { + ingress_rules = ["ntp-udp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + puppet = { + ingress_rules = ["puppet-tcp", "puppetdb-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + prometheus = { + ingress_rules = ["prometheus-http-tcp", "prometheus-pushgateway-http-tcp", "prometheus-node-exporter-http-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + promtail = { + ingress_rules = ["promtail-http"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + rabbitmq = { + ingress_rules = ["rabbitmq-4369-tcp", "rabbitmq-5671-tcp", "rabbitmq-5672-tcp", "rabbitmq-15672-tcp", "rabbitmq-25672-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + rdp = { + ingress_rules = ["rdp-tcp", "rdp-udp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + redis = { + ingress_rules = ["redis-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + redshift = { + ingress_rules = ["redshift-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + smtp = { + ingress_rules = ["smtp-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + smtp-submission = { + ingress_rules = ["smtp-submission-587-tcp", "smtp-submission-2587-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + smtps = { + ingress_rules = ["smtps-465-tcp", "smtps-2465-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + solr = { + ingress_rules = ["solr-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + splunk = { + ingress_rules = ["splunk-indexer-tcp", "splunk-web-tcp", "splunk-splunkd-tcp", "splunk-hec-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + squid = { + ingress_rules = ["squid-proxy-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + ssh = { + ingress_rules = ["ssh-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + storm = { + ingress_rules = ["storm-nimbus-tcp", "storm-ui-tcp", "storm-supervisor-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + vault = { + ingress_rules = ["vault-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + wazuh = { + ingress_rules = ["wazuh-server-agent-connection-tcp", "wazuh-server-agent-connection-udp", "wazuh-server-agent-enrollment", "wazuh-server-agent-cluster-daemon", "wazuh-server-syslog-collector-tcp", "wazuh-server-syslog-collector-udp", "wazuh-server-restful-api", "wazuh-indexer-restful-api", "wazuh-dashboard", ] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + web = { + ingress_rules = ["http-80-tcp", "http-8080-tcp", "https-443-tcp", "web-jmx-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + winrm = { + ingress_rules = ["winrm-http-tcp", "winrm-https-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + zabbix = { + ingress_rules = ["zabbix-server", "zabbix-proxy", "zabbix-agent"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + zipkin = { + ingress_rules = ["zipkin-admin-tcp", "zipkin-admin-query-tcp", "zipkin-admin-web-tcp", "zipkin-query-tcp", "zipkin-web-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + zookeeper = { + ingress_rules = ["zookeeper-2181-tcp", "zookeeper-2182-tls-tcp", "zookeeper-2888-tcp", "zookeeper-3888-tcp", "zookeeper-jmx-tcp"] + ingress_with_self = ["all-all"] + egress_rules = ["all-all"] + } + }) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + create_sg = try(each.value.create_sg, var.defaults.create_sg, true) + create_timeout = try(each.value.create_timeout, var.defaults.create_timeout, "10m") + delete_timeout = try(each.value.delete_timeout, var.defaults.delete_timeout, "15m") + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name, null) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + putin_khuylo = try(each.value.putin_khuylo, var.defaults.putin_khuylo, true) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + rules = try(each.value.rules, var.defaults.rules, { + + activemq-5671-tcp = [5671, 5671, "tcp", "ActiveMQ AMQP"] + activemq-8883-tcp = [8883, 8883, "tcp", "ActiveMQ MQTT"] + activemq-61614-tcp = [61614, 61614, "tcp", "ActiveMQ STOMP"] + activemq-61617-tcp = [61617, 61617, "tcp", "ActiveMQ OpenWire"] + activemq-61619-tcp = [61619, 61619, "tcp", "ActiveMQ WebSocket"] + + alertmanager-9093-tcp = [9093, 9093, "tcp", "Alert Manager"] + alertmanager-9094-tcp = [9094, 9094, "tcp", "Alert Manager Cluster"] + + carbon-line-in-tcp = [2003, 2003, "tcp", "Carbon line-in"] + carbon-line-in-udp = [2003, 2003, "udp", "Carbon line-in"] + carbon-pickle-tcp = [2013, 2013, "tcp", "Carbon pickle"] + carbon-pickle-udp = [2013, 2013, "udp", "Carbon pickle"] + carbon-admin-tcp = [2004, 2004, "tcp", "Carbon admin"] + carbon-gui-udp = [8081, 8081, "tcp", "Carbon GUI"] + + cassandra-clients-tcp = [9042, 9042, "tcp", "Cassandra clients"] + cassandra-thrift-clients-tcp = [9160, 9160, "tcp", "Cassandra Thrift clients"] + cassandra-jmx-tcp = [7199, 7199, "tcp", "JMX"] + + consul-tcp = [8300, 8300, "tcp", "Consul server"] + consul-grpc-tcp = [8502, 8502, "tcp", "Consul gRPC"] + consul-grpc-tcp-tls = [8503, 8503, "tcp", "Consul gRPC TLS"] + consul-webui-http-tcp = [8500, 8500, "tcp", "Consul web UI HTTP"] + consul-webui-https-tcp = [8501, 8501, "tcp", "Consul web UI HTTPS"] + consul-dns-tcp = [8600, 8600, "tcp", "Consul DNS"] + consul-dns-udp = [8600, 8600, "udp", "Consul DNS"] + consul-serf-lan-tcp = [8301, 8301, "tcp", "Serf LAN"] + consul-serf-lan-udp = [8301, 8301, "udp", "Serf LAN"] + consul-serf-wan-tcp = [8302, 8302, "tcp", "Serf WAN"] + consul-serf-wan-udp = [8302, 8302, "udp", "Serf WAN"] + + dax-cluster-unencrypted-tcp = [8111, 8111, "tcp", "DAX Cluster unencrypted"] + dax-cluster-encrypted-tcp = [9111, 9111, "tcp", "DAX Cluster encrypted"] + + docker-swarm-mngmt-tcp = [2377, 2377, "tcp", "Docker Swarm cluster management"] + docker-swarm-node-tcp = [7946, 7946, "tcp", "Docker Swarm node"] + docker-swarm-node-udp = [7946, 7946, "udp", "Docker Swarm node"] + docker-swarm-overlay-udp = [4789, 4789, "udp", "Docker Swarm Overlay Network Traffic"] + + dns-udp = [53, 53, "udp", "DNS"] + dns-tcp = [53, 53, "tcp", "DNS"] + + etcd-client-tcp = [2379, 2379, "tcp", "Etcd Client"] + etcd-peer-tcp = [2380, 2380, "tcp", "Etcd Peer"] + + ntp-udp = [123, 123, "udp", "NTP"] + + elasticsearch-rest-tcp = [9200, 9200, "tcp", "Elasticsearch REST interface"] + elasticsearch-java-tcp = [9300, 9300, "tcp", "Elasticsearch Java interface"] + + grafana-tcp = [3000, 3000, "tcp", "Grafana Dashboard"] + + graphite-webui = [80, 80, "tcp", "Graphite admin interface"] + graphite-2003-tcp = [2003, 2003, "tcp", "Carbon receiver plain text"] + graphite-2004-tcp = [2004, 2004, "tcp", "Carbon receiver pickle"] + graphite-2023-tcp = [2023, 2023, "tcp", "Carbon aggregator plaintext"] + graphite-2024-tcp = [2024, 2024, "tcp", "Carbon aggregator pickle"] + graphite-8080-tcp = [8080, 8080, "tcp", "Graphite gunicorn port"] + graphite-8125-tcp = [8125, 8125, "tcp", "Statsd TCP"] + graphite-8125-udp = [8125, 8125, "udp", "Statsd UDP default"] + graphite-8126-tcp = [8126, 8126, "tcp", "Statsd admin"] + + http-80-tcp = [80, 80, "tcp", "HTTP"] + http-8080-tcp = [8080, 8080, "tcp", "HTTP"] + + https-443-tcp = [443, 443, "tcp", "HTTPS"] + https-8443-tcp = [8443, 8443, "tcp", "HTTPS"] + + ipsec-500-udp = [500, 500, "udp", "IPSEC ISAKMP"] + ipsec-4500-udp = [4500, 4500, "udp", "IPSEC NAT-T"] + + kafka-broker-tcp = [9092, 9092, "tcp", "Kafka PLAINTEXT enable broker 0.8.2+"] + kafka-broker-tls-tcp = [9094, 9094, "tcp", "Kafka TLS enabled broker 0.8.2+"] + kafka-broker-tls-public-tcp = [9194, 9194, "tcp", "Kafka TLS Public enabled broker 0.8.2+ (MSK specific)"] + kafka-broker-sasl-scram-tcp = [9096, 9096, "tcp", "Kafka SASL/SCRAM enabled broker (MSK specific)"] + kafka-broker-sasl-scram-public-tcp = [9196, 9196, "tcp", "Kafka SASL/SCRAM Public enabled broker (MSK specific)"] + kafka-broker-sasl-iam-tcp = [9098, 9098, "tcp", "Kafka SASL/IAM access control enabled (MSK specific)"] + kafka-broker-sasl-iam-public-tcp = [9198, 9198, "tcp", "Kafka SASL/IAM Public access control enabled (MSK specific)"] + kafka-jmx-exporter-tcp = [11001, 11001, "tcp", "Kafka JMX Exporter"] + kafka-node-exporter-tcp = [11002, 11002, "tcp", "Kafka Node Exporter"] + + kibana-tcp = [5601, 5601, "tcp", "Kibana Web Interface"] + + kubernetes-api-tcp = [6443, 6443, "tcp", "Kubernetes API Server"] + + ldap-tcp = [389, 389, "tcp", "LDAP"] + + ldaps-tcp = [636, 636, "tcp", "LDAPS"] + + logstash-tcp = [5044, 5044, "tcp", "Logstash"] + + loki-grafana = [3100, 3100, "tcp", "Grafana Loki endpoint"] + loki-grafana-grpc = [9095, 9095, "tcp", "Grafana Loki GRPC"] + + memcached-tcp = [11211, 11211, "tcp", "Memcached"] + + minio-tcp = [9000, 9000, "tcp", "MinIO"] + + mongodb-27017-tcp = [27017, 27017, "tcp", "MongoDB"] + mongodb-27018-tcp = [27018, 27018, "tcp", "MongoDB shard"] + mongodb-27019-tcp = [27019, 27019, "tcp", "MongoDB config server"] + + mysql-tcp = [3306, 3306, "tcp", "MySQL/Aurora"] + + mssql-tcp = [1433, 1433, "tcp", "MSSQL Server"] + mssql-udp = [1434, 1434, "udp", "MSSQL Browser"] + mssql-analytics-tcp = [2383, 2383, "tcp", "MSSQL Analytics"] + mssql-broker-tcp = [4022, 4022, "tcp", "MSSQL Broker"] + + nfs-tcp = [2049, 2049, "tcp", "NFS/EFS"] + + nomad-http-tcp = [4646, 4646, "tcp", "Nomad HTTP"] + nomad-rpc-tcp = [4647, 4647, "tcp", "Nomad RPC"] + nomad-serf-tcp = [4648, 4648, "tcp", "Serf"] + nomad-serf-udp = [4648, 4648, "udp", "Serf"] + + openvpn-udp = [1194, 1194, "udp", "OpenVPN"] + openvpn-tcp = [943, 943, "tcp", "OpenVPN"] + openvpn-https-tcp = [443, 443, "tcp", "OpenVPN"] + + postgresql-tcp = [5432, 5432, "tcp", "PostgreSQL"] + + puppet-tcp = [8140, 8140, "tcp", "Puppet"] + puppetdb-tcp = [8081, 8081, "tcp", "PuppetDB"] + + prometheus-http-tcp = [9090, 9090, "tcp", "Prometheus"] + prometheus-pushgateway-http-tcp = [9091, 9091, "tcp", "Prometheus Pushgateway"] + prometheus-node-exporter-http-tcp = [9100, 9100, "tcp", "Prometheus Node Exporter"] + + promtail-http = [9080, 9080, "tcp", "Promtail endpoint"] + + oracle-db-tcp = [1521, 1521, "tcp", "Oracle"] + + octopus-tentacle-tcp = [10933, 10933, "tcp", "Octopus Tentacle"] + + rabbitmq-4369-tcp = [4369, 4369, "tcp", "RabbitMQ epmd"] + rabbitmq-5671-tcp = [5671, 5671, "tcp", "RabbitMQ"] + rabbitmq-5672-tcp = [5672, 5672, "tcp", "RabbitMQ"] + rabbitmq-15672-tcp = [15672, 15672, "tcp", "RabbitMQ"] + rabbitmq-25672-tcp = [25672, 25672, "tcp", "RabbitMQ"] + + rdp-tcp = [3389, 3389, "tcp", "Remote Desktop"] + rdp-udp = [3389, 3389, "udp", "Remote Desktop"] + + redis-tcp = [6379, 6379, "tcp", "Redis"] + + redshift-tcp = [5439, 5439, "tcp", "Redshift"] + + saltstack-tcp = [4505, 4506, "tcp", "SaltStack"] + + smtp-tcp = [25, 25, "tcp", "SMTP"] + smtp-submission-587-tcp = [587, 587, "tcp", "SMTP Submission"] + smtp-submission-2587-tcp = [2587, 2587, "tcp", "SMTP Submission"] + smtps-465-tcp = [465, 465, "tcp", "SMTPS"] + smtps-2456-tcp = [2465, 2465, "tcp", "SMTPS"] + + solr-tcp = [8983, 8987, "tcp", "Solr"] + + splunk-indexer-tcp = [9997, 9997, "tcp", "Splunk indexer"] + splunk-web-tcp = [8000, 8000, "tcp", "Splunk Web"] + splunk-splunkd-tcp = [8089, 8089, "tcp", "Splunkd"] + splunk-hec-tcp = [8088, 8088, "tcp", "Splunk HEC"] + + squid-proxy-tcp = [3128, 3128, "tcp", "Squid default proxy"] + + ssh-tcp = [22, 22, "tcp", "SSH"] + + storm-nimbus-tcp = [6627, 6627, "tcp", "Nimbus"] + storm-ui-tcp = [8080, 8080, "tcp", "Storm UI"] + storm-supervisor-tcp = [6700, 6703, "tcp", "Supervisor"] + + vault-tcp = [8200, 8200, "tcp", "Vault"] + + wazuh-server-agent-connection-tcp = [1514, 1514, "tcp", "Agent connection service(TCP)"] + wazuh-server-agent-connection-udp = [1514, 1514, "udp", "Agent connection service(UDP)"] + wazuh-server-agent-enrollment = [1515, 1515, "tcp", "Agent enrollment service"] + wazuh-server-agent-cluster-daemon = [1516, 1516, "tcp", "Wazuh cluster daemon"] + wazuh-server-syslog-collector-tcp = [514, 514, "tcp", "Wazuh Syslog collector(TCP)"] + wazuh-server-syslog-collector-udp = [514, 514, "udp", "Wazuh Syslog collector(UDP)"] + wazuh-server-restful-api = [55000, 55000, "tcp", "Wazuh server RESTful API"] + wazuh-indexer-restful-api = [9200, 9200, "tcp", "Wazuh indexer RESTful API"] + wazuh-dashboard = [443, 443, "tcp", "Wazuh web user interface"] + + web-jmx-tcp = [1099, 1099, "tcp", "JMX"] + + winrm-http-tcp = [5985, 5985, "tcp", "WinRM HTTP"] + winrm-https-tcp = [5986, 5986, "tcp", "WinRM HTTPS"] + + zabbix-server = [10051, 10051, "tcp", "Zabbix Server"] + zabbix-proxy = [10051, 10051, "tcp", "Zabbix Proxy"] + zabbix-agent = [10050, 10050, "tcp", "Zabbix Agent"] + + zipkin-admin-tcp = [9990, 9990, "tcp", "Zipkin Admin port collector"] + zipkin-admin-query-tcp = [9901, 9901, "tcp", "Zipkin Admin port query"] + zipkin-admin-web-tcp = [9991, 9991, "tcp", "Zipkin Admin port web"] + zipkin-query-tcp = [9411, 9411, "tcp", "Zipkin query port"] + zipkin-web-tcp = [8080, 8080, "tcp", "Zipkin web port"] + + zookeeper-2181-tcp = [2181, 2181, "tcp", "Zookeeper"] + zookeeper-2182-tls-tcp = [2182, 2182, "tcp", "Zookeeper TLS (MSK specific)"] + zookeeper-2888-tcp = [2888, 2888, "tcp", "Zookeeper"] + zookeeper-3888-tcp = [3888, 3888, "tcp", "Zookeeper"] + zookeeper-jmx-tcp = [7199, 7199, "tcp", "JMX"] + + all-all = [-1, -1, "-1", "All protocols"] + all-tcp = [0, 65535, "tcp", "All TCP ports"] + all-udp = [0, 65535, "udp", "All UDP ports"] + all-icmp = [-1, -1, "icmp", "All IPV4 ICMP"] + all-ipv6-icmp = [-1, -1, 58, "All IPV6 ICMP"] + + _ = ["", "", ""] + }) + security_group_id = try(each.value.security_group_id, var.defaults.security_group_id, null) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id, null) +} diff --git a/wrappers/memcached/README.md b/wrappers/memcached/README.md new file mode 100644 index 00000000..5e78d049 --- /dev/null +++ b/wrappers/memcached/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/memcached` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/memcached" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/memcached?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/memcached" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/memcached/main.tf b/wrappers/memcached/main.tf new file mode 100644 index 00000000..b184df6e --- /dev/null +++ b/wrappers/memcached/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/memcached" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["memcached-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/memcached/outputs.tf b/wrappers/memcached/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/memcached/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/memcached/variables.tf b/wrappers/memcached/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/memcached/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/memcached/versions.tf b/wrappers/memcached/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/memcached/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/minio/README.md b/wrappers/minio/README.md new file mode 100644 index 00000000..f1bd88f0 --- /dev/null +++ b/wrappers/minio/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/minio` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/minio" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/minio?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/minio" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/minio/main.tf b/wrappers/minio/main.tf new file mode 100644 index 00000000..3941aa13 --- /dev/null +++ b/wrappers/minio/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/minio" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["minio-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/minio/outputs.tf b/wrappers/minio/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/minio/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/minio/variables.tf b/wrappers/minio/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/minio/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/minio/versions.tf b/wrappers/minio/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/minio/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/mongodb/README.md b/wrappers/mongodb/README.md new file mode 100644 index 00000000..f6707c24 --- /dev/null +++ b/wrappers/mongodb/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/mongodb` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/mongodb" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/mongodb?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/mongodb" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/mongodb/main.tf b/wrappers/mongodb/main.tf new file mode 100644 index 00000000..eca4acb6 --- /dev/null +++ b/wrappers/mongodb/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/mongodb" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["mongodb-27017-tcp", "mongodb-27018-tcp", "mongodb-27019-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/mongodb/outputs.tf b/wrappers/mongodb/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/mongodb/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/mongodb/variables.tf b/wrappers/mongodb/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/mongodb/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/mongodb/versions.tf b/wrappers/mongodb/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/mongodb/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/mssql/README.md b/wrappers/mssql/README.md new file mode 100644 index 00000000..afff182e --- /dev/null +++ b/wrappers/mssql/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/mssql` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/mssql" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/mssql?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/mssql" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/mssql/main.tf b/wrappers/mssql/main.tf new file mode 100644 index 00000000..2d2fdd7d --- /dev/null +++ b/wrappers/mssql/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/mssql" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["mssql-tcp", "mssql-udp", "mssql-analytics-tcp", "mssql-broker-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/mssql/outputs.tf b/wrappers/mssql/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/mssql/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/mssql/variables.tf b/wrappers/mssql/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/mssql/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/mssql/versions.tf b/wrappers/mssql/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/mssql/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/mysql/README.md b/wrappers/mysql/README.md new file mode 100644 index 00000000..eb963419 --- /dev/null +++ b/wrappers/mysql/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/mysql` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/mysql" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/mysql?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/mysql" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/mysql/main.tf b/wrappers/mysql/main.tf new file mode 100644 index 00000000..6468a277 --- /dev/null +++ b/wrappers/mysql/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/mysql" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["mysql-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/mysql/outputs.tf b/wrappers/mysql/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/mysql/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/mysql/variables.tf b/wrappers/mysql/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/mysql/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/mysql/versions.tf b/wrappers/mysql/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/mysql/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/nfs/README.md b/wrappers/nfs/README.md new file mode 100644 index 00000000..9e794279 --- /dev/null +++ b/wrappers/nfs/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/nfs` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/nfs" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/nfs?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/nfs" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/nfs/main.tf b/wrappers/nfs/main.tf new file mode 100644 index 00000000..598d3e91 --- /dev/null +++ b/wrappers/nfs/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/nfs" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["nfs-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/nfs/outputs.tf b/wrappers/nfs/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/nfs/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/nfs/variables.tf b/wrappers/nfs/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/nfs/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/nfs/versions.tf b/wrappers/nfs/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/nfs/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/nomad/README.md b/wrappers/nomad/README.md new file mode 100644 index 00000000..9561dd83 --- /dev/null +++ b/wrappers/nomad/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/nomad` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/nomad" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/nomad?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/nomad" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/nomad/main.tf b/wrappers/nomad/main.tf new file mode 100644 index 00000000..44a6177d --- /dev/null +++ b/wrappers/nomad/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/nomad" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["nomad-http-tcp", "nomad-rpc-tcp", "nomad-serf-tcp", "nomad-serf-udp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/nomad/outputs.tf b/wrappers/nomad/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/nomad/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/nomad/variables.tf b/wrappers/nomad/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/nomad/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/nomad/versions.tf b/wrappers/nomad/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/nomad/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/ntp/README.md b/wrappers/ntp/README.md new file mode 100644 index 00000000..baa0099e --- /dev/null +++ b/wrappers/ntp/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/ntp` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/ntp" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/ntp?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/ntp" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/ntp/main.tf b/wrappers/ntp/main.tf new file mode 100644 index 00000000..83ae8434 --- /dev/null +++ b/wrappers/ntp/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/ntp" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["ntp-udp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/ntp/outputs.tf b/wrappers/ntp/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/ntp/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/ntp/variables.tf b/wrappers/ntp/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/ntp/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/ntp/versions.tf b/wrappers/ntp/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/ntp/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/openvpn/README.md b/wrappers/openvpn/README.md new file mode 100644 index 00000000..ec932d97 --- /dev/null +++ b/wrappers/openvpn/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/openvpn` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/openvpn" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/openvpn?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/openvpn" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/openvpn/main.tf b/wrappers/openvpn/main.tf new file mode 100644 index 00000000..7e9e33b2 --- /dev/null +++ b/wrappers/openvpn/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/openvpn" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["openvpn-udp", "openvpn-tcp", "openvpn-https-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/openvpn/outputs.tf b/wrappers/openvpn/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/openvpn/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/openvpn/variables.tf b/wrappers/openvpn/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/openvpn/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/openvpn/versions.tf b/wrappers/openvpn/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/openvpn/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/oracle-db/README.md b/wrappers/oracle-db/README.md new file mode 100644 index 00000000..aac1f55f --- /dev/null +++ b/wrappers/oracle-db/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/oracle-db` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/oracle-db" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/oracle-db?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/oracle-db" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/oracle-db/main.tf b/wrappers/oracle-db/main.tf new file mode 100644 index 00000000..87947bb5 --- /dev/null +++ b/wrappers/oracle-db/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/oracle-db" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["oracle-db-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/oracle-db/outputs.tf b/wrappers/oracle-db/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/oracle-db/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/oracle-db/variables.tf b/wrappers/oracle-db/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/oracle-db/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/oracle-db/versions.tf b/wrappers/oracle-db/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/oracle-db/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/outputs.tf b/wrappers/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/postgresql/README.md b/wrappers/postgresql/README.md new file mode 100644 index 00000000..12798731 --- /dev/null +++ b/wrappers/postgresql/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/postgresql` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/postgresql" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/postgresql?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/postgresql" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/postgresql/main.tf b/wrappers/postgresql/main.tf new file mode 100644 index 00000000..8e7e4868 --- /dev/null +++ b/wrappers/postgresql/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/postgresql" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["postgresql-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/postgresql/outputs.tf b/wrappers/postgresql/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/postgresql/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/postgresql/variables.tf b/wrappers/postgresql/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/postgresql/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/postgresql/versions.tf b/wrappers/postgresql/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/postgresql/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/prometheus/README.md b/wrappers/prometheus/README.md new file mode 100644 index 00000000..58ad4c62 --- /dev/null +++ b/wrappers/prometheus/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/prometheus` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/prometheus" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/prometheus?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/prometheus" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/prometheus/main.tf b/wrappers/prometheus/main.tf new file mode 100644 index 00000000..49cabf9d --- /dev/null +++ b/wrappers/prometheus/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/prometheus" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["prometheus-http-tcp", "prometheus-pushgateway-http-tcp", "prometheus-node-exporter-http-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/prometheus/outputs.tf b/wrappers/prometheus/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/prometheus/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/prometheus/variables.tf b/wrappers/prometheus/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/prometheus/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/prometheus/versions.tf b/wrappers/prometheus/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/prometheus/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/promtail/README.md b/wrappers/promtail/README.md new file mode 100644 index 00000000..8cc5b566 --- /dev/null +++ b/wrappers/promtail/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/promtail` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/promtail" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/promtail?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/promtail" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/promtail/main.tf b/wrappers/promtail/main.tf new file mode 100644 index 00000000..fee81db0 --- /dev/null +++ b/wrappers/promtail/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/promtail" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["promtail-http"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/promtail/outputs.tf b/wrappers/promtail/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/promtail/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/promtail/variables.tf b/wrappers/promtail/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/promtail/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/promtail/versions.tf b/wrappers/promtail/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/promtail/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/puppet/README.md b/wrappers/puppet/README.md new file mode 100644 index 00000000..16bb5974 --- /dev/null +++ b/wrappers/puppet/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/puppet` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/puppet" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/puppet?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/puppet" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/puppet/main.tf b/wrappers/puppet/main.tf new file mode 100644 index 00000000..e41800df --- /dev/null +++ b/wrappers/puppet/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/puppet" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["puppet-tcp", "puppetdb-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/puppet/outputs.tf b/wrappers/puppet/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/puppet/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/puppet/variables.tf b/wrappers/puppet/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/puppet/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/puppet/versions.tf b/wrappers/puppet/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/puppet/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/rabbitmq/README.md b/wrappers/rabbitmq/README.md new file mode 100644 index 00000000..84cf6c99 --- /dev/null +++ b/wrappers/rabbitmq/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/rabbitmq` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/rabbitmq" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/rabbitmq?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/rabbitmq" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/rabbitmq/main.tf b/wrappers/rabbitmq/main.tf new file mode 100644 index 00000000..8cd5e876 --- /dev/null +++ b/wrappers/rabbitmq/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/rabbitmq" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["rabbitmq-4369-tcp", "rabbitmq-5671-tcp", "rabbitmq-5672-tcp", "rabbitmq-15672-tcp", "rabbitmq-25672-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/rabbitmq/outputs.tf b/wrappers/rabbitmq/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/rabbitmq/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/rabbitmq/variables.tf b/wrappers/rabbitmq/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/rabbitmq/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/rabbitmq/versions.tf b/wrappers/rabbitmq/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/rabbitmq/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/rdp/README.md b/wrappers/rdp/README.md new file mode 100644 index 00000000..db850a05 --- /dev/null +++ b/wrappers/rdp/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/rdp` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/rdp" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/rdp?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/rdp" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/rdp/main.tf b/wrappers/rdp/main.tf new file mode 100644 index 00000000..1e385c5d --- /dev/null +++ b/wrappers/rdp/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/rdp" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["rdp-tcp", "rdp-udp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/rdp/outputs.tf b/wrappers/rdp/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/rdp/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/rdp/variables.tf b/wrappers/rdp/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/rdp/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/rdp/versions.tf b/wrappers/rdp/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/rdp/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/redis/README.md b/wrappers/redis/README.md new file mode 100644 index 00000000..0e195549 --- /dev/null +++ b/wrappers/redis/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/redis` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/redis" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/redis?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/redis" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/redis/main.tf b/wrappers/redis/main.tf new file mode 100644 index 00000000..e1e3a0e5 --- /dev/null +++ b/wrappers/redis/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/redis" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["redis-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/redis/outputs.tf b/wrappers/redis/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/redis/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/redis/variables.tf b/wrappers/redis/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/redis/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/redis/versions.tf b/wrappers/redis/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/redis/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/redshift/README.md b/wrappers/redshift/README.md new file mode 100644 index 00000000..2e1666ff --- /dev/null +++ b/wrappers/redshift/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/redshift` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/redshift" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/redshift?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/redshift" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/redshift/main.tf b/wrappers/redshift/main.tf new file mode 100644 index 00000000..b871c6b6 --- /dev/null +++ b/wrappers/redshift/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/redshift" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["redshift-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/redshift/outputs.tf b/wrappers/redshift/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/redshift/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/redshift/variables.tf b/wrappers/redshift/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/redshift/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/redshift/versions.tf b/wrappers/redshift/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/redshift/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/smtp-submission/README.md b/wrappers/smtp-submission/README.md new file mode 100644 index 00000000..57a3afc1 --- /dev/null +++ b/wrappers/smtp-submission/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/smtp-submission` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/smtp-submission" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/smtp-submission?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/smtp-submission" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/smtp-submission/main.tf b/wrappers/smtp-submission/main.tf new file mode 100644 index 00000000..90ba7df5 --- /dev/null +++ b/wrappers/smtp-submission/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/smtp-submission" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["smtp-submission-587-tcp", "smtp-submission-2587-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/smtp-submission/outputs.tf b/wrappers/smtp-submission/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/smtp-submission/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/smtp-submission/variables.tf b/wrappers/smtp-submission/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/smtp-submission/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/smtp-submission/versions.tf b/wrappers/smtp-submission/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/smtp-submission/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/smtp/README.md b/wrappers/smtp/README.md new file mode 100644 index 00000000..236e26c6 --- /dev/null +++ b/wrappers/smtp/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/smtp` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/smtp" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/smtp?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/smtp" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/smtp/main.tf b/wrappers/smtp/main.tf new file mode 100644 index 00000000..0a5a1d84 --- /dev/null +++ b/wrappers/smtp/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/smtp" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["smtp-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/smtp/outputs.tf b/wrappers/smtp/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/smtp/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/smtp/variables.tf b/wrappers/smtp/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/smtp/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/smtp/versions.tf b/wrappers/smtp/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/smtp/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/smtps/README.md b/wrappers/smtps/README.md new file mode 100644 index 00000000..daa032f1 --- /dev/null +++ b/wrappers/smtps/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/smtps` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/smtps" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/smtps?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/smtps" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/smtps/main.tf b/wrappers/smtps/main.tf new file mode 100644 index 00000000..08a13288 --- /dev/null +++ b/wrappers/smtps/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/smtps" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["smtps-465-tcp", "smtps-2465-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/smtps/outputs.tf b/wrappers/smtps/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/smtps/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/smtps/variables.tf b/wrappers/smtps/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/smtps/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/smtps/versions.tf b/wrappers/smtps/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/smtps/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/solr/README.md b/wrappers/solr/README.md new file mode 100644 index 00000000..6b3c68d0 --- /dev/null +++ b/wrappers/solr/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/solr` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/solr" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/solr?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/solr" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/solr/main.tf b/wrappers/solr/main.tf new file mode 100644 index 00000000..444c0c6e --- /dev/null +++ b/wrappers/solr/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/solr" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["solr-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/solr/outputs.tf b/wrappers/solr/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/solr/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/solr/variables.tf b/wrappers/solr/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/solr/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/solr/versions.tf b/wrappers/solr/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/solr/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/splunk/README.md b/wrappers/splunk/README.md new file mode 100644 index 00000000..37285de8 --- /dev/null +++ b/wrappers/splunk/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/splunk` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/splunk" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/splunk?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/splunk" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/splunk/main.tf b/wrappers/splunk/main.tf new file mode 100644 index 00000000..eb894958 --- /dev/null +++ b/wrappers/splunk/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/splunk" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["splunk-indexer-tcp", "splunk-web-tcp", "splunk-splunkd-tcp", "splunk-hec-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/splunk/outputs.tf b/wrappers/splunk/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/splunk/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/splunk/variables.tf b/wrappers/splunk/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/splunk/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/splunk/versions.tf b/wrappers/splunk/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/splunk/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/squid/README.md b/wrappers/squid/README.md new file mode 100644 index 00000000..3ba84b2e --- /dev/null +++ b/wrappers/squid/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/squid` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/squid" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/squid?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/squid" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/squid/main.tf b/wrappers/squid/main.tf new file mode 100644 index 00000000..71f444a8 --- /dev/null +++ b/wrappers/squid/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/squid" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["squid-proxy-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/squid/outputs.tf b/wrappers/squid/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/squid/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/squid/variables.tf b/wrappers/squid/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/squid/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/squid/versions.tf b/wrappers/squid/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/squid/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/ssh/README.md b/wrappers/ssh/README.md new file mode 100644 index 00000000..9bdb7fd4 --- /dev/null +++ b/wrappers/ssh/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/ssh` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/ssh" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/ssh?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/ssh" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/ssh/main.tf b/wrappers/ssh/main.tf new file mode 100644 index 00000000..aeda2251 --- /dev/null +++ b/wrappers/ssh/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/ssh" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["ssh-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/ssh/outputs.tf b/wrappers/ssh/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/ssh/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/ssh/variables.tf b/wrappers/ssh/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/ssh/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/ssh/versions.tf b/wrappers/ssh/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/ssh/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/storm/README.md b/wrappers/storm/README.md new file mode 100644 index 00000000..9bbfa586 --- /dev/null +++ b/wrappers/storm/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/storm` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/storm" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/storm?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/storm" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/storm/main.tf b/wrappers/storm/main.tf new file mode 100644 index 00000000..bf49d857 --- /dev/null +++ b/wrappers/storm/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/storm" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["storm-nimbus-tcp", "storm-ui-tcp", "storm-supervisor-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/storm/outputs.tf b/wrappers/storm/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/storm/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/storm/variables.tf b/wrappers/storm/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/storm/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/storm/versions.tf b/wrappers/storm/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/storm/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/variables.tf b/wrappers/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/vault/README.md b/wrappers/vault/README.md new file mode 100644 index 00000000..c3230587 --- /dev/null +++ b/wrappers/vault/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/vault` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/vault" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/vault?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/vault" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/vault/main.tf b/wrappers/vault/main.tf new file mode 100644 index 00000000..35bbf6fa --- /dev/null +++ b/wrappers/vault/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/vault" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["vault-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/vault/outputs.tf b/wrappers/vault/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/vault/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/vault/variables.tf b/wrappers/vault/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/vault/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/vault/versions.tf b/wrappers/vault/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/vault/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/versions.tf b/wrappers/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/wazuh/README.md b/wrappers/wazuh/README.md new file mode 100644 index 00000000..de9751db --- /dev/null +++ b/wrappers/wazuh/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/wazuh` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/wazuh" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/wazuh?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/wazuh" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/wazuh/main.tf b/wrappers/wazuh/main.tf new file mode 100644 index 00000000..a9d76b0f --- /dev/null +++ b/wrappers/wazuh/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/wazuh" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["wazuh-server-agent-connection-tcp", "wazuh-server-agent-connection-udp", "wazuh-server-agent-enrollment", "wazuh-server-agent-cluster-daemon", "wazuh-server-syslog-collector-tcp", "wazuh-server-syslog-collector-udp", "wazuh-server-restful-api", "wazuh-indexer-restful-api", "wazuh-dashboard"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/wazuh/outputs.tf b/wrappers/wazuh/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/wazuh/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/wazuh/variables.tf b/wrappers/wazuh/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/wazuh/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/wazuh/versions.tf b/wrappers/wazuh/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/wazuh/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/web/README.md b/wrappers/web/README.md new file mode 100644 index 00000000..bd9132bb --- /dev/null +++ b/wrappers/web/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/web` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/web" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/web?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/web" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/web/main.tf b/wrappers/web/main.tf new file mode 100644 index 00000000..7a3b94de --- /dev/null +++ b/wrappers/web/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/web" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["http-80-tcp", "http-8080-tcp", "https-443-tcp", "web-jmx-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/web/outputs.tf b/wrappers/web/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/web/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/web/variables.tf b/wrappers/web/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/web/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/web/versions.tf b/wrappers/web/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/web/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/winrm/README.md b/wrappers/winrm/README.md new file mode 100644 index 00000000..13f2d7e9 --- /dev/null +++ b/wrappers/winrm/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/winrm` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/winrm" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/winrm?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/winrm" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/winrm/main.tf b/wrappers/winrm/main.tf new file mode 100644 index 00000000..1ec169d3 --- /dev/null +++ b/wrappers/winrm/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/winrm" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["winrm-http-tcp", "winrm-https-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/winrm/outputs.tf b/wrappers/winrm/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/winrm/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/winrm/variables.tf b/wrappers/winrm/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/winrm/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/winrm/versions.tf b/wrappers/winrm/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/winrm/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/zabbix/README.md b/wrappers/zabbix/README.md new file mode 100644 index 00000000..873f673c --- /dev/null +++ b/wrappers/zabbix/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/zabbix` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/zabbix" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/zabbix?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/zabbix" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/zabbix/main.tf b/wrappers/zabbix/main.tf new file mode 100644 index 00000000..c16af085 --- /dev/null +++ b/wrappers/zabbix/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/zabbix" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["zabbix-server", "zabbix-proxy", "zabbix-agent"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/zabbix/outputs.tf b/wrappers/zabbix/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/zabbix/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/zabbix/variables.tf b/wrappers/zabbix/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/zabbix/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/zabbix/versions.tf b/wrappers/zabbix/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/zabbix/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/zipkin/README.md b/wrappers/zipkin/README.md new file mode 100644 index 00000000..5928acc4 --- /dev/null +++ b/wrappers/zipkin/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/zipkin` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/zipkin" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/zipkin?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/zipkin" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/zipkin/main.tf b/wrappers/zipkin/main.tf new file mode 100644 index 00000000..48e2a098 --- /dev/null +++ b/wrappers/zipkin/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/zipkin" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["zipkin-admin-tcp", "zipkin-admin-query-tcp", "zipkin-admin-web-tcp", "zipkin-query-tcp", "zipkin-web-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/zipkin/outputs.tf b/wrappers/zipkin/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/zipkin/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/zipkin/variables.tf b/wrappers/zipkin/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/zipkin/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/zipkin/versions.tf b/wrappers/zipkin/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/zipkin/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +} diff --git a/wrappers/zookeeper/README.md b/wrappers/zookeeper/README.md new file mode 100644 index 00000000..dea3cdb9 --- /dev/null +++ b/wrappers/zookeeper/README.md @@ -0,0 +1,100 @@ +# Wrapper for module: `modules/zookeeper` + +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). + +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. + +This wrapper does not implement any extra functionality. + +## Usage with Terragrunt + +`terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/security-group/aws//wrappers/zookeeper" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-security-group.git//wrappers/zookeeper?ref=master" +} + +inputs = { + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Usage with Terraform + +```hcl +module "wrapper" { + source = "terraform-aws-modules/security-group/aws//wrappers/zookeeper" + + defaults = { # Default values + create = true + tags = { + Terraform = "true" + Environment = "dev" + } + } + + items = { + my-item = { + # omitted... can be any argument supported by the module + } + my-second-item = { + # omitted... can be any argument supported by the module + } + # omitted... + } +} +``` + +## Example: Manage multiple S3 buckets in one Terragrunt layer + +`eu-west-1/s3-buckets/terragrunt.hcl`: + +```hcl +terraform { + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" + # Alternative source: + # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" +} + +inputs = { + defaults = { + force_destroy = true + + attach_elb_log_delivery_policy = true + attach_lb_log_delivery_policy = true + attach_deny_insecure_transport_policy = true + attach_require_latest_tls_policy = true + } + + items = { + bucket1 = { + bucket = "my-random-bucket-1" + } + bucket2 = { + bucket = "my-random-bucket-2" + tags = { + Secure = "probably" + } + } + } +} +``` diff --git a/wrappers/zookeeper/main.tf b/wrappers/zookeeper/main.tf new file mode 100644 index 00000000..e391c5df --- /dev/null +++ b/wrappers/zookeeper/main.tf @@ -0,0 +1,79 @@ +module "wrapper" { + source = "../../modules/zookeeper" + + for_each = var.items + + auto_computed_egress_rules = try(each.value.auto_computed_egress_rules, var.defaults.auto_computed_egress_rules, []) + auto_computed_egress_with_self = try(each.value.auto_computed_egress_with_self, var.defaults.auto_computed_egress_with_self, []) + auto_computed_ingress_rules = try(each.value.auto_computed_ingress_rules, var.defaults.auto_computed_ingress_rules, []) + auto_computed_ingress_with_self = try(each.value.auto_computed_ingress_with_self, var.defaults.auto_computed_ingress_with_self, []) + auto_egress_rules = try(each.value.auto_egress_rules, var.defaults.auto_egress_rules, ["all-all"]) + auto_egress_with_self = try(each.value.auto_egress_with_self, var.defaults.auto_egress_with_self, []) + auto_ingress_rules = try(each.value.auto_ingress_rules, var.defaults.auto_ingress_rules, ["zookeeper-2181-tcp", "zookeeper-2182-tls-tcp", "zookeeper-2888-tcp", "zookeeper-3888-tcp", "zookeeper-jmx-tcp"]) + auto_ingress_with_self = try(each.value.auto_ingress_with_self, var.defaults.auto_ingress_with_self, [{ "rule" = "all-all" }]) + auto_number_of_computed_egress_rules = try(each.value.auto_number_of_computed_egress_rules, var.defaults.auto_number_of_computed_egress_rules, 0) + auto_number_of_computed_egress_with_self = try(each.value.auto_number_of_computed_egress_with_self, var.defaults.auto_number_of_computed_egress_with_self, 0) + auto_number_of_computed_ingress_rules = try(each.value.auto_number_of_computed_ingress_rules, var.defaults.auto_number_of_computed_ingress_rules, 0) + auto_number_of_computed_ingress_with_self = try(each.value.auto_number_of_computed_ingress_with_self, var.defaults.auto_number_of_computed_ingress_with_self, 0) + computed_egress_cidr_blocks = try(each.value.computed_egress_cidr_blocks, var.defaults.computed_egress_cidr_blocks, ["0.0.0.0/0"]) + computed_egress_ipv6_cidr_blocks = try(each.value.computed_egress_ipv6_cidr_blocks, var.defaults.computed_egress_ipv6_cidr_blocks, ["::/0"]) + computed_egress_prefix_list_ids = try(each.value.computed_egress_prefix_list_ids, var.defaults.computed_egress_prefix_list_ids, []) + computed_egress_rules = try(each.value.computed_egress_rules, var.defaults.computed_egress_rules, []) + computed_egress_with_cidr_blocks = try(each.value.computed_egress_with_cidr_blocks, var.defaults.computed_egress_with_cidr_blocks, []) + computed_egress_with_ipv6_cidr_blocks = try(each.value.computed_egress_with_ipv6_cidr_blocks, var.defaults.computed_egress_with_ipv6_cidr_blocks, []) + computed_egress_with_prefix_list_ids = try(each.value.computed_egress_with_prefix_list_ids, var.defaults.computed_egress_with_prefix_list_ids, []) + computed_egress_with_self = try(each.value.computed_egress_with_self, var.defaults.computed_egress_with_self, []) + computed_egress_with_source_security_group_id = try(each.value.computed_egress_with_source_security_group_id, var.defaults.computed_egress_with_source_security_group_id, []) + computed_ingress_cidr_blocks = try(each.value.computed_ingress_cidr_blocks, var.defaults.computed_ingress_cidr_blocks, []) + computed_ingress_ipv6_cidr_blocks = try(each.value.computed_ingress_ipv6_cidr_blocks, var.defaults.computed_ingress_ipv6_cidr_blocks, []) + computed_ingress_prefix_list_ids = try(each.value.computed_ingress_prefix_list_ids, var.defaults.computed_ingress_prefix_list_ids, []) + computed_ingress_rules = try(each.value.computed_ingress_rules, var.defaults.computed_ingress_rules, []) + computed_ingress_with_cidr_blocks = try(each.value.computed_ingress_with_cidr_blocks, var.defaults.computed_ingress_with_cidr_blocks, []) + computed_ingress_with_ipv6_cidr_blocks = try(each.value.computed_ingress_with_ipv6_cidr_blocks, var.defaults.computed_ingress_with_ipv6_cidr_blocks, []) + computed_ingress_with_prefix_list_ids = try(each.value.computed_ingress_with_prefix_list_ids, var.defaults.computed_ingress_with_prefix_list_ids, []) + computed_ingress_with_self = try(each.value.computed_ingress_with_self, var.defaults.computed_ingress_with_self, []) + computed_ingress_with_source_security_group_id = try(each.value.computed_ingress_with_source_security_group_id, var.defaults.computed_ingress_with_source_security_group_id, []) + create = try(each.value.create, var.defaults.create, true) + description = try(each.value.description, var.defaults.description, "Security Group managed by Terraform") + egress_cidr_blocks = try(each.value.egress_cidr_blocks, var.defaults.egress_cidr_blocks, ["0.0.0.0/0"]) + egress_ipv6_cidr_blocks = try(each.value.egress_ipv6_cidr_blocks, var.defaults.egress_ipv6_cidr_blocks, ["::/0"]) + egress_prefix_list_ids = try(each.value.egress_prefix_list_ids, var.defaults.egress_prefix_list_ids, []) + egress_rules = try(each.value.egress_rules, var.defaults.egress_rules, []) + egress_with_cidr_blocks = try(each.value.egress_with_cidr_blocks, var.defaults.egress_with_cidr_blocks, []) + egress_with_ipv6_cidr_blocks = try(each.value.egress_with_ipv6_cidr_blocks, var.defaults.egress_with_ipv6_cidr_blocks, []) + egress_with_prefix_list_ids = try(each.value.egress_with_prefix_list_ids, var.defaults.egress_with_prefix_list_ids, []) + egress_with_self = try(each.value.egress_with_self, var.defaults.egress_with_self, []) + egress_with_source_security_group_id = try(each.value.egress_with_source_security_group_id, var.defaults.egress_with_source_security_group_id, []) + ingress_cidr_blocks = try(each.value.ingress_cidr_blocks, var.defaults.ingress_cidr_blocks, []) + ingress_ipv6_cidr_blocks = try(each.value.ingress_ipv6_cidr_blocks, var.defaults.ingress_ipv6_cidr_blocks, []) + ingress_prefix_list_ids = try(each.value.ingress_prefix_list_ids, var.defaults.ingress_prefix_list_ids, []) + ingress_rules = try(each.value.ingress_rules, var.defaults.ingress_rules, []) + ingress_with_cidr_blocks = try(each.value.ingress_with_cidr_blocks, var.defaults.ingress_with_cidr_blocks, []) + ingress_with_ipv6_cidr_blocks = try(each.value.ingress_with_ipv6_cidr_blocks, var.defaults.ingress_with_ipv6_cidr_blocks, []) + ingress_with_prefix_list_ids = try(each.value.ingress_with_prefix_list_ids, var.defaults.ingress_with_prefix_list_ids, []) + ingress_with_self = try(each.value.ingress_with_self, var.defaults.ingress_with_self, []) + ingress_with_source_security_group_id = try(each.value.ingress_with_source_security_group_id, var.defaults.ingress_with_source_security_group_id, []) + name = try(each.value.name, var.defaults.name) + number_of_computed_egress_cidr_blocks = try(each.value.number_of_computed_egress_cidr_blocks, var.defaults.number_of_computed_egress_cidr_blocks, 0) + number_of_computed_egress_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_ipv6_cidr_blocks, 0) + number_of_computed_egress_prefix_list_ids = try(each.value.number_of_computed_egress_prefix_list_ids, var.defaults.number_of_computed_egress_prefix_list_ids, 0) + number_of_computed_egress_rules = try(each.value.number_of_computed_egress_rules, var.defaults.number_of_computed_egress_rules, 0) + number_of_computed_egress_with_cidr_blocks = try(each.value.number_of_computed_egress_with_cidr_blocks, var.defaults.number_of_computed_egress_with_cidr_blocks, 0) + number_of_computed_egress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_egress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_egress_with_ipv6_cidr_blocks, 0) + number_of_computed_egress_with_prefix_list_ids = try(each.value.number_of_computed_egress_with_prefix_list_ids, var.defaults.number_of_computed_egress_with_prefix_list_ids, 0) + number_of_computed_egress_with_self = try(each.value.number_of_computed_egress_with_self, var.defaults.number_of_computed_egress_with_self, 0) + number_of_computed_egress_with_source_security_group_id = try(each.value.number_of_computed_egress_with_source_security_group_id, var.defaults.number_of_computed_egress_with_source_security_group_id, 0) + number_of_computed_ingress_cidr_blocks = try(each.value.number_of_computed_ingress_cidr_blocks, var.defaults.number_of_computed_ingress_cidr_blocks, 0) + number_of_computed_ingress_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_ipv6_cidr_blocks, 0) + number_of_computed_ingress_prefix_list_ids = try(each.value.number_of_computed_ingress_prefix_list_ids, var.defaults.number_of_computed_ingress_prefix_list_ids, 0) + number_of_computed_ingress_rules = try(each.value.number_of_computed_ingress_rules, var.defaults.number_of_computed_ingress_rules, 0) + number_of_computed_ingress_with_cidr_blocks = try(each.value.number_of_computed_ingress_with_cidr_blocks, var.defaults.number_of_computed_ingress_with_cidr_blocks, 0) + number_of_computed_ingress_with_ipv6_cidr_blocks = try(each.value.number_of_computed_ingress_with_ipv6_cidr_blocks, var.defaults.number_of_computed_ingress_with_ipv6_cidr_blocks, 0) + number_of_computed_ingress_with_prefix_list_ids = try(each.value.number_of_computed_ingress_with_prefix_list_ids, var.defaults.number_of_computed_ingress_with_prefix_list_ids, 0) + number_of_computed_ingress_with_self = try(each.value.number_of_computed_ingress_with_self, var.defaults.number_of_computed_ingress_with_self, 0) + number_of_computed_ingress_with_source_security_group_id = try(each.value.number_of_computed_ingress_with_source_security_group_id, var.defaults.number_of_computed_ingress_with_source_security_group_id, 0) + revoke_rules_on_delete = try(each.value.revoke_rules_on_delete, var.defaults.revoke_rules_on_delete, false) + tags = try(each.value.tags, var.defaults.tags, {}) + use_name_prefix = try(each.value.use_name_prefix, var.defaults.use_name_prefix, true) + vpc_id = try(each.value.vpc_id, var.defaults.vpc_id) +} diff --git a/wrappers/zookeeper/outputs.tf b/wrappers/zookeeper/outputs.tf new file mode 100644 index 00000000..ec6da5f4 --- /dev/null +++ b/wrappers/zookeeper/outputs.tf @@ -0,0 +1,5 @@ +output "wrapper" { + description = "Map of outputs of a wrapper." + value = module.wrapper + # sensitive = false # No sensitive module output found +} diff --git a/wrappers/zookeeper/variables.tf b/wrappers/zookeeper/variables.tf new file mode 100644 index 00000000..a6ea0962 --- /dev/null +++ b/wrappers/zookeeper/variables.tf @@ -0,0 +1,11 @@ +variable "defaults" { + description = "Map of default values which will be used for each item." + type = any + default = {} +} + +variable "items" { + description = "Maps of items to create a wrapper from. Values are passed through to the module." + type = any + default = {} +} diff --git a/wrappers/zookeeper/versions.tf b/wrappers/zookeeper/versions.tf new file mode 100644 index 00000000..c4f23b0b --- /dev/null +++ b/wrappers/zookeeper/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.29" + } + } +}