resources:
Resources:
# 首先你需要先有一个桶。最简单的例子
S3BucketWwwexamplecom:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.s3WwwBucket}
AccessControl: PublicRead
# 存在这个桶之后,可以设置桶的策略,用到的是BucketPolicy.
BucketPolicyWwwexamplecom:
Type: 'AWS::S3::BucketPolicy'
Properties:
PolicyDocument:
Statement:
- Effect: Allow
Principal: '*'
Action:
- 's3:GetObject'
Resource: arn:aws:s3:::${self:custom.s3WwwBucket}/*
Bucket:
Ref: S3BucketWwwexamplecom
https://stackoverflow.com/questions/51752703/attach-bucket-policy-to-bucket-generated-by-serverless
https://stackoverflow.com/questions/54259512/how-to-create-a-bucket-with-public-read-access 这个是一个比较老的版本,使用会有问题,可以参考上面的链接。