0

I am setting up an AWS VPN with terraform. To achieve it I am building a CA authority with TF running the follow code:

resource "null_resource" "vpn_certificates_creation" {
  provisioner "local-exec" {
  command = "./1-create_certificates_for_vpn_setup.sh"
  interpreter = ["/bin/bash"]
  }
}

I see an error in the output:

null_resource.vpn_certificates_creation (local-exec): Data Base Updated
null_resource.vpn_certificates_creation (local-exec): ./easyrsa: 333: set: Illegal option -o echo
null_resource.vpn_certificates_creation (local-exec): Using SSL: openssl OpenSSL 1.1.1  11 Sep 2018

What is going wrong?

Zioalex
  • 3,441
  • 2
  • 33
  • 30

1 Answers1

0

Looking into the easyrsa code I found this line:

(stty echo 2>/dev/null) || { (set -o echo 2>/dev/null) && set -o echo; }

Therefore I need a tty allocation that is not happening by default in the local-exec TF provider.

Searching around I found a nice solution Trick an application into thinking its stdout is a terminal, not a pipe that I am applying to my specific use case.

resource "null_resource" "vpn_certificates_creation" {
  provisioner "local-exec" {
  command = "./1-create_certificates_for_vpn_setup.sh /dev/null"
  interpreter = ["script", "-eq", "-c"]
  }
}

Using script I can make TF believing that we have a tty allocated.

Zioalex
  • 3,441
  • 2
  • 33
  • 30