philips-labs / terraform-aws-github-runner

Terraform module for scalable GitHub action runners on AWS
https://philips-labs.github.io/terraform-aws-github-runner/
MIT License
2.44k stars 578 forks source link

Question: cost attribution per team/repository recommendation #3958

Open kgoralski opened 3 days ago

kgoralski commented 3 days ago

Hey,

I wonder if you got some recommendation on dynamic EC2 tagging of self-hosted runners for cost exploring. Like per team/repository.

With multiple teams and repositories setup It would be great to for example on Job got started it got tagged additionally with tags like team, repository etc. Ideally it could be some extra tags on GH workflows side that could be picked up by scale-up lambda that could update the tags dynamically?

Maybe it could be extended with usage of these variables?

https://github.com/philips-labs/terraform-aws-github-runner/blob/main/modules/multi-runner/variables.tf#L64

https://github.com/philips-labs/terraform-aws-github-runner/blob/e269d0f7906d9a9c7dbf8da951af94c6a87ca6f0/modules/multi-runner/variables.tf#L80

Thanks in advance for the answer

npalm commented 18 hours ago

With ec2 tags (and multi-runners) you can tag per runner type. Tagging per job is not supported. I think this can be done by using a pre job script that is using the job event to add a tag to the instance.

For repo level runners tagging could also be done via the lambda, but not sure if this is supported by the module. For org level runners this won't work since creating a runner based on an event does not match which job got assigned by GitHub.