is there any way to use terraform variable inside a shell script?
The variable i want to use inside my shell-script:
variable "json_file" {
description = "JSON filename"
type = string
default = "Testing_Dashboard--2022-02-16T14_29_16.json"
}
Shell-script (var placement is marked at the end of curl):
#!/bin/sh
DD_API_KEY=abcd
DD_APP_KEY=abcd
dashboard_id="p24-ry9-p5i"
curl -X GET "https://api.datadoghq.eu/api/v1/dashboard/${dashboard_id}" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY_CENSHARE}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY_CENSHARE}" \
> dashboard_exports/<USE_THE_VARIABLE_HERE>
I'am executing the shell-script with null_resource type:
resource "null_resource" "provision" {
triggers = {
build_number = "${timestamp()}"
}
provisioner "local-exec" {
command = "/bin/bash shell_scripts/get_dashboard_json.sh"
interpreter=["/bin/bash", "-c"]
working_dir=path.module
}
}
terraform output json_file?