Skip to content

Fix sst remove failing on in-use ACM certificate by ordering load Balancer deletion first. - #6938

Open
MalekD5 wants to merge 1 commit into
anomalyco:devfrom
MalekD5:fix/lb-cert-removal-order
Open

Fix sst remove failing on in-use ACM certificate by ordering load Balancer deletion first.#6938
MalekD5 wants to merge 1 commit into
anomalyco:devfrom
MalekD5:fix/lb-cert-removal-order

Conversation

@MalekD5

@MalekD5 MalekD5 commented Jul 13, 2026

Copy link
Copy Markdown

closes #6934

Problem Summary

The load balancer's Elastic Network Interface (ENI) release sometimes delays, and when the ACM certificate delete fires while the ENIs still reference the certificate, you get ResourceInUseException and the removal aborts before it ever reaches the load balancer.

This issue is not deterministic by nature, and most of the time we are at the mercy of AWS-side timings so it not as obvious.

Fix

The way this PR fixes the problem is by explicitly making the ALB depend on the ACM Certificate. Here is the base config I used for testing:

/// <reference path="./.sst/platform/config.d.ts" />

export default $config({
  app(input) {
    return { name: "test-lb-cert", home: "aws", removal: "remove" };
  },
  async run() {
    const vpc = new sst.aws.Vpc("Vpc");
    new sst.aws.Alb("Alb", {
      vpc,
      domain: "lb.sst-test.malekd5.com", // AWS hosted zone
      listeners: [{ port: 443, protocol: "https" }],
    });
  },
});

Here is the before and after sst state export after running deploy:

Before
Before Fix Image

As you can notice, no ACM URNs in dependencies, which means your run's success is timing luck.

After
image

As you can notice, ACM URNS in dependency array ordered, which means LB delete must fully complete before ACM delete starts every run. And we are no longer under the mercy of AWS-side timing.

@omercnet omercnet 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.

Verified the fix across Alb, Service, and Service v1. The explicit load-balancer dependency expands through DnsValidatedCertificate to the ACM certificate and validation resources, so Pulumi's reverse destroy order removes the listener and load balancer before deleting the certificate. Both the direct component dependency used by Alb and the Output-wrapped component dependency used by Service were exercised with Pulumi mock-monitor graph probes. Platform typecheck and build pass. The existing focused Vitest files could not collect because platform/src/global.d.ts imports @types/node as a runtime package; that failure is pre-existing and unrelated to this diff.

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.

sst remove fails deleting the ACM certificate for ALB/Service (missing dependency edge)

2 participants