-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: improve how to use resource_group in modules #40
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 |
---|---|---|
|
@@ -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
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 current implementation for the 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
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
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 current implementation for the 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
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
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 current implementation for the 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
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
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 current implementation for the 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
|
||
} |
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.
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 theenabled
key. When enabled, it containsenabled
,arn
, andname
.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.