You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(ami-housekeeper): don't delete referenced AMIs in default config (#4623)
In 472cc5f the default config was
migrated to use SSM for AMI lookup. A parameter is created which stores
a reference to the AMI. By default, this parameter is called
`${var.ssm_paths.root}/${var.ssm_paths.config}/ami_id`.
The housekeeper is a process that looks for AMIs which can be deleted
because they're no longer used. It does this in a couple of ways:
1. Check the launch template for the AMI ID.
2. Check the SSM parameter.
3. Apply a threshold to not delete AMIs that are too new, according to
the config.
The problem is that we were looking for SSM parameters like this:
```typescript
const ssmParams = await ssmClient.send(
new DescribeParametersCommand({
ParameterFilters: [
{
Key: "Name",
Values: ["ami-id"],
Option: "Contains",
},
],
}),
);
```
i.e. we were looking for parameters which contain the hardcoded string
`ami-id`. This is different to the new default of `ami_id`. So we
weren't considering the right AMIs to be in use.
What would be a better approach would be to reference the values
dynamically. This means resolving from the template, and handling the
passed-in options, if there are any. We're documenting that we support
wildcards, so also support that here too.
The default value in the launch template became `resolve:ssm:<id or
AMI>`, so we need to make sure to ask EC2 to resolve for us when looking
up the template. In that way we get the actual AMI ID rather than the
alias.
This can be a bit challenging to understand, so the comments are
improved.
Comprehensive tests are added to try to ensure this all works as
expected.
Closes: #4571
---------
Co-authored-by: Niek Palm <niek.palm@philips.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Niek Palm <npalm@users.noreply.github.com>
Copy file name to clipboardExpand all lines: examples/prebuilt/README.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,18 @@ This module shows how to create GitHub action runners using a prebuilt AMI for t
7
7
8
8
@@ Usages
9
9
10
+
11
+
Steps for the full setup, such as creating a GitHub app can be found in the root module's [README](https://github.com/github-aws-runners/terraform-aws-github-runner). First download the Lambda releases from GitHub. Alternatively you can build the lambdas locally with Node or Docker, there is a simple build script in `<root>/.ci/build.sh`. In the `main.tf` you can simply remove the location of the lambda zip files, the default location will work in this case.
12
+
13
+
> This example assumes local built lambda's available. Ensure you have built the lambda's. Alternatively you can download the lambda's. The version needs to be set to a GitHub release version, see https://github.com/github-aws-runners/terraform-aws-github-runner/releases
14
+
15
+
```bash
16
+
cd ../lambdas-download
17
+
terraform init
18
+
terraform apply -var=module_version=<VERSION>
19
+
cd -
20
+
```
21
+
10
22
### Packer Image
11
23
12
24
You will need to build your image. This example deployment uses the image example in `/images/linux-amz2`. You must build this image with packer in your AWS account first. Once you have built this you need to provider your owner ID as a variable
| <aname="input_ami_name_filter"></a> [ami\_name\_filter](#input\_ami\_name\_filter)| AMI name filter for the action runner AMI. By default amazon linux 2 is used. |`string`|`"github-runner-al2023-x86_64-*"`| no |
107
+
| <aname="input_aws_region"></a> [aws\_region](#input\_aws\_region)| AWS region. |`string`|`"eu-west-1"`| no |
108
+
| <aname="input_environment"></a> [environment](#input\_environment)| Environment name, used as prefix. |`string`|`null`| no |
95
109
| <aname="input_github_app"></a> [github\_app](#input\_github\_app)| GitHub for API usages. | <pre>object({<br/> id = string<br/> key_base64 = string<br/> })</pre> | n/a | yes |
96
110
| <aname="input_runner_os"></a> [runner\_os](#input\_runner\_os)| The EC2 Operating System type to use for action runner instances (linux,windows). |`string`|`"linux"`| no |
0 commit comments