-
-
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 |
---|---|---|
@@ -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, | ||
|
@@ -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 | ||
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 condition For example: locals {
...
is_resource_group_created = var.resource_group.enabled && var.module_tags_enabled
} Then you can simplify this line to use the new local.
|
||
|
||
name = local.resource_group_name | ||
description = var.resource_group_description | ||
description = var.resource_group.description | ||
|
||
query = { | ||
resource_tags = local.module_tags | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,19 @@ output "users" { | |
description = "The list of user IDs that belong to the user group." | ||
value = values(aws_elasticache_user_group_association.this)[*].user_id | ||
} | ||
|
||
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
+28
to
+39
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. This output's value can be simplified. Using Assuming you create the
|
||
} |
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, | ||
|
@@ -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 | ||
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 condition For example: locals {
...
is_resource_group_created = var.resource_group.enabled && var.module_tags_enabled
} Then you can simplify this line to use the new local.
|
||
|
||
name = local.resource_group_name | ||
description = var.resource_group_description | ||
description = var.resource_group.description | ||
|
||
query = { | ||
resource_tags = local.module_tags | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,19 @@ output "password_required" { | |
description = "Whether a password is required for this user." | ||
value = !aws_elasticache_user.this.no_password_required | ||
} | ||
|
||
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
+28
to
+39
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. This output's value can be simplified. Using Assuming you create the
|
||
} |
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, | ||
|
@@ -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 | ||
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 condition For example: locals {
...
is_resource_group_created = var.resource_group.enabled && var.module_tags_enabled
} Then you can simplify this line to use the new local.
|
||
|
||
name = local.resource_group_name | ||
description = var.resource_group_description | ||
description = var.resource_group.description | ||
|
||
query = { | ||
resource_tags = local.module_tags | ||
|
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.
This output's value can be simplified. Using
merge
with a conditional map makes the logic a bit complex and results in an object with a non-static shape (thearn
andname
keys are conditional). It's generally better for module outputs to have a consistent structure.Assuming you create the
local.is_resource_group_created
variable as suggested forresource-group.tf
, you can simplify this output to be more readable and consistent.