Skip to content

Support ConnectPublic on internal Terraform stacks - #138

Merged
drernie merged 4 commits into
mainfrom
connect-public-terraform-subnets
Dec 6, 2026
Merged

drernie merged 4 commits into
mainfrom
connect-public-terraform-subnets

Conversation

@drernie

@drernie drernie commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Description

The need

Operators of internal (private) Quilt stacks on the Terraform path cannot use the opt-in ConnectPublic CloudFormation parameter shipped in deployment#3319: the module nulls PublicSubnets on every internal stack and the VPC module rejects caller-supplied public subnets there. This is the iac work unit of quilt-specs#214, narrowed after quilt-specs#350.

What changed

  • parameters.ConnectPublic = "Enabled" on an internal stack now supplies PublicSubnets to the template: the module-created public subnets, or, with an existing VPC, two distinct non-empty caller-supplied public subnet IDs (the VPC module rejects anything else). There is no new quilt module input; the existing parameter is the only source of truth.
  • Internal stacks without ConnectPublic Enabled keep PublicSubnets null; UserSubnets, the main ALB's scheme and public stacks are unchanged.
  • A plan-time precondition requires a non-empty ConnectSecurityGroup when ConnectPublic is Enabled and ConnectAllowedHosts is non-empty. Absent keys are handled and unknown values defer to apply. It is a subset of the template rule in deployment#3723, which stays the authority; the module does not inspect route tables, subnet suitability or security group rules.
  • README, VARIABLES.md and the variable descriptions state the prerequisites; CHANGELOG has an entry for the subnet wiring and one for the plan-time check.

Verification

  • terraform fmt -check -recursive, then terraform test in modules/vpc (17 passed) and modules/quilt/tests/smoke (12 passed), run locally on Terraform 1.14.2 at head a881ab69; the CI jobs of the same names (fmt, markdownlint, validate, both test suites) passed at that head.
  • The vpc tests cover existing-VPC opt-in, missing and duplicate subnet IDs, subnet IDs without opt-in, and the module-created VPC. The smoke tests assert the actual CloudFormation PublicSubnets/UserSubnets parameters for existing-VPC opt-in, disabled, default and public stacks; a mocked apply compares the generated VPC output with the stack parameter on the module-created path; a plan test rejects a missing ingress group (it fails if the precondition is disabled).
  • No live AWS plan or apply has been run.

Links

Risk and rollback

No automatic public enablement and no new ingress resources: ConnectPublic stays opt-in and the main ALB stays internal. CloudFormation validates template eligibility. To disable, set ConnectPublic = "Disabled" and remove the existing-VPC public subnet input, using the documented Connect ALB replacement procedure where a running Connect ALB needs it. Do not enable on a customer stack without the required security review and both deployment#3723 and deployment#3269 shipped; the precondition does not inspect customer ingress rules.

The optionality note

Opens the Terraform path to public Connect on internal stacks, which was closed before. It keeps ConnectPublic as the single switch, so it forecloses no future ingress design (for example a dedicated Connect WAF ACL).

TODO

  • CHANGELOG entry
  • I promise to deploy to dev stacks (including nightly) soon after PR is merged so we really have these changes tested

🤖 Generated with Claude Code

https://claude.ai/code/session_01KCtustfJTmiNGXAwTmXwka

@greptile-apps

greptile-apps Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge; the latest change only adds the missing changelog entry.

Reviews (3) · Last reviewed commit: "Note the ConnectSecurityGroup plan-time ..." · Reviewed by Greptile

@shannon-ernie-s-grok shannon-ernie-s-grok Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review at head f3c17c99, against quilt-specs#214 (the iac unit) and Sergey's Dec 4 comment. I read the diff and compared it with deployment main's template:

  • ConnectPublic (Enabled/Disabled) is offered only on internal, network 2.0, non-WAF stacks.
  • PublicSubnets is an optional CommaDelimitedList.
  • The ConnectPublicNeedsPublicSubnets rule applies to the existing-VPC variant.

Does it implement what #214 specifies? Yes. In the iac unit's own terms:

  • It derives the opt-in from parameters.ConnectPublic, so there is no second source of truth.
  • It passes module-created public subnets, or requires two distinct non-empty caller-supplied IDs on an existing VPC.
  • It keeps the null rule when Connect is not public.
  • It leaves UserSubnets and the main ALB untouched.
  • It does not widen the closed substrate key set.

CI is green: fmt, markdownlint, validate, and the mocked vpc and smoke tests. There is no review yet, and REVIEW_REQUIRED blocks the merge. No threads are open.

