Fall Cleaning #4: Open the Front Door (Route 53, ACM & NLB)

Goal & Abstract of Blog Post:

  • Goal:
    • Give phones a real HTTPS address, where each emailed link carries a signed expiring token for one chore, so the MVP is protected without a full login system.
    • This finishes Envoy Gateway (HTTPS and rate limiting), adds Route 53 + ACM, and the Load Balancer Controller + NLB.
StepRepo / PRFilesWhat and why
A: Find your DNS host——- nslookup -type=NS im-your-huckleberry.com shows where to add the NS records
B: Fall #3 carry-overgitops– Kyverno config
– Argo app
– Exclude argocd from Kyverno’s webhooks, and ignoreDifferences for the image digest.
– Do this before Fall #4 adds new controllers.
C: Long-lived DNS + certificateinfra · new bootstrap/dns/ (local state, like github-actions)- versions.tf
– main.tf
– outputs.tf
– Route 53 zone cleanup.im-your-huckleberry.com
– Plus an ACM cert for it and *.cleanup…, validated by DNS.
– It survives rebuilds, so the NS records and cert never change.
D: Delegate the subdomain (one time)your DNS host’s dashboard—– Add the 4 NS records Terraform outputs.
– The cert then validates by itself.
E: Cluster-side AWS piecesinfra · cluster workspace– vpc.tf (subnet elb tags)
– new lb-controller.tf,
– external-dns.tf
– IAM roles and Pod Identity for the Load Balancer Controller and ExternalDNS.
– The LB controller is installed by Terraform, because it needs the VPC ID, which changes every rebuild.
F: Signing keyinfra (same PR as 3)– app-secrets.tf– Add a link_signing_key alongside the admin token
– write-only as before
G: Signed, expiring chore linksappmain.py, tests– GET /c/{chore}?exp=&sig= verifies an HMAC signature and expiry.
– POST /admin/links (admin-token protected) mints a link.
– Tests for valid, expired and tampered links.
H: Open the front doorgitops– EnvoyProxy
– Gateway
– HTTPRoute
– new ExternalDNS app
– rate-limit policy
– ExternalSecret
– Deployment tag
– EnvoyProxy becomes an internet-facing NLB with the ACM cert.
– The hostname becomes the real one, HTTP redirects to HTTPS, /c/ is routed,
– Envoy rate-limits, and ExternalDNS owns the record.
I: Prove it (one session)——– DNS resolves
– Cert is valid
– HTTP redirects
– The signed link works while expired and tampered ones fail
– Rate limit returns 429
– Opens phone
J: Teardown, carefully——– Remove the NLB before terraform destroy.
– An orphaned NLB keeps costing money and blocks the VPC from being deleted.

Step A: Find your DNS host

========
nslookup -type=NS im-your-huckleberry.com
========

Step B: Previous blog post carry-over

PolicyModeChange
disallow-latest-tag, disallow-privilege-escalation, disallow-privilegedDenyAdd argocd and kyverno to their excluded namespaces. Keep Fail
disallow-host-namespaces, require-drop-all-capabilities, require-run-as-nonroot, require-labels, require-resource-limitsAuditAdd failurePolicy: Ignore. An Audit policy never blocks anything, so it shouldn’t block when Kyverno is down either
verify-say-when-imageDeny, say-when onlyNo change: it’s scoped to one namespace

Audit policies: don’t block when Kyverno is unreachable

gitops/apps/kyverno/policies

  • 4 files changed
    • apps/kyverno/policies/disallow-host-namespaces.yaml
    • apps/kyverno/policies/require-drop-all-capabilities.yaml
    • apps/kyverno/policies/require-labels.yaml
    • apps/kyverno/policies/require-resource-limits.yaml
    • apps/kyverno/policies/require-run-as-nonroot.yaml
spec:
failurePolicy: Ignore
  • 3 files changed
    • apps/kyverno/policies/disallow-latest-tag.yaml
    • apps/kyverno/policies/disallow-privilege-escalation.yaml
    • apps/kyverno/policies/disallow-privileged.yaml
