diff --git a/modules/self-managed-node-group/main.tf b/modules/self-managed-node-group/main.tf index 8a65dc6a66..64eba7c6be 100644 --- a/modules/self-managed-node-group/main.tf +++ b/modules/self-managed-node-group/main.tf @@ -42,7 +42,8 @@ locals { } data "aws_ssm_parameter" "ami" { - count = var.create ? 1 : 0 + # only pull the ami if we're creating the resource AND we're not already using a custom ami + count = var.create && length(var.ami_id) == 0 ? 1 : 0 region = var.region @@ -219,7 +220,7 @@ resource "aws_launch_template" "this" { arn = var.create_iam_instance_profile ? aws_iam_instance_profile.this[0].arn : var.iam_instance_profile_arn } - image_id = coalesce(var.ami_id, nonsensitive(data.aws_ssm_parameter.ami[0].value)) + image_id = coalesce(var.ami_id, nonsensitive(try(data.aws_ssm_parameter.ami[0].value, ""))) instance_initiated_shutdown_behavior = var.instance_initiated_shutdown_behavior dynamic "instance_market_options" {