【发布时间】:2020-03-02 02:48:54
【问题描述】:
我使用 Bref (https://bref.sh/)。我尝试使用 AWS S3 配置 serverless.yml 文件,以存储 img、css、js 等资产。当我使用“无服务器部署”命令进行部署时,出现此错误:
发生错误:AssetsBucketPolicy - API: s3:PutBucketPolicy Access 拒绝。
在我的 AWS 账户中,我拥有“AdministratorAccess”权限 (https://www.youtube.com/watch?v=KngM5bfpttA&list=PL0_-jlAhLRgEcU0P0Ivi4OO844pgrzJOU&index=2&t=0s)
策略AdministratorAccess
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
]
}
我的 serverless.yml 文件是:
service: bref-demo-symfony
provider:
name: aws
region: us-east-1
runtime: provided
environment:
# Symfony environment variables
APP_ENV: prod
plugins:
- ./vendor/bref/bref
functions:
website:
handler: public/index.php
timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
layers:
- ${bref:layer.php-73-fpm}
events:
- http: 'ANY /'
- http: 'ANY /{proxy+}'
console:
handler: bin/console
timeout: 120 # in seconds
layers:
- ${bref:layer.php-73} # PHP
- ${bref:layer.console} # The "console" layer
resources:
Resources:
# The S3 bucket that stores the assets
Assets:
Type: AWS::S3::Bucket
Properties:
BucketName: my-unique-serverless-assets-bucket
# The policy that makes the bucket publicly readable
AssetsBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref Assets # References the bucket we defined above
PolicyDocument:
Statement:
- Effect: Allow
Principal: '*' # everyone
Action: 's3:GetObject' # to read
Resource: 'arn:aws:s3:::my-unique-serverless-assets-bucket/*' # things in the bucket
在 AWS S3 上,我尝试使用
在存储桶上添加策略 {
"Id": "Policy1573043469280",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1573043465451",
"Action": "s3:*",
"Effect": "Allow",
"Resource": "arn:aws:s3:::bref-demo-symfony-dev-serverless-assets/assets",
"Principal": "*"
}
]
}
我收到一条消息,例如“拒绝访问”、“您无法授予公共访问权限,因为阻止公共访问设置 已为此帐户启用。确定哪些设置是 打开,检查您的阻止公共访问设置。”为什么?
我不明白如何配置它?这个权限(AdministratorAccess)不够?
谢谢!
【问题讨论】:
-
这里是解决方案stackoverflow.com/a/56094474/611720 左侧切换菜单隐藏了我在 S3 管理控制台页面上的“阻止公共访问(帐户设置)”选项
标签: amazon-s3 amazon-iam serverless bref