From 4a4b91d7557eacf0c3effe07f7ced0e0ac366926 Mon Sep 17 00:00:00 2001 From: Jessica Gadling Date: Fri, 21 Jan 2022 13:17:26 -0800 Subject: [PATCH] Make AMI ID's configurable. (#39) * Support explicit batch AMI ID's * Helps to get a ternary right. * Bump swipe version. --- main.tf | 1 + terraform/modules/swipe-sfn-batch-queue/main.tf | 2 +- terraform/modules/swipe-sfn-batch-queue/variables.tf | 6 ++++++ variables.tf | 6 ++++++ version | 2 +- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index f7d1cfe2..a5996097 100644 --- a/main.tf +++ b/main.tf @@ -29,6 +29,7 @@ module "batch_queue" { vpc_id = module.batch_subnet[0].vpc_id batch_subnet_ids = module.batch_subnet[0].batch_subnet_ids } + ami_id = var.batch_ami_id batch_ec2_instance_types = var.batch_ec2_instance_types spot_min_vcpus = var.spot_min_vcpus on_demand_min_vcpus = var.on_demand_min_vcpus diff --git a/terraform/modules/swipe-sfn-batch-queue/main.tf b/terraform/modules/swipe-sfn-batch-queue/main.tf index 66c8ee15..3c588615 100644 --- a/terraform/modules/swipe-sfn-batch-queue/main.tf +++ b/terraform/modules/swipe-sfn-batch-queue/main.tf @@ -103,7 +103,7 @@ resource "aws_batch_compute_environment" "swipe_main" { compute_resources { instance_role = aws_iam_instance_profile.swipe_batch_main.arn instance_type = var.batch_ec2_instance_types - image_id = data.aws_ssm_parameter.swipe_batch_ami.value + image_id = length(var.ami_id) > 0 ? var.ami_id : data.aws_ssm_parameter.swipe_batch_ami.value ec2_key_pair = var.batch_ssh_key_pair_id != "" ? var.batch_ssh_key_pair_id : null security_group_ids = [aws_security_group.swipe.id] subnets = var.network_info.batch_subnet_ids diff --git a/terraform/modules/swipe-sfn-batch-queue/variables.tf b/terraform/modules/swipe-sfn-batch-queue/variables.tf index 66dfcffd..aba894df 100644 --- a/terraform/modules/swipe-sfn-batch-queue/variables.tf +++ b/terraform/modules/swipe-sfn-batch-queue/variables.tf @@ -15,6 +15,12 @@ variable "batch_ssh_key_pair_id" { type = string } +variable "ami_id" { + description = "Override the default AMI image ID (default: latest AL2 ECS batch image)" + type = string + default = "" +} + variable "network_info" { description = "VPC ID and subnet IDs within that VPC to use for AWS batch instances" type = object({ diff --git a/variables.tf b/variables.tf index a4cc3749..43b030e1 100644 --- a/variables.tf +++ b/variables.tf @@ -15,6 +15,12 @@ variable "batch_ssh_public_key" { default = "" } +variable "batch_ami_id" { + description = "AMI ID to use (leave this empty to dynamically use the latest ECS optimized AMI)" + type = string + default = "" +} + variable "network_info" { description = "VPC ID and subnet IDs within that VPC to use for AWS batch instances. If none is provided swipe will generate one" type = object({ diff --git a/version b/version index 532b6e59..9a0d4477 100644 --- a/version +++ b/version @@ -1 +1 @@ -v0.11.0-beta +v0.12.0-beta