diff --git a/main.tf b/main.tf index 1034fd22..91ab79a8 100644 --- a/main.tf +++ b/main.tf @@ -4,6 +4,8 @@ locals { create = var.create && var.putin_khuylo is_t_instance_type = replace(var.instance_type, "/^t(2|3|3a|4g){1}\\..*$/", "1") == "1" ? true : false + + ami = try(coalesce(var.ami, try(nonsensitive(data.aws_ssm_parameter.this[0].value), null)), null) } data "aws_ssm_parameter" "this" { @@ -19,7 +21,7 @@ data "aws_ssm_parameter" "this" { resource "aws_instance" "this" { count = local.create && !var.ignore_ami_changes && !var.create_spot_instance ? 1 : 0 - ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) + ami = local.ami instance_type = var.instance_type cpu_core_count = var.cpu_core_count cpu_threads_per_core = var.cpu_threads_per_core @@ -187,7 +189,7 @@ resource "aws_instance" "this" { resource "aws_instance" "ignore_ami" { count = local.create && var.ignore_ami_changes && !var.create_spot_instance ? 1 : 0 - ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) + ami = local.ami instance_type = var.instance_type cpu_core_count = var.cpu_core_count cpu_threads_per_core = var.cpu_threads_per_core @@ -361,7 +363,7 @@ resource "aws_instance" "ignore_ami" { resource "aws_spot_instance_request" "this" { count = local.create && var.create_spot_instance ? 1 : 0 - ami = try(coalesce(var.ami, nonsensitive(data.aws_ssm_parameter.this[0].value)), null) + ami = local.ami instance_type = var.instance_type cpu_core_count = var.cpu_core_count cpu_threads_per_core = var.cpu_threads_per_core