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.53k stars 600 forks source link

Add the ability to provision arbitrary files to the packer templates #1941

Open toast-gear opened 2 years ago

toast-gear commented 2 years ago

We reference the packer templates directly in this repository so we don't need to maintain our own and keep them in sync with changes that happen here. At the moment you can bolt on additional shell commands via https://github.com/philips-labs/terraform-aws-github-runner/blob/develop/images/ubuntu-focal/github_agent.ubuntu.pkr.hcl#L145 which is great. I would like the ability to also optionally provision files in the same arbitrary style without breaking the template if the end user doesn't have any to provision.

I have more or less 0 Packer knowledge so I'm hoping the community can advise or do the pull request.

ScottGuymer commented 2 years ago

The packer files here are for the most part intended as simple examples of how you might build your own AMI for the runners and not something intended to be re-usable (although its great you do). This is because there are going to be lots of different environment/network/company specific customisations for images created and trying to have a packer template to support that would be too complex to maintain and test well.

That being said it does seem possible and fairly straigtforward.

Add a new variable

variable "files_to_upload" {
  description = "Additional files to be uploaded"
  type        = list(string)
  default     = []
}

Add a new provisioner.

  provisioner "file" {
    sources = var.sources
    destination = "/tmp/"
  }

The destination folder must already exist so would be a little trickier to make that fully custom.

Maybe you could give a try at making a PR with this?

More info on the file provisioner here https://www.packer.io/docs/provisioners/file

github-actions[bot] commented 2 years ago

This issue 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.

toast-gear commented 2 years ago

This is a real enhancement, @npalm @ScottGuymer do you have issue labels which exempt issues from stale at all?

toast-gear commented 2 years ago

@npalm could you exempt this from stale? I've changed companies so no longer work with this solution however I do think it's a legitimate enhancement that someone would find useful so it would be good to keep it raised for someone to do down the road (perhaps I'll get around to doing it just so it's done when I get some time)