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/alb-instance-target-group/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,19 @@ output "health_check" {
timeout = aws_lb_target_group.this.health_check[0].timeout
}
}

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 +100 to +111

Choose a reason for hiding this comment

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

medium

For better module usability, it's recommended that outputs have a consistent object shape. The current implementation changes the shape of the output object based on whether the resource group is created. This can make it harder for module consumers to use the output, as they need to check for the existence of arn and name attributes.

A better approach is to always include these attributes, but set them to null when the resource group is not created. This can be achieved more cleanly and concisely using the try() function.

  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/alb-instance-target-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
32 changes: 15 additions & 17 deletions modules/alb-instance-target-group/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,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/alb-ip-target-group/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,19 @@ output "health_check" {
timeout = aws_lb_target_group.this.health_check[0].timeout
}
}

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 +106 to +117

Choose a reason for hiding this comment

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

medium

For better module usability, it's recommended that outputs have a consistent object shape. The current implementation changes the shape of the output object based on whether the resource group is created. This can make it harder for module consumers to use the output, as they need to check for the existence of arn and name attributes.

A better approach is to always include these attributes, but set them to null when the resource group is not created. This can be achieved more cleanly and concisely using the try() function.

  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/alb-ip-target-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
32 changes: 15 additions & 17 deletions modules/alb-ip-target-group/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -236,23 +236,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/alb-lambda-target-group/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,19 @@ output "health_check" {
timeout = aws_lb_target_group.this.health_check[0].timeout
}
}

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 +66 to +77

Choose a reason for hiding this comment

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

medium

For better module usability, it's recommended that outputs have a consistent object shape. The current implementation changes the shape of the output object based on whether the resource group is created. This can make it harder for module consumers to use the output, as they need to check for the existence of arn and name attributes.

A better approach is to always include these attributes, but set them to null when the resource group is not created. This can be achieved more cleanly and concisely using the try() function.

  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/alb-lambda-target-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
32 changes: 15 additions & 17 deletions modules/alb-lambda-target-group/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,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/alb-listener/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,19 @@ output "rules" {
}
}
}

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 +177 to +188

Choose a reason for hiding this comment

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

medium

For better module usability, it's recommended that outputs have a consistent object shape. The current implementation changes the shape of the output object based on whether the resource group is created. This can make it harder for module consumers to use the output, as they need to check for the existence of arn and name attributes.

A better approach is to always include these attributes, but set them to null when the resource group is not created. This can be achieved more cleanly and concisely using the try() function.

  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/alb-listener/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/alb-listener/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,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
}
Loading