-
Notifications
You must be signed in to change notification settings - Fork 680
feat(runners): add support for looking up pre-built runner AMI ID from an SSM parameter at instance launch time #2520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(runners): add support for looking up pre-built runner AMI ID from an SSM parameter at instance launch time #2520
Conversation
@jpalomaki the PR looks nice, can you add some more tests around this PR to meet the coverage goals, its failing the build. |
@GuptaNavdeep1983 Added some tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice, need to test and added some comments. Can you also add the default example with a commented out part to show how the AMI override works?
@jpalomaki did you had time to check our comments? |
@npalm Not yet (I was afk this week). I will have a look at them on Monday. π |
β¦erraform-aws-github-runner into dynamic-runner-ami-id
@npalm @GuptaNavdeep1983 Comments addressed. Let me know what you think |
β¦-aws-github-runner into dynamic-runner-ami-id
This is now also done in philips-labs/terraform-aws-github-runner@8fe47d6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good. Test the PR on top of the default example with the code below:
module "runners" {
...
ami_id_ssm_parameter_name = aws_ssm_parameter.runner_enable_cloudwatch.name
}
data "aws_ami" "runner" {
most_recent = "true"
filter {
name = "name"
values = ["amzn2-ami-kernel-5.*-hvm-2.0.202209*-x86_64-gp*"] # some older AMI
}
owners = ["amazon"]
}
resource "aws_ssm_parameter" "runner_enable_cloudwatch" {
name = "/${local.environment}/runners/ami"
type = "String"
value = data.aws_ami.runner.image_id
}
## [1.14.0](philips-labs/terraform-aws-github-runner@v1.13.0...v1.14.0) (2022-10-31) ### Features * Experimental feature - Duplicate workflow job event to extra queue ([#2268](https://github.com/philips-labs/terraform-aws-github-runner/issues/2268)) ([ac046b8](philips-labs/terraform-aws-github-runner@ac046b8)) * **runners:** Add support for looking up runner AMI ID from an SSM parameter at instance launch time ([#2520](https://github.com/philips-labs/terraform-aws-github-runner/issues/2520)) ([68e2381](philips-labs/terraform-aws-github-runner@68e2381)) ### Bug Fixes * replacing deprecated set-output in workflow ([#2564](https://github.com/philips-labs/terraform-aws-github-runner/issues/2564)) ([aa0afdd](philips-labs/terraform-aws-github-runner@aa0afdd))
"ssm:GetParameter" | ||
], | ||
"Resource": [ | ||
"arn:aws:ssm:${var.aws_region}:${data.aws_caller_identity.current.account_id}:parameter/${trimprefix(var.ami_id_ssm_parameter_name, "/")}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the partition might need to be parameterized here, so that it can run in the various govcloud implementations
(I believe it's already part of some of the options passed in to various modules, maybe not this one)
## [1.14.0](philips-labs/terraform-aws-github-runner@v1.13.0...v1.14.0) (2022-10-31) ### Features * Experimental feature - Duplicate workflow job event to extra queue ([#2268](https://github.com/philips-labs/terraform-aws-github-runner/issues/2268)) ([ac046b8](philips-labs/terraform-aws-github-runner@ac046b8)) * **runners:** Add support for looking up runner AMI ID from an SSM parameter at instance launch time ([#2520](https://github.com/philips-labs/terraform-aws-github-runner/issues/2520)) ([68e2381](philips-labs/terraform-aws-github-runner@68e2381)) ### Bug Fixes * replacing deprecated set-output in workflow ([#2564](https://github.com/philips-labs/terraform-aws-github-runner/issues/2564)) ([aa0afdd](philips-labs/terraform-aws-github-runner@aa0afdd))
## [1.14.0](philips-labs/terraform-aws-github-runner@v1.13.0...v1.14.0) (2022-10-31) ### Features * Experimental feature - Duplicate workflow job event to extra queue ([#2268](https://github.com/philips-labs/terraform-aws-github-runner/issues/2268)) ([ac046b8](philips-labs/terraform-aws-github-runner@ac046b8)) * **runners:** Add support for looking up runner AMI ID from an SSM parameter at instance launch time ([#2520](https://github.com/philips-labs/terraform-aws-github-runner/issues/2520)) ([68e2381](philips-labs/terraform-aws-github-runner@68e2381)) ### Bug Fixes * replacing deprecated set-output in workflow ([#2564](https://github.com/philips-labs/terraform-aws-github-runner/issues/2564)) ([aa0afdd](philips-labs/terraform-aws-github-runner@aa0afdd))
π
Use case: we build custom runner AMIs periodically (as new actions/runner versions are released), and we have disabled auto-updates on the runners (to keep things predictable and fast). Now the problem is that currently we need to re-apply the runner terraform config, to pick up a newly-built AMI (since it is looked up by the terraform data source).
This PR introduces an option to have the scale up lambda look up the runner AMI ID from an SSM parameter at runner instance launch time, thereby allowing us to update the AMI, without having to re-apply runner stacks.
To make this work fully automated, we'd also amend our AMI build workflow to update this AMI ID SSM parameter, as a new AMI version is built. Then it would be automatically picked up by the runner stack.
This PR is a draft for now, because I assume we'd need to add some tests and amend documentation if this feature is seen as merge-worthy.I have quickly smoke-tested the happy path in an actual GitHub repo/AWS account.
Let me know what you think.
Thanks,
Jukka