========
spec:
values:
- argocd
- kyverno
========

Step C: Long-lived DNS + certificate

  • In a new bootstrap/dns/ stack. It follows the same pattern as bootstrap/github-actions:
    • Applied from laptop with local state
    • Survives every cluster rebuild.
  • That matters for two reasons:
    • The NS records at WordPress.com never change.
      • If the zone were recreated each session, Route 53 would assign new name servers every time.
    • The certificate stays valid, and ACM renews it automatically.

Long-lived DNS + TLS for the Say When app

ChoiceWhy
A delegated subdomain, not the whole domainThe blog, www and email stay at WordPress.com. Only cleanup.… is answered by Route 53.
force_destroy = falseThe zone’s name servers live in WordPress.com’s settings. Deleting the zone by accident would break the delegation.
Apex plus wildcard on one certcleanup.… for the app now, and *.cleanup.… for anything later (like Grafana) without a new certificate.
DNS validationACM renews automatically for as long as the validation CNAME exists, with no emails to click.
aws_acm_certificate_validationMakes terraform apply wait until the cert is actually issued, so its ARN is only output once it’s usable.
  • Apply in 2 passes:
    • The certificate can’t validate until WordPress.com points cleanup at Route 53, so the zone comes first:
========
terraform init
========
terraform fmt && terraform validate
========
terraform apply -target=aws_route53_zone.cleanup
========
  • -target applies just the zone. It expects 1 to add: type yes.
  • Terraform warns that -target is for exceptional cases. That’s expected, and this is one of them.
========
terraform output name_servers
========

infra/bootstrap/dns/variables.tf:

infra/bootstrap/dns/main.tf:

infra/bootstrap/dns/outsputstf:

Step D: Delegate the subdomain (one time) cleanup to Route 53 at WordPress.com.

  • Add X # of DNS Records under NS
========
nslookup -type=NS cleanup.im-your-huckleberry.com ns1.wordpress.com
========
nslookup -type=SOA cleanup.im-your-huckleberry.com 8.8.8.8
========
terraform apply
========
aws acm describe-certificate --region us-east-1 \
--certificate-arn "$(terraform output -raw certificate_arn)" \
--query 'Certificate.{status:Status,names:SubjectAlternativeNames}' --output json
========
cp terraform.tfstate ~/Documents/cluster-app/tfstate-backups/dns-$(date +%Y%m%d-%H%M).tfstate
========

Step E: Cluster-Side AWS Pieces – Load Balancer Controller & ExternalDNS

FileWhatWhy
vpc.tf (edit)Tag the public subnets kubernetes.io/role/elb = 1Tells the Load Balancer Controller where it may place an internet-facing NLB
policies/aws-load-balancer-controller-iam-policy.json (new)AWS’s official IAM policy for the controllerDownloaded from the exact release you install, so the permissions match
lb-controller.tf (new)IAM role, Pod Identity, and Helm install of the controllerInstalled by Terraform, not Argo, because its chart needs the VPC ID, which changes every rebuild. Terraform knows it, but Git doesn’t.
external-dns.tf (new)IAM role and Pod Identity for ExternalDNSIt may edit records only in your cleanup.… zone. The app itself goes in via GitOps in step 6.
app-secrets.tf (edit)Add a link_signing_keyThe key the app uses to sign chore links (step 5)

Why built this way

ChoiceWhy
The controller via Terraform helm_releaseIts chart needs vpcId, which changes every rebuild. Argo CD reads static Git, while Terraform has the live value. It’s the same reasoning as Argo CD’s own install.
The official IAM policy file, pinned to the installed releaseThat policy is long and changes between releases. Copying it for the exact version avoids “AccessDenied on some new API” surprises.
ExternalDNS may change one zoneIt can’t touch any other DNS in your account. The two discovery calls can’t be scoped, and grant no write access.
data "aws_route53_zone"The zone belongs to bootstrap/dns. This workspace only looks it up, the same pattern as the ECR repo in Fall #3.
replicaCount = 1Lab-sized. The chart’s default is 2.

