Skip to content

feat: Add workflow URL to EC2 instance tags - #4658

Closed
roberto-civitas wants to merge 1 commit into
github-aws-runners:mainfrom
civitaslearning:add-build-url-to-instance-tags
Closed

feat: Add workflow URL to EC2 instance tags#4658
roberto-civitas wants to merge 1 commit into
github-aws-runners:mainfrom
civitaslearning:add-build-url-to-instance-tags

Conversation

@roberto-civitas

Copy link
Copy Markdown

Add the workflow_url to the instance tags so that it's easier to identify which build is being run by the instance.

The property is passed along from the webhook lambda, as part of the SQS event.

@roberto-civitas
roberto-civitas requested a review from a team as a code owner July 10, 2025 18:28
@roberto-civitas roberto-civitas changed the title Add workflow URL to EC2 instance tags feat: Add workflow URL to EC2 instance tags Jul 10, 2025
@roberto-civitas
roberto-civitas force-pushed the add-build-url-to-instance-tags branch 3 times, most recently from 8a5b66b to b98f8bd Compare July 10, 2025 18:43
@roberto-civitas
roberto-civitas force-pushed the add-build-url-to-instance-tags branch from b98f8bd to 343f078 Compare July 10, 2025 18:45
@npalm

npalm commented Jul 14, 2025

Copy link
Copy Markdown
Member

@roberto-civitas thx for the PR. Good idea, but I am afraid it won't work.

Runners are indeed created based on the workflow_job event, however which job starts on the runner is orechestrated by GitHub. So the actual job running on a runner is not alwasy the event that leading to creation of the runner. The module supports XRay which allows you to see correlation between which events is causing runner creation.

Next to het workflow_job event created there is a event for in_progress. This event could be used to tag an instance with the job in progress. It should not hard to correlate based ont he the event since this event contians the runner name as well.

Wondering what your thoughts are.

@roberto-civitas

Copy link
Copy Markdown
Author

Thank you for having a look at the PR. I will modify it so that it uses the event you suggest.

@npalm

npalm commented Jul 15, 2025

Copy link
Copy Markdown
Member

Thank you for having a look at the PR. I will modify it so that it uses the event you suggest.

Maybe good to have a short discussion on how to implement this. This to avoid you wast time on a proposal that is not fitting. My first thought would be having an extra lambda as part of the control plane. But no time to dig in so far.

@edersonbrilhante

edersonbrilhante commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

This can be done the same way I implemented in Forge using runner_template_hook_job_started.
Inside runner_template_hook_job_started, I added a command to update the EC2 tags, as you can see in the PR:
cisco-open/forge#91

Here is where to pass the runner_template_hook_job_started to runners module:
https://github.com/cisco-open/forge/blob/df3e1a38cf522e03e49b290c3ff97c7e9351f485/modules/platform/ec2_deployment/main.tf#L154

@edersonbrilhante

Copy link
Copy Markdown
Contributor

@npalm @roberto-civitas
Check out this idea. I am updating EC2 instances using the EventBridge event bus as a trigger. I created a new rule to subscribe to in_progress and completed events, which then triggers a Lambda to add tags with info about the job ID and job URL. This could be extended to include more properties.

It’s already working in Forge, so it could be added as part of terraform-aws-github-runner.

https://github.com/cisco-open/forge/blob/main/modules/platform/ec2_deployment/lambda/update_ec2_tags.py
https://github.com/cisco-open/forge/blob/main/modules/platform/ec2_deployment/update-ec2-tags.tf

@npalm

npalm commented Nov 2, 2025

Copy link
Copy Markdown
Member

@edersonbrilhante Yup I think that approach is much beeter. Maybe good to put this by default in the scripts provided in this repo. However I would avoid any context info in this repo that is user controlled, e..g github_ref. Others should be fine.

@github-actions

github-actions Bot commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions Bot added the Stale label Feb 1, 2026
@github-actions github-actions Bot closed this Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants