Skip to content

Commit f540417

Browse files
committed
cleanup
1 parent a8c7b58 commit f540417

File tree

9 files changed

+70
-49
lines changed

9 files changed

+70
-49
lines changed

examples/multi-runner/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ locals {
5353
{
5454
subnet_ids = lookup(v.runner_config, "subnet_ids", null) != null ? [module.base.vpc.private_subnets[0]] : null
5555
vpc_id = lookup(v.runner_config, "vpc_id", null) != null ? module.base.vpc.vpc_id : null
56-
ami = merge(
56+
ami = contains(keys(v.runner_config), "ami") ? merge(
5757
v.runner_config.ami,
5858
{
5959
id_ssm_parameter_arn = lookup(local.ssm_ami_arns, k, null) != null ? local.ssm_ami_arns[k] : null
6060
}
61-
)
61+
) : null
6262
}
6363
)
6464
}

examples/multi-runner/templates/runner-configs/windows-x64.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ runner_config:
1515
delay_webhook_event: 5
1616
scale_down_schedule_expression: cron(* * * * ? *)
1717
runner_boot_time_in_minutes: 20
18-
ami:
19-
filter:
20-
name:
21-
- Windows_Server-2022-English-Full-ECS_Optimized-*
22-
state:
23-
- available
18+
ami_filter:
19+
name:
20+
- Windows_Server-2022-English-Full-ECS_Optimized-*
21+
state:
22+
- available

