-
Notifications
You must be signed in to change notification settings - Fork 0
Completely deprecate old NLB from the metaflow-metadata-service module #9
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
This PR completely the deprecation of NLB and its migration to ALB towards DAT-106. The `moved` blocks will be removed with a later PR after a subsequent apply. Test plan --- Check that terraform plan reports destroy of old NLB but no other changes.
WalkthroughThis change removes all conditional logic and variables related to optionally setting up an Application Load Balancer (ALB) or pointing the API Gateway to an ALB in the metadata-service module. The configuration now always creates and uses the Network Load Balancer (NLB), and the variables Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Terraform
participant AWS
User->>Terraform: Apply metadata-service module
Terraform->>AWS: Create NLB (aws_lb.apigw_nlb)
Terraform->>AWS: Create associated target groups, listeners, security groups
Terraform->>AWS: Configure ECS service with dynamic load balancer blocks
Terraform->>AWS: Configure API Gateway VPC link to always use NLB
Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🔇 Additional comments (1)
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
modules/metadata-service/ec2.tf (1)
158-166
: Indexing a single-instance resource breaks the plan – remove all[0]
suffixes.All ALB / NLB / SG resources have been converted from
count = 1
lists to singleton resources.
However, many references still use the old indexed address (resource_name[0]
). Oncecount
is gone this address no longer exists andterraform plan
will fail with “Invalid index” errors.Concrete offenders:
aws_security_group.metadata_alb_security_group[0].id
aws_lb.alb[0].arn
aws_lb_target_group.alb_main[0].arn
aws_lb_target_group.alb_db_migrate[0].arn
aws_lb.apigw_nlb[0].arn
aws_lb_target_group.apigw_*[0].arn
Fix all of them by dropping the index:
- security_groups = [aws_security_group.metadata_alb_security_group[0].id] + security_groups = [aws_security_group.metadata_alb_security_group.id] - load_balancer_arn = aws_lb.alb[0].arn + load_balancer_arn = aws_lb.alb.arn - target_group_arn = aws_lb_target_group.alb_main[0].arn + target_group_arn = aws_lb_target_group.alb_main.arn…and similarly for every other occurrence.
Failing to do so will block
terraform plan/apply
and leave the module undeployable.
Please update all references and run a plan to verify.Also applies to: 210-230, 258-306
🧹 Nitpick comments (2)
modules/metadata-service/api-gateway.tf (1)
53-56
: Variable names now misleading – consider renaming for clarity.
local.alb_arn
/alb_dns_name
actually hold the NLB’s ARN/DNS.
While not functionally wrong, the mis-label can confuse future maintainers.-locals { - alb_arn = aws_lb.apigw_nlb.arn - alb_dns_name = aws_lb.apigw_nlb.dns_name +locals { + nlb_arn = aws_lb.apigw_nlb.arn + nlb_dns_name = aws_lb.apigw_nlb.dns_name } ... - target_arns = [local.alb_arn] + target_arns = [local.nlb_arn] ... - uri = "http://${local.alb_dns_name}/{proxy}" + uri = "http://${local.nlb_dns_name}/{proxy}"Renaming avoids cognitive friction and aligns terminology.
modules/metadata-service/ecs.tf (1)
70-73
: List-index mapping works but is brittle – prefer an object map.Relying on parallel lists and numeric indices (
local.alb_ports[0] ↔ local.alb_target_groups[0]
) is error-prone. Represent the relationship explicitly with a map:locals { alb_lb_map = { 8080 = aws_lb_target_group.alb_main.arn 8082 = aws_lb_target_group.alb_db_migrate.arn } } dynamic "load_balancer" { for_each = local.alb_lb_map content { target_group_arn = load_balancer.value container_name = "${var.resource_prefix}service${var.resource_suffix}" container_port = tonumber(load_balancer.key) } }This removes the dependence on positional indices and scales better if more ports are added.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
modules/metadata-service/api-gateway.tf
(1 hunks)modules/metadata-service/ec2.tf
(1 hunks)modules/metadata-service/ecs.tf
(1 hunks)modules/metadata-service/variables.tf
(0 hunks)
💤 Files with no reviewable changes (1)
- modules/metadata-service/variables.tf
🔇 Additional comments (1)
modules/metadata-service/ec2.tf (1)
1-55
:moved {}
blocks are correct but incomplete without the reference fixes.The state-migration blocks accurately map
old_resource[0]
→new_resource
.
Yet because downstream code still points at[0]
, the move will succeed while the plan phase immediately crashes on those stale references (see previous comment). After fixing the indices, keep thesemoved
blocks – they’ll seamlessly migrate the state.
This PR completely the deprecation of NLB and its migration to ALB towards DAT-106.
The
moved
blocks will be removed with a later PR after a subsequent apply.Test plan
Check that terraform plan reports destroy of old NLB but no other changes.