linux - Terraform - Shell 脚本权限被拒绝错误
问题描述
我是 Terraform 世界的新手。我正在尝试使用 terraform 执行 shell 脚本。但是,我收到权限被拒绝错误。
下面是执行 shell 脚本的 main.tf 文件
#Executing shell script via Null Resource
resource "null_resource" "install_istio" {
provisioner "local-exec" {
command = "${path.module}/install-istio.sh"
}
}
下面是 install-istio.sh 文件
#!/bin/sh
# Download and install the Istio istioctl client binary
# Specify the Istio version that will be leveraged throughout these instructions
ISTIO_VERSION=1.7.3
curl -sL "https://github.com/istio/istio/releases/download/$ISTIO_VERSION/istioctl-$ISTIO_VERSION-linux-amd64.tar.gz" | tar xz
sudo mv ./istioctl /usr/local/bin/istioctl
sudo chmod +x /usr/local/bin/istioctl
# Install the Istio Operator on EKS
istioctl operator init
# The Istio Operator is installed into the istio-operator namespace. Query the namespace.
kubectl get all -n istio-operator
# Install Istio components
istioctl profile dump default
# Create the istio-system namespace and deploy the Istio Operator Spec to that namespace.
kubectl create ns istio-system
kubectl apply -f istio-eks.yaml
# Validate the Istio installation
kubectl get all -n istio-system
以下是错误:
module.istio_module.null_resource.install_istio (local-exec): Executing: ["/bin/sh" "-c" ".terraform/modules/istio_module/Istio-Operator/install-istio.sh"]
module.istio_module.null_resource.install_istio (local-exec): /bin/sh: .terraform/modules/istio_module/Istio-Operator/install-istio.sh: Permission denied
module.cluster.data.aws_eks_cluster_auth.auth: Refreshing state...
Error: Error running command '.terraform/modules/istio_module/Istio-Operator/install-istio.sh': exit status 126. Output: /bin/sh: .terraform/modules/istio_module/Istio-Operator/install-istio.sh: Permission denied
有人可以帮我解决缺失的部分吗?感谢您的所有帮助!谢谢!
解决方案
我在命令部分添加了 chmod +x 并且它起作用了。
推荐阅读
- selenium - 如何使用 selenium IDE 查找包含文本的 xpath 并选择该行中的复选框
- android - 当我将标签从一个切换到另一个时,片段中的 Webview 总是刷新
- java - 在运行前定义 Maven 依赖版本
- html - 为什么我的嵌套 CSS 过渡不起作用?
- excel - 如何使用 Excel VBA 将具有属性的 xml 映射 (xsd) 项绑定到工作表单元格?
- browser - 搜索插件 XML 中是否可以有相对路径?(开放搜索)
- python-2.7 - 无法使用 python 2.7 安装数据科学 - ValueError: This package requires python >= 3.0
- swift - 图像未在 Alamofire 中使用 multipartformdata 上传到服务器
- kotlin - 作业问题 - 我做错了什么?
- java - 异常是 java.net.ProtocolException:无效的 HTTP 方法:PATCH