Error: failed to render : <template_file>:8,15-16: Unsupported operator; Bitwise operators are not supported. Did you mean boolean OR ("&&")?, and 1 other diagnostic(s)
on modules/helm/main.tf line 1, in data "template_file" "helm-values":
1: data "template_file" "helm-values" {
main.tf:
data "template_file" "helm-values" {
template = "${file("${path.module}/helm_.tpl")}"
vars = {
#listener_addr = "${var.Listener_Addr}"
aws_kms_id = "${var.AWS_KMS_ID}"
aws_region = "${var.AWS_Region}"
aws_access_key = "${var.AWS_Access_Key}"
aws_secret_key = "${var.AWS_Secret_Key}"
mysql_user = "${var.MYSQL_user}"
mysql_pw = "${var.MYSQL_pw}"
mysql_rds_addr = "${var.MYSQL_RDS_Address}"
}
}
resource "helm_release" "vault" {
depends_on = [var.MYSQL_RDS_Address]
name = var.Helm_Deployment_Name
repository = "hashicorp"
chart = "hashicorp/vault"
version = var.Helm_Vault_Version
namespace = var.K8_Namespace
values = data.template_file.helm-values
}
Hi @atornetto,
This error seems to be describing a syntax error in your helm_.tpl
file, but you didn’t include the contents of that file in your question. If you can post a new comment showing the contents of that file I might be able to suggest where the syntax error is.
Note that since you are using Terraform 0.12 or later the template_file
data source is no longer necessary and is deprecated. You can achieve the same result using Terraform’s built-in templatefile
function:
resource "helm_release" "vault" {
depends_on = [var.MYSQL_RDS_Address]
name = var.Helm_Deployment_Name
repository = "hashicorp"
chart = "hashicorp/vault"
version = var.Helm_Vault_Version
namespace = var.K8_Namespace
values = templatefile("${path.module}/helm_.tpl", {
aws_kms_id = var.AWS_KMS_ID
aws_region = var.AWS_Region
aws_access_key = var.AWS_Access_Key
aws_secret_key = var.AWS_Secret_Key
mysql_user = var.MYSQL_user
mysql_pw = var.MYSQL_pw
mysql_rds_addr = var.MYSQL_RDS_Address
})
}
The underlying template syntax is the same in both cases, so using templatefile
won’t make your syntax error go away, but it should achieve the same result without using a deprecated provider.
Thanks for that change @apparentlymart! Here is my template file helm_.tpl:
${yamlencode({
"global":
"enabled": "true"
"server":
"ha":
"enabled": "true"
"config": |
"ui" = "true"
"listener" "tcp" {
"tls_disable" = "1"
"address" = "10.0.xx.0/xx:8200" #"${listener_addr}"
"cluster_address" = "10.0.xx.0/xx:8201"
}
"listener" "tcp" {
"address" = "0.0.0.0:8200" #test
}
"seal" "awskms" {
"region" = "${aws_region}"
"kms_key_id" = "{${aws_kms_id}"
"access_key" = "${aws_access_key}"
"secret_key" = "${aws_secret_key}"
}
"storage" "mysql" {
"username" = "${mysql_user}"
"password" = "${mysql_pw}"
"address" = "${mysql_rds_addr}"
}
})}
@apparentlymart do you have any suggestions? thank you!
Hi @atornetto,
The syntax you’ve used here is not valid Terraform language syntax. It seems like you are trying to use a hybrid of Terraform language and YAML syntax, which won’t work because this is a Terraform expression whose result will be converted to YAML, not a YAML data structure itself.
Some of the syntax choices you made here are unfamiliar to me so I’m not entirely sure what would be the correct way to express what you want to express in Terraform. Perhaps it would help if you could show an example of what you’d want the resulting YAML to look like, and then hopefully I can show you the equivalent of that in Terraform’s syntax.
(The specific error you shared is because of the |
character you included after "config":
, which I guess you were intending to take a YAML-like meaning but in the Terraform language that is not a valid operator. However, I think addressing that would just cause another syntax error further down, so I’d like to see what your intended result is so that I can show an example of it all working at once.)