-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: improve how to use resource_group in modules #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,23 +62,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 | ||
Comment on lines
+69
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation within the
|
||
type = object({ | ||
enabled = optional(bool, true) | ||
name = optional(string, "") | ||
description = optional(string, "Managed by Terraform.") | ||
}) | ||
default = {} | ||
nullable = false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,3 +123,19 @@ output "aws_service_targets" { | |
} | ||
} | ||
} | ||
|
||
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
+129
to
+140
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For better consistency in the module's output API, it's preferable for the You can achieve this by using a single conditional expression that returns a complete object with
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -340,23 +340,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 | ||
Comment on lines
+347
to
+352
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation within the
|
||
type = object({ | ||
enabled = optional(bool, true) | ||
name = optional(string, "") | ||
description = optional(string, "Managed by Terraform.") | ||
}) | ||
default = {} | ||
nullable = false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,3 +217,19 @@ output "zookeeper_connections" { | |
tls = aws_msk_cluster.this.zookeeper_connect_string_tls | ||
} | ||
} | ||
|
||
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
+223
to
+234
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For better consistency in the module's output API, it's preferable for the You can achieve this by using a single conditional expression that returns a complete object with
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,23 +271,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 | ||
Comment on lines
+278
to
+283
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation within the
|
||
type = object({ | ||
enabled = optional(bool, true) | ||
name = optional(string, "") | ||
description = optional(string, "Managed by Terraform.") | ||
}) | ||
default = {} | ||
nullable = false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,4 +83,19 @@ output "custom_mail_from" { | |
# k => v | ||
# if !contains(["arn", "id", "email_identity", "identity_type", "tags", "tags_all", "dkim_signing_attributes", "verified_for_sending_status", "configuration_set_name"], k) | ||
# } | ||
# } | ||
# } | ||
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
+89
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For better consistency in the module's output API, it's preferable for the You can achieve this by using a single conditional expression that returns a complete object with
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,23 +134,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 | ||
Comment on lines
+141
to
+146
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation within the
|
||
type = object({ | ||
enabled = optional(bool, true) | ||
name = optional(string, "") | ||
description = optional(string, "Managed by Terraform.") | ||
}) | ||
default = {} | ||
nullable = false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,3 +66,19 @@ output "zz" { | |
policy = aws_sns_topic_policy.this | ||
} | ||
} | ||
|
||
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
+72
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For better consistency in the module's output API, it's preferable for the You can achieve this by using a single conditional expression that returns a complete object with
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better consistency in the module's output API, it's preferable for the
resource_group
output to always have the same shape, regardless of whether the resource group is enabled or not. This avoids consumers of the module having to check for the existence of thearn
andname
attributes.You can achieve this by using a single conditional expression that returns a complete object with
null
values forarn
andname
when the resource group is disabled.