bash - bash:./create.sh:权限被拒绝,尝试构建堆栈时
问题描述
我已经创建了一个具有 AdministratorAccess 策略的用户,我可以运行aws s3 ls
并且它运行良好,但是当我尝试在 bash 中使用模板来使用 Cloudformation 构建堆栈时
aws cloudformation create-stack \
--stack-name $1 \
--template-body file://$2 \
--region=us-west-2 \
--capabilities CAPABILITY_IAM
如果我尝试在包含所有文件的目录中构建一个堆栈./create.sh test testVPC.yml
,我得到一个错误:bash: ./create.sh: Permission denied
我正在尝试部署一个简单的 VPC:
Description: >
This template deploys a VCP.
Resources:
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/24
EnableDnsHostnames: true
请你帮助我好吗?
解决方案
您的错误似乎是 bash 错误,而不是 CloudFormation 错误。为了运行./create.sh
,你所在的 linux/unix 系统必须相信 create.sh 是一个可执行程序。
chmod 755 create.sh
此外,通常 create.sh 的第一行应指示使用哪种语言解释器,在您的情况下为 bash:
#!/bin/bash
尽管这可能看起来是可选的,因为在某些系统上,如果#!
省略第一行,它仍然使用 sh(或 bash)。
推荐阅读
- python - 使用 Selenium 和 Python 在连接超时时使用 while 循环从头开始
- javascript - 将键分配给 JSON 对象
- javascript - 具有依赖关系的多个调用 redux-thunk
- javascript - 为什么我们创建一个变量来引用一个类而不是仅仅使用 document.querySelector(".class")?
- excel - 使用大文本填充 Word 文档
- java - 如何打印出数组索引 2-5
- python - 如何从用户输入的字符串中删除引号并将其用于其他目的?
- c# - ASP.NET Core 中 Content-Type“application/csp-report”的“415 Unsupported Media Type”
- typescript - Typescript 在我的 Angular 项目中找不到 @types/spotify-api
- c++ - 在 .cc 文件中找不到 iostream