Skip to content

Commit

Permalink
fix(eks): replacement of cloudinit provider for user-data (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-ook authored Feb 5, 2024
1 parent 21eb945 commit 92237c8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ data "aws_ami" "eks" {
}
}

data "template_cloudinit_config" "ng" {
data "cloudinit_config" "ng" {
for_each = { for ng in var.node_groups : ng.name => ng }
base64_encode = true
gzip = false
Expand Down Expand Up @@ -166,10 +166,10 @@ resource "aws_launch_template" "ng" {
instance_type = lookup(each.value, "instance_type", local.default_eks_config.instance_type)
user_data = (
length(regexall("^AL2", lookup(each.value, "ami_type", local.default_eks_config.ami_type))) > 0 ?
data.template_cloudinit_config.ng[each.key].rendered :
data.cloudinit_config.ng[each.key].rendered :
length(regexall("^BOTTLEROCKET", lookup(each.value, "ami_type", local.default_eks_config.ami_type))) > 0 ?
base64encode(local.bottlerocket_userdata) :
data.template_cloudinit_config.ng[each.key].rendered
data.cloudinit_config.ng[each.key].rendered
)

iam_instance_profile {
Expand Down Expand Up @@ -286,7 +286,7 @@ resource "aws_autoscaling_group" "ng" {

# Render a multi-part cloud-init config making use of the part
# above, and other source files
data "template_cloudinit_config" "mng" {
data "cloudinit_config" "mng" {
for_each = { for ng in var.managed_node_groups : ng.name => ng }
base64_encode = true
gzip = false
Expand All @@ -307,10 +307,10 @@ resource "aws_launch_template" "mng" {
tags = merge(local.default-tags, local.eks-tag, var.tags, lookup(each.value, "tags", {}))
user_data = (
length(regexall("^AL2", lookup(each.value, "ami_type", local.default_eks_config.ami_type))) > 0 ?
data.template_cloudinit_config.mng[each.key].rendered :
data.cloudinit_config.mng[each.key].rendered :
length(regexall("^BOTTLEROCKET", lookup(each.value, "ami_type", local.default_eks_config.ami_type))) > 0 ?
base64encode(local.bottlerocket_userdata) :
data.template_cloudinit_config.mng[each.key].rendered
data.cloudinit_config.mng[each.key].rendered
)

block_device_mappings {
Expand Down

0 comments on commit 92237c8

Please sign in to comment.