Reputation: 63
I am trying to access variable's value from remote location(file, etc.)
I read about input variables
but still couldn't achieve what I am looking for.
My case is to get the value of the variable from some remote file.
I tried something like below
terraform apply -var-file="https://s3-ap-northeast-1.amazonaws.com/..."
but this give error saying no such file or directory
.
Is there any way to load values on runtime from remote location ?
EDIT: I am using mysql provider to create database & users. For setting the user password, I want to use some remote location where my passwords are kept (maybe a s3 file).
PS : I saw that there is keybase available for passwords but I wanted to check if there are other ways for achievening this ?
Upvotes: 2
Views: 730
Reputation: 60104
It's hard to download and pass the file name to terraform apply, but you can do this with bash, This is how we do in remote server.
#!/bin/bash
varfile_name=terraformvar.tfvars
varfile=$(aws s3 cp s3://bucket-********/web-app/terraform/terraform_vars.tfvars ./$varfile_name)
if [ $? -eq 0 ]; then
terraform apply -var-file=$varfile_name
else
echo "failed to download file from s3"
fi
Upvotes: 1