Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new variables 'associate_public_ip_address' and 'target_ami_name_prefix' #65

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 7 additions & 5 deletions amazon-eks-al2.pkr.hcl
Original file line number Diff line number Diff line change
@@ -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" {
Expand Down Expand Up @@ -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"
Expand Down
14 changes: 13 additions & 1 deletion variables.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,19 @@ variable "instance_type" {
}

variable "ami_name_prefix" {
description = "The prefix to use when creating the AMI name. i.e. - `<ami_name_prefix>-<eks_version>-<timestamp>"
description = "The prefix identifying the source AMI to use when creating the AMI. i.e. - `<ami_name_prefix>-<eks_version>-<timestamp>"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to just update the variable description to make it clear that its the name prefix that is used to both lookup the base AMI as well as the name prefix used for the resulting AMI

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. - `<target_ami_name_prefix>-<eks_version>-<timestamp>"
type = string
default = "custom-eks-node"
}