Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions modules/dns-firewall-domain-list/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,19 @@ output "domains" {
description = "The list of domains from the firewall domain list."
value = aws_route53_resolver_firewall_domain_list.this.domains
}

output "resource_group" {
description = "The resource group created to manage resources in this module."
value = merge(
{
enabled = var.resource_group.enabled && var.module_tags_enabled
},
(var.resource_group.enabled && var.module_tags_enabled
? {
arn = module.resource_group[0].arn
name = module.resource_group[0].name
}
: {}
)
)
Comment on lines +23 to +34

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation for the resource_group output value is a bit complex and produces an inconsistent object structure. When the resource group is disabled, the output object only contains the enabled key. When enabled, it contains enabled, arn, and name.

It's a best practice for module outputs to have a consistent structure. You can simplify this logic and ensure a consistent output by using the try() function. This makes the output predictable for module consumers.

  value = {
    enabled = var.resource_group.enabled && var.module_tags_enabled
    arn     = try(module.resource_group[0].arn, null)
    name    = try(module.resource_group[0].name, null)
  }

}
10 changes: 5 additions & 5 deletions modules/dns-firewall-domain-list/resource-group.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
locals {
resource_group_name = (var.resource_group_name != ""
? var.resource_group_name
resource_group_name = (var.resource_group.name != ""
? var.resource_group.name
: join(".", [
local.metadata.package,
local.metadata.module,
Expand All @@ -12,12 +12,12 @@ locals {

module "resource_group" {
source = "tedilabs/misc/aws//modules/resource-group"
version = "~> 0.10.0"
version = "~> 0.12.0"

count = (var.resource_group_enabled && var.module_tags_enabled) ? 1 : 0
count = (var.resource_group.enabled && var.module_tags_enabled) ? 1 : 0

name = local.resource_group_name
description = var.resource_group_description
description = var.resource_group.description

query = {
resource_tags = local.module_tags
Expand Down
32 changes: 15 additions & 17 deletions modules/dns-firewall-domain-list/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,21 @@ variable "module_tags_enabled" {
# Resource Group
###################################################

variable "resource_group_enabled" {
description = "(Optional) Whether to create Resource Group to find and group AWS resources which are created by this module."
type = bool
default = true
nullable = false
}

variable "resource_group_name" {
description = "(Optional) The name of Resource Group. A Resource Group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`."
type = string
default = ""
nullable = false
}

variable "resource_group_description" {
description = "(Optional) The description of Resource Group."
type = string
default = "Managed by Terraform."
nullable = false

variable "resource_group" {
description = <<EOF
(Optional) A configurations of Resource Group for this module. `resource_group` as defined below.
(Optional) `enabled` - Whether to create Resource Group to find and group AWS resources which are created by this module. Defaults to `true`.
(Optional) `name` - The name of Resource Group. A Resource Group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`. If not provided, a name will be generated using the module name and instance name.
(Optional) `description` - The description of Resource Group. Defaults to `Managed by Terraform.`.
EOF
type = object({
enabled = optional(bool, true)
name = optional(string, "")
description = optional(string, "Managed by Terraform.")
})
default = {}
nullable = false
}
16 changes: 16 additions & 0 deletions modules/dns-firewall-rule-group/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,19 @@ output "sharing" {
shares = module.share
}
}

output "resource_group" {
description = "The resource group created to manage resources in this module."
value = merge(
{
enabled = var.resource_group.enabled && var.module_tags_enabled
},
(var.resource_group.enabled && var.module_tags_enabled
? {
arn = module.resource_group[0].arn
name = module.resource_group[0].name
}
: {}
)
)
Comment on lines +65 to +76

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation for the resource_group output value is a bit complex and produces an inconsistent object structure. When the resource group is disabled, the output object only contains the enabled key. When enabled, it contains enabled, arn, and name.

It's a best practice for module outputs to have a consistent structure. You can simplify this logic and ensure a consistent output by using the try() function. This makes the output predictable for module consumers.

  value = {
    enabled = var.resource_group.enabled && var.module_tags_enabled
    arn     = try(module.resource_group[0].arn, null)
    name    = try(module.resource_group[0].name, null)
  }

}
10 changes: 5 additions & 5 deletions modules/dns-firewall-rule-group/resource-group.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
locals {
resource_group_name = (var.resource_group_name != ""
? var.resource_group_name
resource_group_name = (var.resource_group.name != ""
? var.resource_group.name
: join(".", [
local.metadata.package,
local.metadata.module,
Expand All @@ -12,12 +12,12 @@ locals {

module "resource_group" {
source = "tedilabs/misc/aws//modules/resource-group"
version = "~> 0.10.0"
version = "~> 0.12.0"

count = (var.resource_group_enabled && var.module_tags_enabled) ? 1 : 0
count = (var.resource_group.enabled && var.module_tags_enabled) ? 1 : 0

name = local.resource_group_name
description = var.resource_group_description
description = var.resource_group.description

query = {
resource_tags = local.module_tags
Expand Down
34 changes: 16 additions & 18 deletions modules/dns-firewall-rule-group/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -104,26 +104,8 @@ variable "module_tags_enabled" {
# Resource Group
###################################################

variable "resource_group_enabled" {
description = "(Optional) Whether to create Resource Group to find and group AWS resources which are created by this module."
type = bool
default = true
nullable = false
}

variable "resource_group_name" {
description = "(Optional) The name of Resource Group. A Resource Group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`."
type = string
default = ""
nullable = false
}

variable "resource_group_description" {
description = "(Optional) The description of Resource Group."
type = string
default = "Managed by Terraform."
nullable = false
}


###################################################
Expand All @@ -145,3 +127,19 @@ variable "shares" {
default = []
nullable = false
}

variable "resource_group" {
description = <<EOF
(Optional) A configurations of Resource Group for this module. `resource_group` as defined below.
(Optional) `enabled` - Whether to create Resource Group to find and group AWS resources which are created by this module. Defaults to `true`.
(Optional) `name` - The name of Resource Group. A Resource Group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`. If not provided, a name will be generated using the module name and instance name.
(Optional) `description` - The description of Resource Group. Defaults to `Managed by Terraform.`.
EOF
type = object({
enabled = optional(bool, true)
name = optional(string, "")
description = optional(string, "Managed by Terraform.")
})
default = {}
nullable = false
}
16 changes: 16 additions & 0 deletions modules/dns-firewall/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,19 @@ output "rule_groups" {
}
}
}

output "resource_group" {
description = "The resource group created to manage resources in this module."
value = merge(
{
enabled = var.resource_group.enabled && var.module_tags_enabled
},
(var.resource_group.enabled && var.module_tags_enabled
? {
arn = module.resource_group[0].arn
name = module.resource_group[0].name
}
: {}
)
)
Comment on lines +37 to +48

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation for the resource_group output value is a bit complex and produces an inconsistent object structure. When the resource group is disabled, the output object only contains the enabled key. When enabled, it contains enabled, arn, and name.

It's a best practice for module outputs to have a consistent structure. You can simplify this logic and ensure a consistent output by using the try() function. This makes the output predictable for module consumers.

  value = {
    enabled = var.resource_group.enabled && var.module_tags_enabled
    arn     = try(module.resource_group[0].arn, null)
    name    = try(module.resource_group[0].name, null)
  }

}
10 changes: 5 additions & 5 deletions modules/dns-firewall/resource-group.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
locals {
resource_group_name = (var.resource_group_name != ""
? var.resource_group_name
resource_group_name = (var.resource_group.name != ""
? var.resource_group.name
: join(".", [
local.metadata.package,
local.metadata.module,
Expand All @@ -12,12 +12,12 @@ locals {

module "resource_group" {
source = "tedilabs/misc/aws//modules/resource-group"
version = "~> 0.10.0"
version = "~> 0.12.0"

count = (var.resource_group_enabled && var.module_tags_enabled) ? 1 : 0
count = (var.resource_group.enabled && var.module_tags_enabled) ? 1 : 0

name = local.resource_group_name
description = var.resource_group_description
description = var.resource_group.description

query = {
resource_tags = local.module_tags
Expand Down
32 changes: 15 additions & 17 deletions modules/dns-firewall/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,21 @@ variable "module_tags_enabled" {
# Resource Group
###################################################

variable "resource_group_enabled" {
description = "(Optional) Whether to create Resource Group to find and group AWS resources which are created by this module."
type = bool
default = true
nullable = false
}

variable "resource_group_name" {
description = "(Optional) The name of Resource Group. A Resource Group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`."
type = string
default = ""
nullable = false
}

variable "resource_group_description" {
description = "(Optional) The description of Resource Group."
type = string
default = "Managed by Terraform."
nullable = false

variable "resource_group" {
description = <<EOF
(Optional) A configurations of Resource Group for this module. `resource_group` as defined below.
(Optional) `enabled` - Whether to create Resource Group to find and group AWS resources which are created by this module. Defaults to `true`.
(Optional) `name` - The name of Resource Group. A Resource Group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`. If not provided, a name will be generated using the module name and instance name.
(Optional) `description` - The description of Resource Group. Defaults to `Managed by Terraform.`.
EOF
type = object({
enabled = optional(bool, true)
name = optional(string, "")
description = optional(string, "Managed by Terraform.")
})
default = {}
nullable = false
}
16 changes: 16 additions & 0 deletions modules/fms-dns-firewall-policy/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,19 @@ output "attributes" {
cascade_deletion_enabled = aws_fms_policy.this.delete_all_policy_resources
}
}

output "resource_group" {
description = "The resource group created to manage resources in this module."
value = merge(
{
enabled = var.resource_group.enabled && var.module_tags_enabled
},
(var.resource_group.enabled && var.module_tags_enabled
? {
arn = module.resource_group[0].arn
name = module.resource_group[0].name
}
: {}
)
)
Comment on lines +47 to +58

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation for the resource_group output value is a bit complex and produces an inconsistent object structure. When the resource group is disabled, the output object only contains the enabled key. When enabled, it contains enabled, arn, and name.

It's a best practice for module outputs to have a consistent structure. You can simplify this logic and ensure a consistent output by using the try() function. This makes the output predictable for module consumers.

  value = {
    enabled = var.resource_group.enabled && var.module_tags_enabled
    arn     = try(module.resource_group[0].arn, null)
    name    = try(module.resource_group[0].name, null)
  }

}
10 changes: 5 additions & 5 deletions modules/fms-dns-firewall-policy/resource-group.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
locals {
resource_group_name = (var.resource_group_name != ""
? var.resource_group_name
resource_group_name = (var.resource_group.name != ""
? var.resource_group.name
: join(".", [
local.metadata.package,
local.metadata.module,
Expand All @@ -12,12 +12,12 @@ locals {

module "resource_group" {
source = "tedilabs/misc/aws//modules/resource-group"
version = "~> 0.10.0"
version = "~> 0.12.0"

count = (var.resource_group_enabled && var.module_tags_enabled) ? 1 : 0
count = (var.resource_group.enabled && var.module_tags_enabled) ? 1 : 0

name = local.resource_group_name
description = var.resource_group_description
description = var.resource_group.description

query = {
resource_tags = local.module_tags
Expand Down
32 changes: 15 additions & 17 deletions modules/fms-dns-firewall-policy/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,21 @@ variable "module_tags_enabled" {
# Resource Group
###################################################

variable "resource_group_enabled" {
description = "(Optional) Whether to create Resource Group to find and group AWS resources which are created by this module."
type = bool
default = true
nullable = false
}

variable "resource_group_name" {
description = "(Optional) The name of Resource Group. A Resource Group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`."
type = string
default = ""
nullable = false
}

variable "resource_group_description" {
description = "(Optional) The description of Resource Group."
type = string
default = "Managed by Terraform."
nullable = false

variable "resource_group" {
description = <<EOF
(Optional) A configurations of Resource Group for this module. `resource_group` as defined below.
(Optional) `enabled` - Whether to create Resource Group to find and group AWS resources which are created by this module. Defaults to `true`.
(Optional) `name` - The name of Resource Group. A Resource Group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`. If not provided, a name will be generated using the module name and instance name.
(Optional) `description` - The description of Resource Group. Defaults to `Managed by Terraform.`.
EOF
type = object({
enabled = optional(bool, true)
name = optional(string, "")
description = optional(string, "Managed by Terraform.")
})
default = {}
nullable = false
}
16 changes: 16 additions & 0 deletions modules/waf-ip-set/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,19 @@ output "ip_addresses" {
description = "A list of strings that specify one or more IP addresses or blocks of IP addresses in Classless Inter-Domain Routing (CIDR) notation."
value = aws_wafv2_ip_set.this.addresses
}

output "resource_group" {
description = "The resource group created to manage resources in this module."
value = merge(
{
enabled = var.resource_group.enabled && var.module_tags_enabled
},
(var.resource_group.enabled && var.module_tags_enabled
? {
arn = module.resource_group[0].arn
name = module.resource_group[0].name
}
: {}
)
)
Comment on lines +38 to +49

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation for the resource_group output value is a bit complex and produces an inconsistent object structure. When the resource group is disabled, the output object only contains the enabled key. When enabled, it contains enabled, arn, and name.

It's a best practice for module outputs to have a consistent structure. You can simplify this logic and ensure a consistent output by using the try() function. This makes the output predictable for module consumers.

  value = {
    enabled = var.resource_group.enabled && var.module_tags_enabled
    arn     = try(module.resource_group[0].arn, null)
    name    = try(module.resource_group[0].name, null)
  }

}
10 changes: 5 additions & 5 deletions modules/waf-ip-set/resource-group.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
locals {
resource_group_name = (var.resource_group_name != ""
? var.resource_group_name
resource_group_name = (var.resource_group.name != ""
? var.resource_group.name
: join(".", [
local.metadata.package,
local.metadata.module,
Expand All @@ -13,12 +13,12 @@ locals {

module "resource_group" {
source = "tedilabs/misc/aws//modules/resource-group"
version = "~> 0.10.0"
version = "~> 0.12.0"

count = (var.resource_group_enabled && var.module_tags_enabled) ? 1 : 0
count = (var.resource_group.enabled && var.module_tags_enabled) ? 1 : 0

name = local.resource_group_name
description = var.resource_group_description
description = var.resource_group.description

query = {
resource_tags = local.module_tags
Expand Down
Loading