From 14b2688ba6262059700aac3fe1cec1d9c5805544 Mon Sep 17 00:00:00 2001 From: Charlie Jackson Date: Thu, 13 Jul 2023 17:50:12 -0500 Subject: [PATCH] new variables 'associate_public_ip_address' and 'target_ami_name_prefix' --- amazon-eks-al2.pkr.hcl | 12 +++++++----- variables.pkr.hcl | 14 +++++++++++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/amazon-eks-al2.pkr.hcl b/amazon-eks-al2.pkr.hcl index f1b15f9..c8fe40b 100644 --- a/amazon-eks-al2.pkr.hcl +++ b/amazon-eks-al2.pkr.hcl @@ -1,7 +1,7 @@ locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") - target_ami_name = "${var.ami_name_prefix}-${var.eks_version}-${local.timestamp}" + target_ami_name = "${var.target_ami_name_prefix}-${var.eks_version}-${local.timestamp}" } data "amazon-ami" "this" { @@ -54,10 +54,12 @@ source "amazon-ebs" "this" { Name = local.target_ami_name } - source_ami = data.amazon-ami.this.id - ssh_pty = true - ssh_username = var.source_ami_ssh_user - subnet_id = var.subnet_id + source_ami = data.amazon-ami.this.id + ssh_pty = true + ssh_username = var.source_ami_ssh_user + subnet_id = var.subnet_id + associate_public_ip_address = var.associate_public_ip_address + tags = { os_version = "Amazon Linux 2" diff --git a/variables.pkr.hcl b/variables.pkr.hcl index 0b26021..99c874e 100644 --- a/variables.pkr.hcl +++ b/variables.pkr.hcl @@ -77,7 +77,19 @@ variable "instance_type" { } variable "ami_name_prefix" { - description = "The prefix to use when creating the AMI name. i.e. - `--" + description = "The prefix identifying the source AMI to use when creating the AMI. i.e. - `--" type = string default = "amazon-eks-node" } + +variable "associate_public_ip_address" { + description = "If using a non-default VPC, public IP addresses are not provided by default. If this is true, your new instance will get a Public IP." + type = string + default = null +} + +variable "target_ami_name_prefix" { + description = "The prefix to use when creating the AMI name. i.e. - `--" + type = string + default = "custom-eks-node" +} \ No newline at end of file