Skip to content

feat: Enable integration with multiple LBs #297

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

jwadolowski
Copy link
Contributor

@jwadolowski jwadolowski commented Apr 3, 2025

what

Enable ECS service registration in multiple LB target groups (docs). Currently, only 1 ALB and 1 NLB can be associated with a given service definition.

why

There are scenarios where an ECS-hosted app needs to register itself into multiple target groups to handle use cases such as:

  • traffic split between internal and internet-facing LBs
  • handling of different protocols (e.g., HTTPS/gRPC) that require distinct target group configurations
  • an app that exposes multiple ports (e.g. 80 + 8080 + 8443)
  • etc

references

Copy link

coderabbitai bot commented Apr 3, 2025

📝 Walkthrough

Walkthrough

The changes introduce support for configuring additional load balancers. A new input parameter, additional_lbs, is documented and added to the configuration. This parameter accepts a list of objects with optional values for container_name and container_port (defaulting to the main container’s port) and a required target_group_arn. The implementation in the code creates a new local variable derived from this parameter and updates the aggregated load balancer list. Additionally, a corresponding variable is declared with the appropriate type and default value.

Changes

File(s) Change Summary
docs/terraform.md Added documentation for the new input parameter additional_lbs (list(object) with optional container_name and container_port, and required target_group_arn).
main.tf, variables.tf In main.tf, introduced a new local variable additional_lbs using list comprehension and updated the load_balancers aggregation; in variables.tf, declared the new variable additional_lbs with its type, description, and default value ([]).

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 884d379 and f649a40.

⛔ Files ignored due to path filters (1)
  • README.md is excluded by !README.md
📒 Files selected for processing (3)
  • docs/terraform.md (1 hunks)
  • main.tf (1 hunks)
  • variables.tf (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (4)
variables.tf (1)

1145-1153: Define New Variable for Additional Load Balancers

The new variable additional_lbs is defined with the correct type:

  • Uses a list of objects with container_name and container_port marked as optional, and target_group_arn as required.
  • The description clearly explains its purpose and the default value is set to an empty list.

This aligns with the PR objective to enable support for multiple load balancer target groups.

docs/terraform.md (1)

40-41: Document the New additional_lbs Input Parameter

The documentation section has been updated to include the new input parameter additional_lbs with a thorough description and correct type formatting. The documented type is consistent with that specified in variables.tf and clarifies that container_name and container_port are optional while target_group_arn is required.

main.tf (2)

129-136: Implement Local Block for Additional Load Balancers

The local variable additional_lbs is defined using a list comprehension that iterates over var.additional_lbs. The logic:

  • Falls back to module.this.id if container_name is not provided.
  • Falls back to var.container_port if container_port is null.
  • Sets elb_name to null and correctly extracts target_group_arn.

This implementation is clean and meets the objective of configuring additional load balancer settings.


138-142: Concatenate Updated Load Balancers List

The load_balancers local variable is now defined by concatenating:

  • The primary ALB configuration [local.alb]
  • A conditional inclusion of the NLB configuration (if defined)
  • The new local.additional_lbs list

This ensures that additional load balancers are seamlessly integrated with the standard ALB and optionally an NLB configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@mergify mergify bot added the triage Needs triage label Apr 3, 2025
@jwadolowski jwadolowski marked this pull request as ready for review April 10, 2025 15:21
@jwadolowski jwadolowski requested review from a team as code owners April 10, 2025 15:21
@jwadolowski jwadolowski requested review from Gowiem and nitrocode April 10, 2025 15:21
@gberenice
Copy link
Contributor

/terratest

Copy link
Contributor

@gberenice gberenice left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@gberenice gberenice merged commit 5f276e6 into cloudposse:main Apr 11, 2025
19 checks passed
@mergify mergify bot removed the triage Needs triage label Apr 11, 2025
Copy link
Contributor

These changes were released in v2.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants