Skip to content

fix: resolve EC2 instance ID by tag instead of static secret#4

Merged
gf5901 merged 1 commit into
mainfrom
fix/dynamic-ec2-instance-lookup
Mar 21, 2026
Merged

fix: resolve EC2 instance ID by tag instead of static secret#4
gf5901 merged 1 commit into
mainfrom
fix/dynamic-ec2-instance-lookup

Conversation

@gf5901
Copy link
Copy Markdown
Owner

@gf5901 gf5901 commented Mar 21, 2026

Summary

  • Replace static Ec2InstanceId SST secret with runtime ec2:DescribeInstances lookup filtered by Role=task-forge-runner tag
  • Result is cached per Lambda cold start (one API call max), falls back to EC2_INSTANCE_ID env var if set
  • Updated all 4 Lambda packages (API, Autopilot, Metrics, RepoScanner) and removed the secret from sst.config.ts

Motivation

Spot instance replacements change the instance ID, causing all SSM SendCommand calls to fail with InvalidInstanceId. This required manually updating the SST secret and redeploying. With tag-based lookup, new instances are discovered automatically as long as they carry the Role=task-forge-runner tag.

Test plan

  • All 4 Lambda packages build with esbuild
  • API typecheck, lint, and tests pass
  • Deployed to production via sst deploy
  • Verified API health check returns OK
  • Manually invoked Autopilot Lambda — successfully resolved instance by tag and triggered SSM command

Made with Cursor

Spot instance replacements change the instance ID, breaking all SSM
commands with InvalidInstanceId errors. Replace the static
Ec2InstanceId SST secret with a runtime ec2:DescribeInstances lookup
filtered by the Role=task-forge-runner tag. Result is cached per
Lambda cold start. Falls back to EC2_INSTANCE_ID env var if set.

Made-with: Cursor
@gf5901 gf5901 merged commit 7cab9ea into main Mar 21, 2026
4 checks passed
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