From 0d484b2d297c90c02d06b9b7fa6c70d696b27f3c Mon Sep 17 00:00:00 2001 From: pchatain Date: Wed, 11 Sep 2024 08:38:09 -0700 Subject: [PATCH 1/4] required for capacity block --- main.tf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.tf b/main.tf index 749e67d..93ab750 100644 --- a/main.tf +++ b/main.tf @@ -166,6 +166,15 @@ resource "aws_instance" "this" { } } + dynamic "instance_market_options" { + for_each = length(var.instance_market_options) > 0 ? [var.instance_market_options] : [] + + content { + market_type = try(instance_market_options.value.market_type, null) + spot_options = try(instance_market_options.value.spot_options, null) + } +} + enclave_options { enabled = var.enclave_options_enabled } From ef87ee9477ce819efa207729c60582f7032652cb Mon Sep 17 00:00:00 2001 From: pchatain Date: Wed, 11 Sep 2024 08:44:38 -0700 Subject: [PATCH 2/4] add ability to read it in --- variables.tf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/variables.tf b/variables.tf index 38a1b5b..c7e600b 100644 --- a/variables.tf +++ b/variables.tf @@ -40,6 +40,12 @@ variable "maintenance_options" { default = {} } +variable "instance_market_options" { + description = "The market (purchasing) option for the instance" + type = any + default = {} +} + variable "availability_zone" { description = "AZ to start the instance in" type = string From b39c2cdc85cb900bc628ea7c6dc030ee8cd97450 Mon Sep 17 00:00:00 2001 From: pchatain Date: Wed, 11 Sep 2024 08:47:52 -0700 Subject: [PATCH 3/4] remove spot options since we don't need it --- main.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/main.tf b/main.tf index 93ab750..6a2243d 100644 --- a/main.tf +++ b/main.tf @@ -171,7 +171,6 @@ resource "aws_instance" "this" { content { market_type = try(instance_market_options.value.market_type, null) - spot_options = try(instance_market_options.value.spot_options, null) } } From 87f0a84bc8f309e56d917e80057d44d61752fa93 Mon Sep 17 00:00:00 2001 From: pchatain Date: Wed, 11 Sep 2024 10:56:38 -0700 Subject: [PATCH 4/4] first linting pass --- main.tf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.tf b/main.tf index 6a2243d..a0536b3 100644 --- a/main.tf +++ b/main.tf @@ -167,12 +167,12 @@ resource "aws_instance" "this" { } dynamic "instance_market_options" { - for_each = length(var.instance_market_options) > 0 ? [var.instance_market_options] : [] + for_each = length(var.instance_market_options) > 0 ? [var.instance_market_options] : [] - content { - market_type = try(instance_market_options.value.market_type, null) + content { + market_type = try(instance_market_options.value.market_type, null) + } } -} enclave_options { enabled = var.enclave_options_enabled