I'm trying to create an EKS node group with NVMe storage(for Spark usage). I've followed this blog post: https://aws.amazon.com/blogs/containers/best-practices-for-running-spark-on-amazon-eks/
I'm trying to set this up on terraform by specifying a launch template for the EKS node group like so:
data "template_file" "user_data_prepare_nvme" {
template = <<EOF
#!/bin/bash -xe
IDX=1
for DEV in /dev/disk/by-id/nvme-Amazon_EC2_NVMe_Instance_Storage_*-ns-1; do
mkfs.xfs ${DEV}
mkdir -p /pv-disks/local${IDX}
echo ${DEV} /pv-disks/local${IDX} xfs defaults,noatime 1 2 >> /etc/fstab
IDX=$((${IDX} 1))
done
mount -a
EOF
}
However, I'm getting a strange error
Error: Invalid reference
│
│ on __data__.tf line 227, in data "template_file" "user_data_prepare_nvme":
│ 227: IDX=1 && for DEV in /dev/disk/by-id/nvme-Amazon_EC2_NVMe_Instance_Storage_*-ns-1; do mkfs.xfs ${DEV};mkdir -p /pv-disks/local${IDX};echo ${DEV} /pv-disks/local${IDX} xfs defaults,noatime 1 2 >> /etc/fstab; IDX=$((${IDX} 1)); done
│
│ A reference to a resource type must be followed by at least one attribute
│ access, specifying the resource name.
I have no idea what Terraform is thinking here. My understanding is that it is just a string definition here?
CodePudding user response:
If ${IDX} is your bash variable reference, not TF reference, you have to escape it:
$${IDX}
You have to do similar escaping for other bash variables references.
