Skip to content

feat(ec2): add tags option to Ec2RunnerProvider - #961

Merged
mergify[bot] merged 4 commits into
CloudSnorkel:mainfrom
GilUpstream:feat/ec2-instance-tags
Jul 28, 2026
Merged

feat(ec2): add tags option to Ec2RunnerProvider#961
mergify[bot] merged 4 commits into
CloudSnorkel:mainfrom
GilUpstream:feat/ec2-instance-tags

Conversation

@GilUpstream

@GilUpstream GilUpstream commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an tags prop to Ec2RunnerProvider that merges extra tags into the existing RunInstances TagSpecifications (instance + volume).

Why launch-time tags (not job hooks): security monitoring that enrolls hosts by tag needs the tag present from the moment the instance exists. Tagging from ACTIONS_RUNNER_HOOK_JOB_STARTED (the workaround from #524) runs only after the job starts, which is too late for short-lived ephemeral runners — the instance may terminate before the agent is installed. cdk.Tags.of() also does not help, because these instances are created dynamically by Step Functions, not as CloudFormation resources.

This builds on the tags already applied in #909 (Name, GitHubRunners:*) and makes the same mechanism extensible.

API

new Ec2RunnerProvider(this, 'EC2', {
  labels: ['ec2'],
  tags: {
    SecurityMonitoring: 'enabled',
  },
});

Testing

  • Unit tests cover TagSpecifications merge for instance + volume, and reserved-key rejection
  • pnpm exec jest test/providers.test.ts passes
  • API.md regenerated via pnpm docgen

Related: #524 (custom EC2 tags at launch time).

Made with Cursor

Allow static tags to be merged into RunInstances TagSpecifications so
they exist from instance launch. Needed when security monitoring must
enroll a host by tag before the runner job starts; job-started hooks are
too late for short-lived ephemeral runners.

Reserved Name and GitHubRunners:* keys remain owned by the provider.

Co-authored-by: Cursor <cursoragent@cursor.com>
@GilUpstream

Copy link
Copy Markdown
Contributor Author

@kichik Thoughts on this approach for extending tags? This seemed like a better option rather than the fragile nature of the user data approach.

@kichik

kichik commented Jul 24, 2026

Copy link
Copy Markdown
Member

I've been resisting this for a long time. But I can't deny it's useful. Let me clean it up a tiny bit and merge.

kichik added 2 commits July 27, 2026 21:16
instanceTags -> tags
allow overriding
DRY tests
keep readme shorter
@kichik

kichik commented Jul 28, 2026

Copy link
Copy Markdown
Member

Thanks.

FYI @pharindoko @emmanuelnk

@kichik kichik changed the title feat(ec2): add instanceTags to Ec2RunnerProvider feat(ec2): add tags option to Ec2RunnerProvider Jul 28, 2026
@mergify mergify Bot added the queued label Jul 28, 2026
@mergify

mergify Bot commented Jul 28, 2026

Copy link
Copy Markdown

Merge Queue Status

  • Entered queue2026-07-28 01:58 UTC · Rule: default · triggered by rule Automatic merge on approval and successful build
  • Checks skipped · PR is already up-to-date
  • Merged2026-07-28 01:59 UTC · at d895953ec8a237dd9c2eacdfa4024f592992aacd · squash

This pull request spent 31 seconds in the queue, including 7 seconds running CI.

Required conditions to merge

@mergify
mergify Bot merged commit dbb63c8 into CloudSnorkel:main Jul 28, 2026
15 of 16 checks passed
@mergify mergify Bot removed the queued label Jul 28, 2026
@GilUpstream
GilUpstream deleted the feat/ec2-instance-tags branch July 30, 2026 02:29
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