infra/vpc.tf

  • Tells the Load Balancer Controller where it may place an internet-facing NLB
========
public_subnet_tags = {
# Karpenter EC2NodeClass discovers both east subnets.
"karpenter.sh/discovery" = local.eks_east_name
# AWS Load Balancer Controller may place internet-facing
# load balancers (the Fall #4 NLB) in these subnets.
"kubernetes.io/role/elb" = "1"
}
========

infra/policies/aws-load-balancer-controller-iam-policy.json

  • Pick the controller version and fetch its IAM policy
    • The same method as the Argo CD upgrade: look the version up, don’t guess it.
    • This time no placeholders cuz the version goes straight into variables.
  • This is how AWS’s own install guide does it:
    • Downloads the controller’s IAM policy pinned to a release tag
      • curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.14.1/docs/install/iam_policy.json.
  • The version Helm reports is utilized instead of a hardcoded one. The controller has also supported this setup for a while: its release notes list support for EKS pod identities.

infra/lb-controller.tf

infra/external-dns.tf

Step F: Signed key

infra/app-secrets.tf

========
# Signs chore links (HMAC-SHA256). 64 letters and digits.
ephemeral "random_password" "say_when_link_signing_key" {
length = 64
special = false
}
========
{
secret_string_wo = jsonencode({
admin_token = ephemeral.random_password.say_when_admin_token.result
link_signing_key = ephemeral.random_password.say_when_link_signing_key.result
})
secret_string_wo_version = 2
}
========

Step G: Signed, expiring chore links. & .py stuff

