-
-
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
Conversation
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.
Summary of Changes
Hello @posquit0, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request refactors the configuration of resource groups within several ElastiCache modules. The main objective is to enhance the modularity and maintainability of the codebase by transitioning from disparate variables to a unified, object-based approach for defining resource group parameters.
Highlights
- Resource Group Configuration Refactor: Consolidated multiple individual
resource_group_*
variables into a single, object-basedresource_group
variable for improved organization and consistency across modules. - Module Version Update: Updated the internal
resource-group
module dependency from version~> 0.10.0
to~> 0.12.0
in affected modules. - Variable Reference Updates: All internal references to resource group parameters have been updated to use the new
var.resource_group.*
structure, reflecting the object-based configuration. - New Resource Group Output: Added a
resource_group
output to each affected module, providing details of the managed resource group for external consumption.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request effectively refactors the resource group configuration across three modules by consolidating multiple variables into a single object, which is a great improvement for usability. The version update for the resource group module is also correctly applied. My review includes suggestions to further enhance the implementation by introducing a local variable to avoid repeating logic. This will improve the code's readability and maintainability, and also make the new resource_group
output's structure more consistent and predictable for consumers of these modules.
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 | ||
} | ||
: {} | ||
) | ||
) |
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 (the arn
and name
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 for resource-group.tf
, you can simplify this output to be more readable and consistent.
value = {
enabled = local.is_resource_group_created
arn = local.is_resource_group_created ? module.resource_group[0].arn : null
name = local.is_resource_group_created ? module.resource_group[0].name : null
}
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 comment
The reason will be displayed to describe this comment to others. Learn more.
The condition var.resource_group.enabled && var.module_tags_enabled
is also used in outputs.tf
. To avoid repetition and improve maintainability, consider defining it as a local variable within the locals
block at the top of this file.
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.
count = local.is_resource_group_created ? 1 : 0
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 | ||
} | ||
: {} | ||
) | ||
) |
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 (the arn
and name
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 for resource-group.tf
, you can simplify this output to be more readable and consistent.
value = {
enabled = local.is_resource_group_created
arn = local.is_resource_group_created ? module.resource_group[0].arn : null
name = local.is_resource_group_created ? module.resource_group[0].name : null
}
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 comment
The reason will be displayed to describe this comment to others. Learn more.
The condition var.resource_group.enabled && var.module_tags_enabled
is also used in outputs.tf
. To avoid repetition and improve maintainability, consider defining it as a local variable within the locals
block at the top of this file.
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.
count = local.is_resource_group_created ? 1 : 0
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 | ||
} | ||
: {} | ||
) | ||
) |
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 (the arn
and name
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 for resource-group.tf
, you can simplify this output to be more readable and consistent.
value = {
enabled = local.is_resource_group_created
arn = local.is_resource_group_created ? module.resource_group[0].arn : null
name = local.is_resource_group_created ? module.resource_group[0].name : null
}
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 comment
The reason will be displayed to describe this comment to others. Learn more.
The condition var.resource_group.enabled && var.module_tags_enabled
is also used in outputs.tf
. To avoid repetition and improve maintainability, consider defining it as a local variable within the locals
block at the top of this file.
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.
count = local.is_resource_group_created ? 1 : 0
Summary
Update resource group configuration to use object-based pattern.
Changes
Modules Updated
Test Plan