-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Labels
Description
This issue was originally opened by @vikas027 as hashicorp/terraform#12249. It was migrated here as part of the provider split. The original body of the issue is below.
Terraform Version
0.8.7
Affected Resource(s)
Terraform Configuration Files
data "external" "create_policy" {
program = ["bash", "${path.module}/create_policy.sh"]
query = {
list_of_images = "${var.list_of_images}"
}
}
Expected Behavior
List list_of_images
should have been passed to the script.
Actual Behavior
Error refreshing state: 1 error(s) occurred:
* query: 1 error(s) decoding:
* '[list_of_images]' expected type 'string', got unconvertible type '[]interface {}'
Terraform Version
0.8.7
Affected Resource(s)
Terraform Configuration Files
data "external" "create_policy" {
program = ["bash", "${path.module}/create_policy.sh"]
}
create_policy.sh
#!/bin/bash
set -e
# This works
jq -n --arg foobaz "$FOOBAZ" '{"foobaz":$foobaz}'
# This throws an error
jq -n '{"Version":"2008-10-17","Statement":[{"Sid":"repo_policy","Effect":"Allow","Principal":{"AWS":["arn:aws:iam::${account_id}:root","arn:aws:iam::${account_id}:role/ecr_restricted_admin"]},"Action":"*"}]}'
Expected Behavior
Terraform shouldn't thrown an error when the the bash script is producing a valid json
$ bash modules/ecr/create_policy.sh | jq .
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "repo_policy",
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam::${account_id}:root",
"arn:aws:iam::${account_id}:role/ecr_restricted_admin"
]
},
"Action": "*"
}
]
}
Actual Behavior
* data.external.create_policy: command "bash" produced invalid JSON: json: cannot unmarshal array into Go value of type string
Steps to Reproduce
Create the resource and the script files and run terraform plan
mikemac42, caitecoll, keichan34, tristanmorgan, berney and 50 morebgshacklett, marcomoscatiello, dkozlov, iamleet, JavidSalmanov-TomTom and 7 more