-
-
Notifications
You must be signed in to change notification settings - Fork 3
feat: improve how to use resource_group in modules #112
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 |
|---|---|---|
|
|
@@ -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
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 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 A better approach is to always include these attributes, but set them to |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
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 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 A better approach is to always include these attributes, but set them to |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
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 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 A better approach is to always include these attributes, but set them to |
||
| } | ||
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 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
arnandnameattributes.A better approach is to always include these attributes, but set them to
nullwhen the resource group is not created. This can be achieved more cleanly and concisely using thetry()function.