【发布时间】:2022-02-18 18:07:03
【问题描述】:
我正在使用无服务器框架,当我尝试访问私有存储桶上的签名 URL 以获取以下配置的 GET 和 PUT 时,出现访问被拒绝错误。但是,当我为 iam.role.statements[0].Resource 下的 Resource 授予 * 时(而不是显式引用 private-bucket),它工作得很好。我做错了什么以及无需授予“*”权限而只需授予私有存储桶权限的最佳方法是什么?
provider:
name: aws
runtime: nodejs12.x
lambdaHashingVersion: '20201221'
iam:
role:
statements:
- Effect: 'Allow'
Action:
- 's3:GetObject'
- 's3:PutObject'
Resource:
- Fn::GetAtt:
- PrivateBucket
- Arn
resources:
Resources:
PrivateBucket:
Type: AWS::S3::Bucket
DeletionPolicy: Retain
Properties:
BucketName: private-bucket
OwnershipControls:
Rules:
- ObjectOwnership: BucketOwnerEnforced
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
CorsConfiguration:
CorsRules:
- AllowedHeaders:
- '*'
AllowedMethods:
- GET
- PUT
AllowedOrigins:
- '*'
【问题讨论】:
标签: amazon-web-services amazon-s3 aws-lambda serverless-framework