Currently struggling writing a Terraform module to deploy a Helm chart, I was getting:
│ Error: YAML parse error on external-dns/templates/serviceaccount.yaml: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal object into Go struct field .metadata.annotations of type string
with a resource definition like this one:
resource "helm_release" "external_dns" {
name = "externaldns"
namespace = var.external_dns_namespace
repository = "https://charts.bitnami.com/bitnami"
chart = "external-dns"
version = "5.3.0"
set {
name = "serviceAccount.annotations.eks.amazonaws.com/role-arn"
value = resource.aws_iam_role.external_dns_role.arn
}
}
When I found a public repository with a similar module: https://github.com/lablabs/terraform-aws-eks-external-dns/blob/master/main.tf and see that it has the last parameter defined as
set {
name = "serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn"
value = aws_iam_role.external_dns[0].arn
}
I tried adding those double slashes (\) and everything works! Now I would like to understand... why are these double slash required before the last two "." but not in the other two?
I understand that, in Terraform, the double slash means literally a slash... but I cannot understand why would it be required there.
This is what I am trying to put into the Terraform module.
Any help with an explanation for this issue will be appreciated :)