Unable to set multiple subnets in helm_release

I am not able to add multiple subnets using helm_release provider. I have eks deployed and I want to use eks private subnets to add Internal NLB but I can only able to add the single subnet. If i add count and element it only picking the single subnet id and it rotate the helm_release. I just want to add the my eks subnets using set.

Below are the code snippet

resource “helm_release” “isnp_stg” {
name = var.name
chart = “nginx-ingress”
namespace = var.namespace
repository = “https://helm.nginx.com/stable

create_namespace = true

values = [templatefile(“${path.module}/ingress-nginx-values.yaml”, {

})]

depends_on = [
aws_eks_cluster.isnp-cpg
]

set {
name = “cluster.enabled”
value = “true”
}

set {
name = “metrics.enabled”
value = “true”
}

set {
name = “controller.service.annotations.service\.beta\.kubernetes\.io/aws-load-balancer-cross-zone-load-balancing-enabled”
value = “true”
type = “string”
}

set {
  name  = "controller.service.annotations.service\\.beta\\.kubernetes\\.io/aws-load-balancer-subnets"
  type = "auto"
 value = "${aws_subnet.isnp_stg_private_subnet.*.id}"
}

}

variable “name” {
type = string
description = “Name of helm release”
default = “ingress-nginx”
}
variable “namespace” {
type = string
description = “Name of namespace where nginx controller should be deployed”
default = “isnp”
}

variable “chart_version” {
type = string
description = “HELM Chart Version for nginx controller”
default = “4.0.19”
}

// Create Private Subnets
resource “aws_subnet” “isnp_stg_private_subnet” {
count = length(var.private_cidrs)
vpc_id = data.aws_vpc.selected.id
cidr_block = var.private_cidrs[count.index]
availability_zone = var.azs[count.index]

tags = {
Name = “{var.private_subnet_names}-{count.index + 1}”
}
}

I can agree, there is something strange with latest ingress versions.

anyway, @pikluranjandas tuples can be easily converted to string. example:

locals{ 
  ...
  aws-load-balancer-subnets            = join(",", data.aws_ssm_parameter.transfer_subnet[*].value)
}

but problem even with static:

  set {
    name  = "controller.service.annotations.service\\.beta\\.kubernetes\\.io/aws-load-balancer-subnets"
    type  = "string"
    value = "subnet-0fd26432879bc21c4, subnet-0ba383f86c9453911, subnet-0ebb77e75a9904da2"
  }

which causing:

Error: failed parsing key "controller.service.annotations.service\\.beta\\.kubernetes\\.io/aws-load-balancer-subnets" with value subnet-0fd26432879bc21c4, subnet-0ba383f86c9453911, subnet-0ebb77e75a9904da2, key " subnet-0ba383f86c9453911" has no value (cannot end with ,)

  with helm_release.ingress_nginx,
  on main.tf line 553, in resource "helm_release" "ingress_nginx":
 553: resource "helm_release" "ingress_nginx" {

and this is very and very strange

UPD!
with setting a joined list is breaking with version > 1.2.0 · Issue #495 · hashicorp/terraform-provider-helm · GitHub
i solved my issue.

need to do: aws-load-balancer-subnets = join(“\,”, data.aws_ssm_parameter.transfer_subnet[*].value)

in other words, comma needs to be escaped!

1 Like

@iaroslav-nakonechnik I am trying to do with join config and Passing subnets values from terraform output, its not working

  set {
    name  = "externalAccess.service.loadBalancerAnnotations.service\\.beta\\.kubernetes\\.io/aws-load-balancer-subnets"
    type  = "string"
    value = join(",", data.terraform_remote_state.module_output.outputs.private_subnet_ids)
  }

OR as mentioned in the link you shared works

  set {
    name  = "grafana.ingress.annotations.alb\\.ingress\\.kubernetes\\.io/success-codes"
    value = "200\\,302\\,303"
  }

have you tried to escape commas?