diff --git a/main.tf b/main.tf index a72e6f0..3713d08 100644 --- a/main.tf +++ b/main.tf @@ -28,6 +28,7 @@ module "comet_ec2" { vpc_id = var.enable_vpc ? module.comet_vpc[0].vpc_id : var.comet_vpc_id comet_ec2_subnet = var.enable_vpc ? module.comet_vpc[0].public_subnets[0] : var.comet_public_subnets[0] comet_ec2_ami_type = var.comet_ec2_ami_type + comet_ec2_ami_id = var.comet_ec2_ami_id comet_ec2_instance_type = var.comet_ec2_instance_type comet_ec2_instance_count = var.comet_ec2_instance_count comet_ec2_volume_type = var.comet_ec2_volume_type diff --git a/modules/comet_ec2/main.tf b/modules/comet_ec2/main.tf index 4a12bfb..9251e8f 100644 --- a/modules/comet_ec2/main.tf +++ b/modules/comet_ec2/main.tf @@ -124,14 +124,15 @@ data "aws_ami" "ubuntu22" { } resource "aws_instance" "comet_ec2" { - ami = var.comet_ec2_ami_type == "al2" ? data.aws_ami.al2.id : ( - var.comet_ec2_ami_type == "rhel7" ? data.aws_ami.rhel7.id : ( - var.comet_ec2_ami_type == "rhel8" ? data.aws_ami.rhel8.id : ( - var.comet_ec2_ami_type == "rhel9" ? data.aws_ami.rhel9.id : ( - var.comet_ec2_ami_type == "ubuntu18" ? data.aws_ami.ubuntu18.id : ( - var.comet_ec2_ami_type == "ubuntu20" ? data.aws_ami.ubuntu20.id : ( - var.comet_ec2_ami_type == "ubuntu22" ? data.aws_ami.ubuntu22.id : ( - null))))))) + ami = var.comet_ec2_ami_id != "" ? var.comet_ec2_ami_id : ( + var.comet_ec2_ami_type == "al2" ? data.aws_ami.al2.id : ( + var.comet_ec2_ami_type == "rhel7" ? data.aws_ami.rhel7.id : ( + var.comet_ec2_ami_type == "rhel8" ? data.aws_ami.rhel8.id : ( + var.comet_ec2_ami_type == "rhel9" ? data.aws_ami.rhel9.id : ( + var.comet_ec2_ami_type == "ubuntu18" ? data.aws_ami.ubuntu18.id : ( + var.comet_ec2_ami_type == "ubuntu20" ? data.aws_ami.ubuntu20.id : ( + var.comet_ec2_ami_type == "ubuntu22" ? data.aws_ami.ubuntu22.id : ( + null)))))))) instance_type = var.comet_ec2_instance_type key_name = var.comet_ec2_key count = var.comet_ec2_instance_count diff --git a/modules/comet_ec2/variables.tf b/modules/comet_ec2/variables.tf index 5bb2ce3..2bdc738 100644 --- a/modules/comet_ec2/variables.tf +++ b/modules/comet_ec2/variables.tf @@ -30,6 +30,11 @@ variable "comet_ec2_instance_type" { type = string } +variable "comet_ec2_ami_id" { + description = "AMI ID for the EC2 instance" + type = string +} + variable "comet_ec2_instance_count" { description = "Number of EC2 instances to provision" type = number diff --git a/variables.tf b/variables.tf index 79deb43..566adbd 100644 --- a/variables.tf +++ b/variables.tf @@ -89,6 +89,12 @@ variable "comet_ec2_ami_type" { } } +variable "comet_ec2_ami_id" { + description = "AMI ID for the EC2 instance" + type = string + default = "" +} + variable "comet_ec2_instance_type" { description = "Instance type for the EC2 instance" type = string @@ -202,7 +208,7 @@ variable "eks_external_dns" { variable "eks_external_dns_r53_zones" { description = "Route 53 zones for external-dns to have access to" type = list(string) - default = [ + default = [ "arn:aws:route53:::hostedzone/XYZ" ] }