Skip to content

Conversation

posquit0
Copy link
Member

Summary

Update resource group configuration to use object-based pattern.

Changes

  • Update module version from ~> 0.10.0 to ~> 0.12.0
  • Replace individual resource_group_* variables with single object variable
  • Update all references to use var.resource_group.* structure
  • Add resource_group output to each module

Modules Updated

  • elasticache-redis-cluster
  • elasticache-redis-user
  • elasticache-redis-user-group

Test Plan

  • Review variable changes
  • Verify resource-group module references are correct
  • Check outputs are properly formatted

Copy link

@gemini-code-assist gemini-code-assist bot left a 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-based resource_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

  1. 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +187 to +198
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
}
: {}
)
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

Comment on lines +28 to +39
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
}
: {}
)
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

Comment on lines +28 to +39
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
}
: {}
)
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

@posquit0 posquit0 merged commit 0e6a753 into main Sep 10, 2025
11 checks passed
@posquit0 posquit0 deleted the feat/improve-resource-group-usage branch September 10, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant