Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ locals {
enabled = var.ssm_sessions.enabled
logs_bucket_name = try(coalesce(var.ssm_sessions.logs_bucket_name, var.logs_bucket_name), "")
}

image_id = var.ami != "" ? var.ami : data.aws_ssm_parameter.linux_ami.value
}

data "aws_partition" "current" {}
Expand All @@ -37,7 +39,7 @@ module "proxy" {
source = "cloudposse/ec2-autoscale-group/aws"
version = "0.41.1"

image_id = data.aws_ssm_parameter.linux_ami.value
image_id = local.image_id
instance_type = "t3.nano"
health_check_type = "ELB"
user_data_base64 = base64encode(module.this.enabled ? data.cloudinit_config.this[0].rendered : "")
Expand Down
11 changes: 11 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ variable "capacity" {
default = {}
}

variable "ami" {
type = string
description = "AMI ID to launch instances with. Accepts an explicit `ami-*` ID or a `resolve:ssm:*` reference that EC2 resolves at instance launch time. Defaults to the latest Amazon Linux 2023 AMI resolved at apply time when empty."
default = ""

validation {
condition = var.ami == "" || startswith(var.ami, "ami-") || startswith(var.ami, "resolve:")
error_message = "The ami value must be empty, an explicit `ami-*` ID, or a `resolve:*` reference."
}
}

variable "instance_types" {
type = list(object({
type = string
Expand Down