I'm new to Terraform world. I'm trying to run a shell script using Terraform.
Below is the main.tf file
#Executing shell script via Null Resource
resource "null_resource" "install_istio" {
provisioner "local-exec" {
command = <<EOT
"chmod +x install-istio.sh"
"./install-istio.sh"
EOT
interpreter = ["/bin/bash", "-c"]
working_dir = "${path.module}"
}
}
Below is the install-istio.sh file which it needs to run
#!/bin/sh
# Download and install the Istio istioctl client binary
# Specify the Istio version that will be leveraged throughout these instructions
ISTIO_VERSION=1.7.3
curl -sL "https://github.com/istio/istio/releases/download/$ISTIO_VERSION/istioctl-$ISTIO_VERSION-linux-amd64.tar.gz" | tar xz
sudo mv ./istioctl /usr/local/bin/istioctl
sudo chmod +x /usr/local/bin/istioctl
# Install the Istio Operator on EKS
istioctl operator init
# The Istio Operator is installed into the istio-operator namespace. Query the namespace.
kubectl get all -n istio-operator
# Install Istio components
istioctl profile dump default
# Create the istio-system namespace and deploy the Istio Operator Spec to that namespace.
kubectl create ns istio-system
kubectl apply -f istio-eks.yaml
# Validate the Istio installation
kubectl get all -n istio-system
I'm getting below warning:
Warning: Interpolation-only expressions are deprecated
on .terraform/modules/istio_module/Istio-Operator/main.tf line 10, in resource "null_resource" "install_istio":
10: working_dir = "${path.module}"
Terraform 0.11 and earlier required all non-constant expressions to be
provided via interpolation syntax, but this pattern is now deprecated. To
silence this warning, remove the "${ sequence from the start and the }"
sequence from the end of this expression, leaving just the inner expression.
Template interpolation syntax is still used to construct strings from
expressions when the template includes multiple interpolation sequences or a
mixture of literal strings and interpolations. This deprecation applies only
to templates that consist entirely of a single interpolation sequence.
The above script in main.tf does run command in the background.
Can someone help me with the missing part? How can I run multiple commands using local exec Also, How can I get rid of the warning message?
Appreciate all your help, Thanks!