Findings

  • P2: public Connect can be enabled on the Terraform path with no ingress guard.
  • P3: the quilt smoke test for the module-created VPC path asserts only the stack name.
  • P3: the PR body says fmt, validate and tests are "pending CI" and leaves the CI TODO unchecked, but all checks have passed. Please update it.

No P1.

Spec follow-ups once this merges. deploy#tf-apply and deploy#network still say the Terraform path cannot supply PublicSubnets. The verify unit in #214 correctly covers reconciling them after a real plan and apply.

(Posted by Shannon on behalf of Ernest.)

Comment thread modules/quilt/main.tf Resolved
@drernie

drernie commented Dec 5, 2026

Copy link
Copy Markdown
Member Author

@greptileai re-review at head a881ab6, please — PR body restructured to the kind sections; code unchanged since the last round except the new precondition, mocked-apply test and docs.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Public ingress on private stacks depends on external deployment safeguards and live ALB replacement procedures that are outside this snapshot and cannot be validated by mocked AWS tests.

No open issues 🎉

What changed in this PR

Enables opt-in public Connect on internal Terraform stacks while keeping the main load balancer private.

Changes:

  • Passes public subnets when ConnectPublic is enabled and validates existing-VPC subnet inputs.
  • Requires a Connect security group when public Connect has allowed hosts.
  • Adds validation and smoke tests, plus prerequisite and rollback documentation.
File Description
VARIABLES.md Documents Connect parameters and subnet requirements.
README.md Explains enablement, prerequisites, and rollback.
modules/​vpc/​variables.tf Adds the internal connect_public input.
modules/​vpc/​tests/​validation.tftest.hcl Tests subnet validation and opt-in behavior.
modules/​vpc/​main.tf Allows and validates public Connect subnets.
modules/​quilt/​variables.tf Clarifies public subnet requirements.
modules/​quilt/​tests/​smoke/​smoke.tftest.hcl Tests subnet wiring and security-group enforcement.
modules/​quilt/​tests/​smoke/​main.tf Exposes inputs and outputs for smoke tests.
modules/​quilt/​main.tf Wires Connect opt-in and adds the security-group precondition.
CHANGELOG.md Records public Connect support.

Review effort: Balanced

@shannon-ernie-s-grok shannon-ernie-s-grok Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving at head a881ab6.

Checked against quilt-specs#214 (56cf09cf, iac):

  • PublicSubnets is passed only when the stack is public, or when the stack is internal and ConnectPublic is Enabled in the existing parameter map. There is no second knob. The module's output overrides any caller-supplied PublicSubnets. Private and Disabled paths still pass null, and the main ALB keeps its user/private subnets.
  • The VPC module takes connect_public, derived by the quilt module. For an existing VPC it requires two distinct non-empty public subnet IDs when public Connect is on, and requires null otherwise (the old behavior). The module-created VPC always has public subnets, so it uses its own outputs.
  • The optional plan-time precondition fires when ConnectPublic is Enabled, ConnectAllowedHosts is non-empty and ConnectSecurityGroup is empty or absent. It defers unknown values to apply. The docs state that the deployment template rule (#3723) is the authority.
  • The tests cover private opt-in, opt-out and Disabled, public stacks, both VPC paths and missing or duplicate subnets. The negative precondition test expects the stack failure. A mocked apply asserts that the actual CFN PublicSubnets parameter equals the generated VPC public subnet output, which is the verify requirement, and that user subnets stay private.
  • All CI checks are green on a881ab6 (fmt, markdownlint, validate ×5, test ×2). The two review threads are resolved. The CHANGELOG Unreleased entry is rendered. README and VARIABLES.md match the behavior.

Non-blocking:

  • The CHANGELOG entry doesn't mention the new ConnectSecurityGroup plan-time check. Consider adding it, but there is no need to push for it.
  • I couldn't run Terraform on my box, so I'm relying on the green test jobs. The live apply and the CFN-side rule check remain in the spec's verify unit.

The precondition is operator-visible (plan fails), so it gets its own
entry alongside the public-subnet wiring.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KCtustfJTmiNGXAwTmXwka
@drernie

drernie commented Dec 6, 2026

Copy link
Copy Markdown
Member Author

@greptileai re-review at head e4e71a0, please — adds a CHANGELOG entry for the ConnectSecurityGroup plan-time check; no code change since a881ab6.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human review must confirm external eligibility/security rules, rollout prerequisites, and live AWS ALB replacement/rollback behavior for private-stack public ingress, which mocked tests do not validate.

No open issues 🎉

Review effort: Balanced

@drernie
drernie merged commit 03a0a1c into main Dec 6, 2026
12 checks passed
@drernie
drernie deleted the connect-public-terraform-subnets branch December 6, 2026 15:41
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