Terraform v0.11.11 + provider.external v1.0.0
data "external" "script" {
program = ["python", "${path.module}\secret.py -id SFTP-Key -keyname private-key"]
}
output "Private Key" {
value = "${data.external.script.result.program}"
}
I was hoping to recieve the output of the script in the same way stdout would after running python C:\Users\oliverj\Documents\Code\github\test\secret.py -id SFTP-Key -keyname private-key
Error: Error refreshing state: 1 error(s) occurred:
data.external.script: 1 error(s) occurred:
data.external.script: data.external.script: failed to execute "python": python: can't open file 'C:\Users\oliverj\Documents\Code\github\test\secret.py -id SFTP-Key -keyname private-key': [Errno 2] No such file or directory-->
terraform initterraform plan or terraform applyI am able to runpython C:\Users\oliverj\Documents\Code\github\test\secret.py -id SFTP-Key -keyname private-key without issue
Hi @JasonOliverEmaze,
The external data source expects each argument to be a separate element in the list, like this:
program = ["python", "${path.module}\secret.py", "-id", "SFTP-Key", "-keyname", "private-key"]
I think with your current configuration, Python is trying to treat the entire string C:\Users\oliverj\Documents\Code\github\test\secret.py -id SFTP-Key -keyname private-key as the script to run, which therefore doesn't work.
failed to execute "python": it finds the python file prints some of the values in it but still gives this error any idea about this
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
Hi @JasonOliverEmaze,
The
externaldata source expects each argument to be a separate element in the list, like this:I think with your current configuration, Python is trying to treat the entire string
C:\Users\oliverj\Documents\Code\github\test\secret.py -id SFTP-Key -keyname private-keyas the script to run, which therefore doesn't work.