Skip to content

Add ALB ingress rules referencing source security groups (rvn-ecs-cluster 0.5.1) - #80

Open
mabadir wants to merge 1 commit into
mainfrom
mabadir/alb-sg-enhancements
Open

Add ALB ingress rules referencing source security groups (rvn-ecs-cluster 0.5.1)#80
mabadir wants to merge 1 commit into
mainfrom
mabadir/alb-sg-enhancements

Conversation

@mabadir

@mabadir mabadir commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds support for ALB ingress rules that reference source security groups, so load balancers can accept traffic from sources without static CIDRs — e.g. the CloudFront VPC origins managed security group (CloudFront-VPCOrigins-Service-SG).

Changes

  • networking/alb: new ingress_security_group_ids variable; creates HTTP/HTTPS ingress rules with referenced_security_group_id on each enabled listener port
  • compute/ecs_cluster: new private_alb_ingress_security_group_ids (exposed as a Ravion input) and public_alb_ingress_security_group_ids (Terraform variable, matching the convention that public ALB ingress CIDRs are not exposed as inputs)
  • Definition bumped to rvn-ecs-cluster 0.5.1 (non-breaking, additive)
  • tftest coverage for both modules; READMEs updated

Verification

  • tofu fmt -check, tofu validate: pass
  • Module definition compile + guardrails: pass
  • Real tofu plan against a scratch root: private ALB security group gets HTTP 80 + HTTPS 443 ingress rules referencing the source SG, alongside existing CIDR rules (unchanged)
  • Native tftest additions match existing file conventions (note: native-tests CI job is currently disabled; pre-existing failures/skips on tofu 1.12 unchanged)

Context

Motivated by a manual inbound rule (TCP 443 from the CloudFront VPC origins SG) added to a private ALB; this codifies that pattern into the module.

Greptile Summary

Adds security-group-referenced ingress support for ALB listener ports.

  • Adds reusable ALB input and HTTP/HTTPS security-group ingress rules.
  • Wires private and public ECS cluster ALBs to the new Terraform inputs.
  • Exposes private ALB source security groups in the Ravion definition and updates tests and documentation.

Confidence Score: 4/5

The duplicate-ID apply failure should be fixed before merging; the release version should also be updated to represent the new feature accurately.

Repeated values accepted by the new input become separately keyed but semantically identical AWS ingress rules, causing the ALB apply to fail, while the module-definition version understates the feature addition.

Files Needing Attention: networking/alb/variables.tf, networking/alb/security_group.tf, compute/ecs_cluster/rvn-ecs-cluster-definition.yml

Important Files Changed

Filename Overview
networking/alb/security_group.tf Adds source-security-group ingress rules for each enabled HTTP and HTTPS listener; duplicate input values can produce duplicate AWS rules.
networking/alb/variables.tf Adds the ALB security-group ID input, but its validation does not reject duplicate IDs.
compute/ecs_cluster/load_balancers.tf Correctly forwards the new public and private ALB inputs to the shared ALB module.
compute/ecs_cluster/variables.tf Adds validated public and private ALB security-group ID variables with empty defaults.
compute/ecs_cluster/rvn-ecs-cluster-definition.yml Exposes the private ALB input and maps it into Terraform, but uses a patch version for a new feature.
networking/alb/tests/basic.tftest.hcl Covers normal source-security-group ingress creation and the empty default.
compute/ecs_cluster/tests/basic.tftest.hcl Verifies public and private ECS cluster ALBs each receive HTTP and HTTPS source-security-group rules.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Input["ECS cluster / ALB input<br/>source security-group IDs"] --> ALB["networking/alb"]
  ALB --> HTTP["HTTP ingress rule<br/>enabled listener port"]
  ALB --> HTTPS["HTTPS ingress rule<br/>enabled listener port"]
  HTTP --> SG["ALB security group"]
  HTTPS --> SG
  Source["Members of referenced<br/>source security group"] --> SG
Loading
Prompt To Fix All With AI
### Issue 1
networking/alb/variables.tf:252
**Duplicate source rules fail apply**

When `ingress_security_group_ids` contains the same ID more than once, each entry becomes a separately keyed but otherwise identical AWS ingress rule, causing the ALB apply to fail when AWS rejects the duplicate rule.

```suggestion
    condition     = length(distinct(var.ingress_security_group_ids)) == length(var.ingress_security_group_ids) && alltrue([for sg in var.ingress_security_group_ids : can(regex("^sg-", sg))])
```

### Issue 2
compute/ecs_cluster/rvn-ecs-cluster-definition.yml:6-7
**Feature uses patch version**

Version `0.5.1` classifies the new optional catalog input as a patch even though the repository's semantic-versioning convention assigns new features and optional inputs a minor release, making feature availability unclear to consumers.