ChoiceWhy
HMAC over chore_id.expBoth are inside the signature. Change the chore or extend the expiry, and the link breaks.
Signature checked before expiryA forged link always gets 403 and learns nothing. Only a genuine old link gets the friendlier 410 Gone.
compare_digest againThe same constant-time comparison as the admin token.
Minting is admin-only and internal/admin/links isn’t on the public route. Only you, via port-forward (and in Fall #9 the notifier), can create links.
TTL default 1 day, max 7Short-lived links limit the damage if an email gets forwarded.
Key read per requestRotate it in Secrets Manager and all old links stop working, with no restart. That’s a built-in “revoke everything”.
========
pytest -q
app/test_main.py::test_healthz
app/test_main.py::test_chores_file_has_ten_valid_chores
app/test_main.py::test_get_one_chore
app/test_main.py::test_unknown_chore_is_404
app/test_main.py::test_metrics_counts_requests
app/test_main.py::test_admin_not_configured_is_503
app/test_main.py::test_admin_wrong_or_missing_token_is_401
app/test_main.py::test_admin_right_token_is_200
app/test_main.py::test_admin_token_rotation_needs_no_restart
tests/test_main.py::test_healthz
tests/test_main.py::test_chores_file_has_ten_valid_chores
tests/test_main.py::test_get_one_chore
tests/test_main.py::test_unknown_chore_is_404
tests/test_main.py::test_metrics_counts_requests
14 passed, 1 warning
========
========
aws ecr describe-images --repository-name say-when-app \
--image-ids imageTag=d1d2 \
--query 'imageDetails[0].imagePushedAt' --output text
2026-12-02T14:55:39.449000-06:00
========

Step H: Open the front door – Gitops

  • EnvoyProxy becomes an internet-facing NLB with the ACM cert.
  • The hostname becomes the real one, HTTP redirects to HTTPS, /c/ is routed,
  • Envoy rate-limits, and ExternalDNS owns the record.
ChoiceWhy
TLS at the NLB (ACM cert)Free and auto-renewing. AWS handles the certificate, and nothing secret is stored in the cluster.
loadBalancerClass: service.k8s.aws/nlb + nlb-target-type: ipThe LB controller, not the old in-tree code, builds the NLB, and it sends traffic straight to the Envoy pods’ IPs, skipping an extra hop through the nodes.
ssl-negotiation-policy: …TLS13-1-2…Modern TLS only: TLS 1.3 and 1.2, no legacy ciphers.
https listener = HTTP protocol on 443TLS already ended at the NLB, so Envoy sees plain HTTP on that port.
The http listener only accepts routes from its own namespaceThe app can’t serve unencrypted traffic, even by mistake. Only the platform’s redirect can attach there.
301 redirectPermanent, so browsers remember to use https next time.
Rate limit on the Gateway, Local, 60/minIt protects everything behind the front door, with no Redis. The tradeoff: with TLS ending at the NLB, Envoy can’t see the real client IP, so it’s one shared budget, not per visitor. That’s fine for a family app, and it’s noted for the post.

Get the Cert ARN from bootstrap/dns:

========
cd ~/infra/bootstrap/dns
CERT_ARN=$(terraform output -raw certificate_arn)
echo "$CERT_ARN"
========

Gitops – Gateway Side

apps/envoy-gateway-config/say-when-gateway.yaml

PieceWhat it does
EnvoyProxy → LoadBalancer + NLB annotations– The Load Balancer Controller builds an internet-facing NLB.
– Port 443 uses TLS with your ACM cert
– Envoy receives plain HTTP inside the VPC
Gateway → two listeners on the real hostname– https (443): the app attaches here.
– http (80): reserved for the redirect only
Redirect HTTPRoute (new)– Anything on http:// gets 301 → https://
BackendTrafficPolicy (new)– Envoy rate-limits the whole front door.
– A flood gets 429 Too Many Requests before it ever reaches the app

Gitops – ExternalDNS Side

apps/external-dns/values.yaml

applications/platform/external-dns.yaml

applications/projects/lab-projects.yaml

========
spec:
sourceRepos:
- https://kubernetes-sigs.github.io/external-dns/
========
destinations:
- namespace: external-dns
server: https://kubernetes.default.svc
========
namespaceResourceWhitelist:
# EnvoyProxy is an Envoy Gateway configuration resource.
- group: gateway.envoyproxy.io
kind: EnvoyProxy
# BackendTrafficPolicy is an Envoy Gateway configuration resource.
- group: gateway.envoyproxy.io
kind: BackendTrafficPolicy
========

Gitops – App HTTP Side

apps/say-when-app/httproute.yaml

========
spec:
parentRefs:
sectionName: https
hostnames:
- cleanup.im-your-huckleberry.com
========
rules:
- matches:
- path:
type: PathPrefix
value: /c/
========

apps/say-when-app/externalsecret.yaml

 ========
 data:
    - secretKey: link_signing_key
      remoteRef:
        key: say-when/app/settings
        property: link_signing_key
========


apps/say-when-app/deployment.yaml

========
image: 026090519635.dkr.ecr.us-east-1.amazonaws.com/say-when-app:d1d27fd19e95bf4fc67d04206868dd72e2d59517
========
- name: LINK_KEY_FILE
value: /etc/say-when/secrets/link_signing_key
========
items:
- key: admin_token
path: admin_token
- key: link_signing_key
path: link_signing_key
========
yamllint -c .yamllint.yaml apps applications && echo "LINT OK"
LINT OK
========
git status --short
M applications/lab/projects/lab-platform.yaml
M apps/envoy-gateway-config/say-when-gateway.yaml
M apps/say-when-app/deployment.yaml
M apps/say-when-app/externalsecret.yaml
M apps/say-when-app/httproute.yaml
?? applications/lab/platform/external-dns.yaml
?? apps/external-dns/
========

Step I: Spin up Cluster

  • DNS resolves
  • Cert is valid
  • HTTP redirects
  • The signed link works while expired and tampered ones fail
  • Rate limit returns 429
  • Opens phone

Part 1: HCP $tuff

  • About 25 minutes
    • helm_release.aws_load_balancer_controller
    • aws_eks_pod_identity_association.lbc and .external_dns
    • the kubernetes.io/role/elb subnet tags
    • the secret version 2
  • Confirm promptly. If the plan fails with the 401 or expired-token error, re-run it once. That’s the known cold-start issue.
========
aws eks update-kubeconfig --name say-when-east --region us-east-1
========
kubectl get nodes -L eks.amazonaws.com/capacityType
========

Part 2: Argo is Green as $$$

  • About 10 minutes
  • In CLI or K9s:
    • Wait for everything to be Synced/Healthy, including the new external-dns, then press Ctrl+C. Then check last week’s Kyverno fix is live:
========
kubectl -n argocd get applications -w
========
kubectl get validatingpolicy require-labels -o jsonpath='{.spec.failurePolicy}{"\n"}'
========
kubectl get validatingpolicy disallow-privileged -o jsonpath='{.spec.matchConstraints.namespaceSelector.matchExpressions[0].values}{"\n"}'
========

Part 3: NLB Appears to be ALIVE!!

  • About 5 minutes
  • In CLI or K9s
========
kubectl -n kube-system get deploy aws-load-balancer-controller
========
kubectl -n envoy-gateway-system get svc -l gateway.envoyproxy.io/owning-gateway-name=say-when -w
========
  • Wait until EXTERNAL-IP shows a hostname like k8s-envoyga-…elb.us-east-1.amazonaws.com, which usually takes 1–3 minutes. Then press Ctrl+C.
  • Expect an internet-facing network load balancer, active, with listeners 443 TLS (your cert ARN) and 80 TCP.
========
aws elbv2 describe-load-balancers --region us-east-1 \
--query 'LoadBalancers[].{name:LoadBalancerName,scheme:Scheme,state:State.Code,type:Type}' --output table
LB_ARN=$(aws elbv2 describe-load-balancers --region us-east-1 --query 'LoadBalancers[0].LoadBalancerArn' --output text)
------------------------------------------------------------------------------
| DescribeLoadBalancers |
+-----------------------------------+-------------------+---------+----------+
| name | scheme | state | type |
+-----------------------------------+-------------------+---------+----------+
| k8s-envoygat-envoyenv-1 | internet-facing | active | network |
+-----------------------------------+-------------------+---------+----------+
========
aws elbv2 describe-listeners --region us-east-1 --load-balancer-arn "$LB_ARN" \
--query 'Listeners[].{port:Port,protocol:Protocol,cert:Certificates[0].CertificateArn}' --output table
========
========
aws elbv2 describe-listeners --region us-east-1 --load-balancer-arn "$LB_ARN" \
--query 'Listeners[].{port:Port,protocol:Protocol,cert:Certificates[0].CertificateArn}' --output table
-------------------------------------------------------------------------------------------------------------
| DescribeListeners |
+---------------------------------------------------------------------------------------+-------+-----------+
| cert | port | protocol |
+---------------------------------------------------------------------------------------+-------+-----------+
| arn:aws:acm:us-east-1:026 | 443 | TLS |
| None | 80 | TCP |
========

Part 4: DNS

  • About 5 – 10 minutes
  • In CLI or K9s
========
kubectl -n external-dns logs deploy/external-dns --since=10m | grep -iE "desired change|CREATE|UPSERT|error" | tail -10
ZONE=$(aws route53 list-hosted-zones-by-name --dns-name cleanup.im-your-huckleberry.com --query 'HostedZones[0].Id' --output text)
========
aws route53 list-resource-record-sets --hosted-zone-id "$ZONE" \
--query 'ResourceRecordSets[].{name:Name,type:Type}' --output table
========
---------------------------------------------------------------------------------
| ListResourceRecordSets |
+----------------------------------------------------------------------+--------+
| name | type |
+----------------------------------------------------------------------+--------+
| cleanup.im-your-huckleberry.com. | A |
| cleanup.im-your-huckleberry.com. | AAAA |
| cleanup.im-your-huckleberry.com. | NS |
| cleanup.im-your-huckleberry.com. | SOA |
| _e68596c15f8e1f4b0ed1c5bb6a327cdf.cleanup.im-your-huckleberry.com. | CNAME |
| edns-a.cleanup.im-your-huckleberry.com. | TXT |
| edns-aaaa.cleanup.im-your-huckleberry.com. | TXT |
+----------------------------------------------------------------------+--------+
  • Expect an A record for cleanup.im-your-huckleberry.com. (an alias to the NLB), the edns-… TXT ownership markers, and the ACM validation CNAME, untouched. Only now check public DNS:
  • Both should return the NLB’s IP addresses.
========
nslookup cleanup.im-your-huckleberry.com ns-32.awsdns-04.com
========
nslookup cleanup.im-your-huckleberry.com 8.8.8.8
========

Part 5: HTTPS end to end

  • About 5 minutes
  • In CLI or K9s
    • Expect:
      • the cert’s subject: CN=cleanup.im-your-huckleberry.com, issued by Amazon
      • TLS 1.3
      • {"version":"d1d27fd…"}
      • 301, with location: https://…
      • 404 for both /metrics and /admin/status, since they’re internal only
========
curl -sv https://cleanup.im-your-huckleberry.com/version 2>&1 | grep -E "subject:|issuer:|SSL connection|HTTP/2|HTTP/1.1 [0-9]|version"
========
curl -sI http://cleanup.im-your-huckleberry.com/version | grep -iE "^HTTP|^location"
========
curl -s -o /dev/null -w '/metrics → %{http_code}\n' https://cleanup.im-your-huckleberry.com/metrics
========
curl -s -o /dev/null -w '/admin/status → %{http_code}\n' https://cleanup.im-your-huckleberry.com/admin/status
========

Part 6: Signed Links

  • About 10 minutes
  • In CLI or K9s
  • The headline moment.
    • Mint a link internally, then open it from your phone

Open private door to app

========
kubectl -n say-when port-forward svc/say-when-app 8081:8080 >/dev/null 2>&1 &
sleep 3
curl -s localhost:8081/healthz; echo
========

Get Admin Toke

========
TOKEN=$(aws secretsmanager get-secret-value --secret-id say-when/app/settings \
--query SecretString --output text | python3 -c 'import json,sys; print(json.load(sys.stdin)["admin_token"])')
echo "token length: ${#TOKEN}" # → 48
========

Mint it up – Link for 1 Chore

  • What that request does:
    • -X POST means “create something”.
    • X-Admin-Token proves you’re the admin.
    • -d '{…}' asks for a link to the rake-leaves chore, valid for 60 minutes.
========
curl -s -X POST localhost:8081/admin/links \
-H "X-Admin-Token: $TOKEN" \
-H 'Content-Type: application/json' \
-d '{"chore_id":"rake-leaves","ttl_minutes":60}'
echo
========

Saved URL into a Variable

========
LINK=$(curl -s -X POST localhost:8081/admin/links -H "X-Admin-Token: $TOKEN" \
-H 'Content-Type: application/json' -d '{"chore_id":"rake-leaves","ttl_minutes":60}' \
| python3 -c 'import json,sys; print(json.load(sys.stdin)["url"])')
echo "$LINK"
========

Open the REALLLL Front Door

  • That goes out over the internet, through DNS → NLB (HTTPS) → Envoy → app, and should return the rake-leaves chore plus expires_at.
  • You can also paste $LINK straight into your browser.
========
curl -s "$LINK"; echo
========
{"chore":{"id":"rake-leaves","name":"Rake leaves","expect":["Rake","Leaf"],"reject":["Basketball","Sports Ball"],"min_confidence":80},"expires_at":1796422771}

BREAK IT / TAMPER IT / DO SOMETHIN DAWWG

  • Both should give 403.
    • ${LINK/rake-leaves/last-mow} swaps the chore name in the link. The signature was made for rake-leaves, so it no longer matches.
    • ${LINK%%&sig=*}&sig=deadbeef replaces the signature with a fake one.
========
curl -s -o /dev/null -w 'other chore → %{http_code}\n' "${LINK/rake-leaves/last-mow}"
========
curl -s -o /dev/null -w 'no signature → %{http_code}\n' "${LINK%%&sig=*}&sig=deadbeef"
========
other chore → 403
no signature → 403

Open on Phone aka the $ Shot Homie G

  • Paste it into a text or email to yourself. On your phone, turn Wi-Fi off so it uses mobile data, then tap the link. You should see the rake-leaves chore, with the padlock.
========
echo -n "$LINK"
========
https://cleanup.im-your-huckleberry.com/c/rake-leaves?exp=1796422771&sig=0bf6bd1ec81ab24a47207ad8ab78b40629be22fb9d80fd2e095201d3c63e0cd9
  • The link went out over the internet, through:
    • Route 53 → NLB (HTTPS with your ACM cert) → Envoy → the app.
  • The app checked the signature and expiry and returned the rake-leaves chore.
  • Reading it piece by piece:
    • /c/rake-leaves: the chore this link is for
    • exp=1796422771: the expiry in Unix seconds, about an hour after you minted it
    • sig=0bf6…cd9: the HMAC-SHA256 signature over rake-leaves.1796422771, made with your secret key
    • The response contains the chore plus expires_at, and never the key

Part 7: Rate Limit

  • About 2 minutes
  • Expect roughly 60 × 200, then 429 for the rest. The limit covers the whole front door, so wait a minute before testing anything else.
========
for i in $(seq 1 75); do curl -s -o /dev/null -w '%{http_code}\n' https://cleanup.im-your-huckleberry.com/healthz; done | sort | uniq -c
========
71 200
4 429
  • The rate limit works: 4 requests got 429 Too Many Requests, refused by Envoy at the front door before they reached the app.
  • Why 71 and not about 60: Envoy’s local limiter is a token bucket. It holds 60 tokens and refills them all every minute on its own clock, not when your loop starts. Your loop probably straddled a refill:

Step J: Teardown, carefully

Teardown: ⚠️ the order matters

  • The trap:
    • Terraform installed the LB controller, so terraform destroy would remove it before it could delete the NLB.
    • The NLB would then be orphaned, keep billing, and block the VPC from being deleted.
    • And if you just delete the Gateway, Argo would recreate it within seconds.
  • So: pause Argo, remove the front door, confirm the NLB is gone, then destroy.
========
kill $(jobs -p) 2>/dev/null; unset TOKEN LINK SHORT
========
# 1. Pause ALL Argo CD syncing (no self-heal while we take things apart)
kubectl -n argocd scale statefulset argocd-application-controller --replicas=0
========
# 2. Remove the Gateway: Envoy deletes its Service, then the LB controller deletes the NLB
kubectl -n envoy-gateway-system delete gateway say-when
========
# 3. Wait until the NLB is gone (about 1-3 min)
watch -n 15 "aws elbv2 describe-load-balancers --region us-east-1 --query 'length(LoadBalancers)' --output text"
========
  • Wait until it prints 0, then press Ctrl+C. ExternalDNS should also remove its record:
    • Only NS, SOA and the ACM CNAME should remain. If the A record lingers, it’s harmless: next session overwrites it.
========
aws route53 list-resource-record-sets --hosted-zone-id "$ZONE" --query 'ResourceRecordSets[].{name:Name,type:Type}' --output table
========
---------------------------------------------------------------------------------
| ListResourceRecordSets |
+----------------------------------------------------------------------+--------+
| name | type |
+----------------------------------------------------------------------+--------+
| cleanup.im-your-huckleberry.com. | NS |
| cleanup.im-your-huckleberry.com. | SOA |
| _e68596c15f8e1f4b0ed1c5bb6a327cdf.cleanup.im-your-huckleberry.com. | CNAME |

Destroy HCP

  • Now destroy: HCP → queue destroy plan → Confirm.
  • Remove the NLB before terraform destroy.
  • An orphaned NLB keeps costing money and blocks the VPC from being deleted.

Afterwards…

========
aws elbv2 describe-load-balancers --region us-east-1 --query 'length(LoadBalancers)' --output text # → 0
========
aws ec2 describe-volumes --region us-east-1 --filters Name=status,Values=available \
Name=tag:kubernetes.io/created-for/pvc/namespace,Values=monitoring --query 'Volumes[].VolumeId' --output text
========

Leave a Reply