examples/prebuilt/main.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ module "runners" {
4545
ami_filter = { name = [var.ami_name_filter], state = ["available"] }
4646
ami_owners = [data.aws_caller_identity.current.account_id]
4747

48-
# Look up runner AMI ID from an AWS SSM parameter (overrides ami_filter at instance launch time)
49-
# NOTE: the parameter must be managed outside of this module (e.g. in a runner AMI build workflow)
50-
# ami_id_ssm_parameter_name = "my-runner-ami-id"
51-
5248
# disable binary syncer since github agent is already installed in the AMI.
5349
enable_runner_binaries_syncer = false
5450

modules/multi-runner/outputs.tf

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,21 @@ output "instance_termination_handler" {
6969
}
7070

7171
output "deprecated_variables_warning" {
72-
description = "Warning for deprecated variables usage"
72+
description = "Warning for deprecated variables usage. These variables will be removed in a future release. Please migrate to using the consolidated 'ami' object in each runner configuration."
7373
value = join("", [
7474
for key, runner_config in var.multi_runner_config : (
75-
try(runner_config.ami_id_ssm_parameter_name, null) != null ?
76-
"DEPRECATION WARNING: The variable 'ami_id_ssm_parameter_name' in runner '${key}' is deprecated and will be removed in a future version. Please use 'ami.id_ssm_parameter_arn' instead.\n" :
77-
""
75+
join("", [
76+
# Show object migration warning only when ami is null and old variables are used
77+
try(runner_config.runner_config.ami, null) == null ? (
78+
(try(runner_config.runner_config.ami_filter, { state = ["available"] }) != { state = ["available"] } ||
79+
try(runner_config.runner_config.ami_owners, ["amazon"]) != ["amazon"] ||
80+
try(runner_config.runner_config.ami_kms_key_arn, "") != "") ?
81+
"DEPRECATION WARNING: Runner '${key}' is using deprecated AMI variables (ami_filter, ami_owners, ami_kms_key_arn). These variables will be removed in a future version. Please migrate to using the consolidated 'ami' object.\n" : ""
82+
) : "",
83+
# Always show warning for ami_id_ssm_parameter_name to migrate to ami_id_ssm_parameter_arn
84+
try(runner_config.runner_config.ami_id_ssm_parameter_name, null) != null ?
85+
"DEPRECATION WARNING: Runner '${key}' is using deprecated variable 'ami_id_ssm_parameter_name'. Please use 'ami.id_ssm_parameter_arn' instead.\n" : ""
86+
])
7887
)
7988
])
8089
}

modules/multi-runner/variables.tf

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,11 @@ variable "multi_runner_config" {
6666
http_put_response_hop_limit = 1
6767
})
6868
ami = optional(object({
69-
filter = optional(map(list(string)), { state = ["available"] })
70-
owners = optional(list(string), ["amazon"])
71-
id_ssm_parameter_name = optional(string, null)
72-
id_ssm_parameter_arn = optional(string, null)
73-
kms_key_arn = optional(string, null)
74-
}), null)
75-
# Deprecated: Use ami object instead
76-
ami = optional(object({
77-
filter = optional(map(list(string)), { state = ["available"] })
78-
owners = optional(list(string), ["amazon"])
79-
id_ssm_parameter_name = optional(string, null)
80-
id_ssm_parameter_arn = optional(string, null)
81-
kms_key_arn = optional(string, null)
82-
}), null)
69+
filter = optional(map(list(string)), { state = ["available"] })
70+
owners = optional(list(string), ["amazon"])
71+
id_ssm_parameter_arn = optional(string, null)
72+
kms_key_arn = optional(string, null)
73+
}), null) # Defaults to null, in which case the module falls back to individual AMI variables (deprecated)
8374
# Deprecated: Use ami object instead
8475
ami_filter = optional(map(list(string)), { state = ["available"] })
8576
ami_owners = optional(list(string), ["amazon"])
@@ -187,6 +178,7 @@ variable "multi_runner_config" {
187178
runner_os: "The EC2 Operating System type to use for action runner instances (linux,windows)."
188179
runner_architecture: "The platform architecture of the runner instance_type."
189180
runner_metadata_options: "(Optional) Metadata options for the ec2 runner instances."
181+
ami: "(Optional) AMI configuration for the action runner instances. This object allows you to specify all AMI-related settings in one place."
190182
ami_filter: "(Optional) List of maps used to create the AMI filter for the action runner AMI. By default amazon linux 2 is used."
191183
ami_owners: "(Optional) The list of owners used to select the AMI of action runner instances."
192184
create_service_linked_role_spot: (Optional) create the serviced linked role for spot instances that is required by the scale-up lambda.

modules/runners/main.tf

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ locals {
3939

4040
# Handle AMI configuration from either the new object or old variables
4141
ami_config = var.ami != null ? var.ami : {
42-
filter = var.ami_filter
43-
owners = var.ami_owners
44-
id_ssm_parameter_name = var.ami_id_ssm_parameter_name
45-
id_ssm_parameter_arn = null
46-
kms_key_arn = var.ami_kms_key_arn
42+
filter = var.ami_filter
43+
owners = var.ami_owners
44+
id_ssm_parameter_arn = null
45+
kms_key_arn = var.ami_kms_key_arn
4746
}
4847
ami_kms_key_arn = local.ami_config.kms_key_arn != null ? local.ami_config.kms_key_arn : ""
4948
ami_filter = merge(local.default_ami[var.runner_os], local.ami_config.filter)

modules/runners/variables.tf

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
variable "ami" {
2-
description = "AMI configuration for the action runner instances"
2+
description = <<EOT
3+
AMI configuration for the action runner instances. This object allows you to specify all AMI-related settings in one place.
4+
5+
Parameters:
6+
- `filter`: Map of lists to filter AMIs by various criteria (e.g., { name = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-*"], state = ["available"] })
7+
- `owners`: List of AMI owners to limit the search. Common values: ["amazon"], ["self"], or specific AWS account IDs
8+
- `id_ssm_parameter_name`: Name of an SSM parameter containing the AMI ID. If specified, this overrides the AMI filter
9+
- `id_ssm_parameter_arn`: ARN of an SSM parameter containing the AMI ID. If specified, this overrides both AMI filter and parameter name
10+
- `kms_key_arn`: Optional KMS key ARN if the AMI is encrypted with a customer managed key
11+
12+
Defaults to null, in which case the module falls back to individual AMI variables (deprecated).
13+
EOT
314
type = object({
4-
filter = optional(map(list(string)), { state = ["available"] })
5-
owners = optional(list(string), ["amazon"])
6-
id_ssm_parameter_name = optional(string, null)
7-
id_ssm_parameter_arn = optional(string, null)
8-
kms_key_arn = optional(string, null)
15+
filter = optional(map(list(string)), { state = ["available"] })
16+
owners = optional(list(string), ["amazon"])
17+
id_ssm_parameter_arn = optional(string, null)
18+
kms_key_arn = optional(string, null)
919
})
1020
default = null
1121
}

outputs.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,14 @@ output "instance_termination_handler" {
7777
}
7878

7979
output "deprecated_variables_warning" {
80-
description = "Warning for deprecated variables usage"
80+
description = "Warning for deprecated variables usage. These variables will be removed in a future release. Please migrate to using the consolidated 'ami' object."
8181
value = join("", [
82-
var.ami_id_ssm_parameter_name != null ? "DEPRECATION WARNING: The variable 'ami_id_ssm_parameter_name' is deprecated and will be removed in a future version. Please use 'ami.id_ssm_parameter_arn' instead.\n" : "",
82+
# Show object migration warning only when ami is null and old variables are used
83+
var.ami == null ? join("", [
84+
(var.ami_filter != { state = ["available"] } || var.ami_owners != ["amazon"] || var.ami_kms_key_arn != null) ?
85+
"DEPRECATION WARNING: You are using the deprecated AMI variables (ami_filter, ami_owners, ami_kms_key_arn). These variables will be removed in a future version. Please migrate to using the consolidated 'ami' object.\n" : "",
86+
]) : "",
87+
# Always show warning for ami_id_ssm_parameter_name to migrate to ami_id_ssm_parameter_arn
88+
var.ami_id_ssm_parameter_name != null ? "DEPRECATION WARNING: The variable 'ami_id_ssm_parameter_name' is deprecated and will be removed in a future version. Please use 'ami.id_ssm_parameter_arn' instead.\n" : ""
8389
])
8490
}

variables.tf

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,23 @@ variable "block_device_mappings" {
367367
}
368368

369369
variable "ami" {
370-
description = "AMI configuration for the action runner instances"
370+
description = <<EOT
371+
AMI configuration for the action runner instances. This object allows you to specify all AMI-related settings in one place.
372+
373+
Parameters:
374+
- `filter`: Map of lists to filter AMIs by various criteria (e.g., { name = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-*"], state = ["available"] })
375+
- `owners`: List of AMI owners to limit the search. Common values: ["amazon"], ["self"], or specific AWS account IDs
376+
- `id_ssm_parameter_name`: Name of an SSM parameter containing the AMI ID. If specified, this overrides the AMI filter
377+
- `id_ssm_parameter_arn`: ARN of an SSM parameter containing the AMI ID. If specified, this overrides both AMI filter and parameter name
378+
- `kms_key_arn`: Optional KMS key ARN if the AMI is encrypted with a customer managed key
379+
380+
Defaults to null, in which case the module falls back to individual AMI variables (deprecated).
381+
EOT
371382
type = object({
372-
filter = optional(map(list(string)), { state = ["available"] })
373-
owners = optional(list(string), ["amazon"])
374-
id_ssm_parameter_name = optional(string, null)
375-
id_ssm_parameter_arn = optional(string, null)
376-
kms_key_arn = optional(string, null)
383+
filter = optional(map(list(string)), { state = ["available"] })
384+
owners = optional(list(string), ["amazon"])
385+
id_ssm_parameter_arn = optional(string, null)
386+
kms_key_arn = optional(string, null)
377387
})
378388
default = null
379389
}

0 commit comments

Comments
 (0)