Hi all. I’m running into an error when I use the terraform_data resource to run a curl command.
Here’s the code:
resource "terraform_data" "verify" {
provisioner "local-exec" {
command = <<EOT
curl -X GET -H "Authorization: Bearer ${data.google_client_config.default.access_token}" \
-H "Content-Type:application/json" \
"https://apigee.googleapis.com/v1/organizations/<redacted>:getSyncAuthorization"
EOT
}
}
data "google_client_config" "default" {
provider = google
}
And here’s the error:
Error: Invalid template interpolation value
│
│ on curl.tf line 15, in resource "terraform_data" "verify":
│ 14: command = <<EOT
│ 15: curl -X GET -H "Authorization: ***" \
│ 16: -H "Content-Type:application/json" \
│ 17: "https://apigee.googleapis.com/v1/organizations/<redatcted>:getSyncAuthorization"
│ 18: EOT
│
│ The expression result is null. Cannot include a null value in a string
│ template.
The role used to run the terraform has the following permissions assigned to it:
iam.serviceAccounts.getAccessToken
iam.serviceAccounts.getOpenIdToken
iam.serviceAccounts.implicitDelegation
iam.serviceAccounts.signBlob
iam.serviceAccounts.signJwt
What am I missing?