```suggestion
  version: 0.6.0
  description: "Add private_alb_ingress_security_group_ids input (and public_alb_ingress_security_group_ids Terraform variable) to allow ALB ingress rules that reference source security groups, such as the CloudFront VPC origins security group."
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "Add ALB ingress rules referencing source..." | Re-trigger Greptile

Greptile also left 2 inline comments on this PR.

Context used (4)

Add ingress_security_group_ids to networking/alb and expose
private_alb_ingress_security_group_ids (Ravion input) and
public_alb_ingress_security_group_ids (Terraform variable) on
compute/ecs_cluster. This allows ALB ingress for sources without
static CIDRs, such as the CloudFront VPC origins security group.

Release rvn-ecs-cluster 0.5.1.
@github-actions

Copy link
Copy Markdown

Ravion Module Publish Plan

Dry run only. No Ravion API mutations were made.

Module Current Version New Version Description
rvn-ecs-cluster 0.5.0 0.5.1 Add private_alb_ingress_security_group_ids input (and public_alb_ingress_security_group_ids Terraform variable) to allow ALB ingress rules that reference source security groups, such as the CloudFront VPC origins security group.

Diffs

rvn-ecs-cluster 0.5.0 -> 0.5.1

--- remote
+++ compiled
     show_when:
       private_alb_enabled: true
     type: string_array
+  - add_button_label: Add security group
+    collapsible: true
+    description: Security groups whose members can access the private ALB. Useful for sources without static CIDRs, such as CloudFront VPC origins.
+    id: private_alb_ingress_security_group_ids
+    label: Ingress security groups
+    placeholder: sg-...
+    show_when:
+      private_alb_enabled: true
+    type: string_array
   - collapsible: true
     description: Idle timeout for the private ALB.
     id: private_alb_idle_timeout
@@
   - **Public and private Network Load Balancers** for TCP/UDP and static IP use cases
   - **CloudWatch Container Insights** dashboard metrics for production visibility
 
-  Terraform source: [flightcontrolhq/modules/compute/ecs_cluster](https://github.com/flightcontrolhq/modules/tree/rvn-ecs-cluster@0.5.0/compute/ecs_cluster)
+  Terraform source: [flightcontrolhq/modules/compute/ecs_cluster](https://github.com/flightcontrolhq/modules/tree/rvn-ecs-cluster@0.5.1/compute/ecs_cluster)
 
   ## Use cases
 
@@
         base_path: compute/ecs_cluster
         branch: main
         execution_environment_id: << module.input.execution_environment_id >>
-        ref: rvn-ecs-cluster@0.5.0
+        ref: rvn-ecs-cluster@0.5.1
         repo: https://github.com/flightcontrolhq/modules
         stack_id: <<stack.id>>
         terraform_variables:
@@
           private_alb_idle_timeout: << module.input.private_alb_idle_timeout >>
           private_alb_ingress_cidr_blocks: << module.input.private_alb_ingress_cidr_blocks >>
           private_alb_ingress_ipv6_cidr_blocks: << module.input.private_alb_ingress_ipv6_cidr_blocks >>
+          private_alb_ingress_security_group_ids: << module.input.private_alb_ingress_security_group_ids >>
           private_alb_ssl_policy: << module.input.private_alb_ssl_policy >>
           private_nlb_access_logs_bucket_arn: << module.input.private_nlb_access_logs_bucket_arn >>
           private_nlb_access_logs_enabled: << module.input.private_nlb_access_logs_enabled >>

default = []

validation {
condition = alltrue([for sg in var.ingress_security_group_ids : can(regex("^sg-", sg))])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Duplicate source rules fail apply

When ingress_security_group_ids contains the same ID more than once, each entry becomes a separately keyed but otherwise identical AWS ingress rule, causing the ALB apply to fail when AWS rejects the duplicate rule.

Suggested change
condition = alltrue([for sg in var.ingress_security_group_ids : can(regex("^sg-", sg))])
condition = length(distinct(var.ingress_security_group_ids)) == length(var.ingress_security_group_ids) && alltrue([for sg in var.ingress_security_group_ids : can(regex("^sg-", sg))])

Context Used: AGENTS.md (source)

Knowledge Base Used: Networking modules: VPC, load balancers, DNS, security groups, EIPs

Prompt To Fix With AI
This is a comment left during a code review.
Path: networking/alb/variables.tf
Line: 252

Comment:
**Duplicate source rules fail apply**

When `ingress_security_group_ids` contains the same ID more than once, each entry becomes a separately keyed but otherwise identical AWS ingress rule, causing the ALB apply to fail when AWS rejects the duplicate rule.

```suggestion
    condition     = length(distinct(var.ingress_security_group_ids)) == length(var.ingress_security_group_ids) && alltrue([for sg in var.ingress_security_group_ids : can(regex("^sg-", sg))])
```

**Context Used:** AGENTS.md ([source](https://github.com/flightcontrolhq/modules/blob/main/AGENTS.md))

**Knowledge Base Used:** [Networking modules: VPC, load balancers, DNS, security groups, EIPs](https://app.greptile.com/flightcontrol/-/custom-context/knowledge-base/flightcontrolhq/modules/-/docs/networking.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +6 to +7
version: 0.5.1
description: "Add private_alb_ingress_security_group_ids input (and public_alb_ingress_security_group_ids Terraform variable) to allow ALB ingress rules that reference source security groups, such as the CloudFront VPC origins security group."

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Feature uses patch version

Version 0.5.1 classifies the new optional catalog input as a patch even though the repository's semantic-versioning convention assigns new features and optional inputs a minor release, making feature availability unclear to consumers.

Suggested change
version: 0.5.1
description: "Add private_alb_ingress_security_group_ids input (and public_alb_ingress_security_group_ids Terraform variable) to allow ALB ingress rules that reference source security groups, such as the CloudFront VPC origins security group."
version: 0.6.0
description: "Add private_alb_ingress_security_group_ids input (and public_alb_ingress_security_group_ids Terraform variable) to allow ALB ingress rules that reference source security groups, such as the CloudFront VPC origins security group."

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: compute/ecs_cluster/rvn-ecs-cluster-definition.yml
Line: 6-7

Comment:
**Feature uses patch version**

Version `0.5.1` classifies the new optional catalog input as a patch even though the repository's semantic-versioning convention assigns new features and optional inputs a minor release, making feature availability unclear to consumers.

```suggestion
  version: 0.6.0
  description: "Add private_alb_ingress_security_group_ids input (and public_alb_ingress_security_group_ids Terraform variable) to allow ALB ingress rules that reference source security groups, such as the CloudFront VPC origins security group."
```

**Context Used:** AGENTS.md ([source](https://github.com/flightcontrolhq/modules/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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.

1 participant