Skip to content

Commit 3f203ee

Browse files
Override the ami (#81)
Co-authored-by: cloudpossebot <[email protected]>
1 parent d2fa23a commit 3f203ee

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ Available targets:
142142
| Name | Description | Type | Default | Required |
143143
|------|-------------|------|---------|:--------:|
144144
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br>This is for some rare cases where resources want additional configuration of tags<br>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
145+
| <a name="input_ami"></a> [ami](#input\_ami) | AMI to use for the instance. Setting this will ignore `ami_filter` and `ami_owners`. | `string` | `null` | no |
145146
| <a name="input_ami_filter"></a> [ami\_filter](#input\_ami\_filter) | List of maps used to create the AMI filter for the action runner AMI. | `map(list(string))` | <pre>{<br> "name": [<br> "amzn2-ami-hvm-2.*-x86_64-ebs"<br> ]<br>}</pre> | no |
146147
| <a name="input_ami_owners"></a> [ami\_owners](#input\_ami\_owners) | The list of owners used to select the AMI of action runner instances. | `list(string)` | <pre>[<br> "amazon"<br>]</pre> | no |
147148
| <a name="input_assign_eip_address"></a> [assign\_eip\_address](#input\_assign\_eip\_address) | Assign an Elastic IP address to the instance | `bool` | `true` | no |

docs/terraform.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
| Name | Description | Type | Default | Required |
4444
|------|-------------|------|---------|:--------:|
4545
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br>This is for some rare cases where resources want additional configuration of tags<br>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
46+
| <a name="input_ami"></a> [ami](#input\_ami) | AMI to use for the instance. Setting this will ignore `ami_filter` and `ami_owners`. | `string` | `null` | no |
4647
| <a name="input_ami_filter"></a> [ami\_filter](#input\_ami\_filter) | List of maps used to create the AMI filter for the action runner AMI. | `map(list(string))` | <pre>{<br> "name": [<br> "amzn2-ami-hvm-2.*-x86_64-ebs"<br> ]<br>}</pre> | no |
4748
| <a name="input_ami_owners"></a> [ami\_owners](#input\_ami\_owners) | The list of owners used to select the AMI of action runner instances. | `list(string)` | <pre>[<br> "amazon"<br>]</pre> | no |
4849
| <a name="input_assign_eip_address"></a> [assign\_eip\_address](#input\_assign\_eip\_address) | Assign an Elastic IP address to the instance | `bool` | `true` | no |

main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ locals {
1313
data "aws_region" "default" {}
1414

1515
data "aws_ami" "default" {
16+
count = module.this.enabled && var.ami == null ? 1 : 0
17+
1618
most_recent = "true"
1719

1820
dynamic "filter" {
@@ -59,7 +61,7 @@ resource "aws_instance" "default" {
5961
#bridgecrew:skip=BC_AWS_PUBLIC_12: Skipping `EC2 Should Not Have Public IPs` check. NAT instance requires public IP.
6062
#bridgecrew:skip=BC_AWS_GENERAL_31: Skipping `Ensure Instance Metadata Service Version 1 is not enabled` check until BridgeCrew support condition evaluation. See https://github.com/bridgecrewio/checkov/issues/793
6163
count = module.this.enabled ? 1 : 0
62-
ami = data.aws_ami.default.id
64+
ami = coalesce(var.ami, join("", data.aws_ami.default.*.id))
6365
instance_type = var.instance_type
6466
user_data = length(var.user_data_base64) > 0 ? var.user_data_base64 : data.template_file.user_data[0].rendered
6567
vpc_security_group_ids = compact(concat(module.security_group.*.id, var.security_groups))

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ variable "ami_owners" {
125125
default = ["amazon"]
126126
}
127127

128+
variable "ami" {
129+
type = string
130+
description = "AMI to use for the instance. Setting this will ignore `ami_filter` and `ami_owners`."
131+
default = null
132+
}
133+
128134
variable "ssm_enabled" {
129135
description = "Enable SSM Agent on Host."
130136
type = bool

0 commit comments

Comments
 (0)