我有一个bash脚本instance_status.sh,它拥有所有的访问权限,这个脚本被放在/中,当我试图执行它时,它会抛出错误
Error: failed to execute "bash": bash: ./instance_status.sh: No such file or directory
on main.tf line 38, in data "external" "instance_status":
38: data "external" "instance_status" {
Bash脚本:
#!/bin/bash
set -e
eval "$(jq -r '@sh "INSTANCE_ID=(.id)"')"
sleep 360
status=$(aws ec2 describe-instance-status --instance-ids ${INSTANCE_ID} --output json --query
'InstanceStatuses[0]')
instance_status=$(echo ${status} | jq -r '.InstanceStatus.Details[0].Status')
system_status=$(echo ${status} | jq -r '.SystemStatus.Details[0].Status')
jq -n --arg inst_status "$instance_status"
--arg sys_status "$system_status"
'{"instance_status":$inst_status,"system_status":$sys_status}'
我从terrafrom main.tf文件下面调用bash脚本:
data "external" "instance_status" {
program = ["bash", "${path.module}/instance_status.sh"]
query = {
id = aws_instance.QA-server-via-ami.id
}
}
output "test" {
value = data.external.instance_status.result
}
你能帮忙吗。
"这个脚本被放置在/";所以使用绝对路径:
/instance_status.sh