尝试 运行 aws cli 时 S3 访问被拒绝

S3 access denied when trying to run aws cli

我正在尝试使用 AWS CLI 运行

aws cloudformation create-stack --stack-name FullstackLambda --template-url https://s3-us-west-2.amazonaws.com/awsappsync/resources/lambda/LambdaCFTemplate.yam --capabilities CAPABILITY_NAMED_IAM --region us-west-2

但我收到错误

An error occurred (ValidationError) when calling the CreateStack operation: S3 error: Access Denied 

我已经使用

设置了我的凭据
aws configure

PS 我从 AppSync 文档 (https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-lambda-resolvers.html)

获得了 create-stack 命令

您似乎不小心跳过了模板文件名末尾的 l 字母:

LambdaCFTemplate.yam -> LambdaCFTemplate.yaml

首先确保S3URL是正确的。但由于这是 403,我怀疑是这样。

您的结果可能来自几种不同的情况。

1.If API 和 IAM 用户均受 MFA 保护,您必须使用 aws sts get-session-token 生成临时凭证并使用它

2.Use 提供对 S3 中模板对象的 cloudformation 读取访问权限的角色。首先创建一个具有 S3 读取权限的 IAM 角色。然后创建如下所示的参数并在资源属性 IamInstanceProfile

中引用它
  "InstanceProfile":{  
     "Description":"Instance Profile Name",
     "Type":"String",
     "Default":"iam-test-role"
  }