Skip to content

Commit

Permalink
fix: Fixed ami variable when using without ssm (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnsavour authored Aug 17, 2023
1 parent 2dc3446 commit a1691a0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a1691a0

Please sign in to comment.