我正在构建我的第一个sls应用程序,并且试图创建两个存储桶。“ LogosBucket”可完美运行。我执行相同的过程来创建另一个名为“ DocumentsBucket”的文件,但失败并显示以下消息:“发生错误:DocumentsBucket-files-bucket-dev已经存在。”
我看过堆栈,它没有在资源下列出。我知道有桶事件发生的问题,但我不认为这是我的情况。感觉像是一个非常简单的疏忽,但我有点迷茫。
这是我的serverless.yml文件:
iamRoleStatements:
- ${file(iam/LogosBucketIAM.yml):LogosBucketIAM}
- ${file(iam/DocumentsBucketIAM.yml):DocumentsBucketIAM}
resources:
Resources:
LogosBucket: ${file(resources/LogosBucket.yml):LogosBucket}
LogosBucketPolicy: ${file(resources/LogosBucket.yml):LogosBucketPolicy}
DocumentsBucket: ${file(resources/DocumentsBucket.yml):DocumentsBucket}
DocumentsBucketPolicy: ${file(resources/DocumentsBucket.yml):DocumentsBucketPolicy}
...
custom:
LogosBucket:
name: logos-bucket-${self:provider.stage}
DocumentsBucket:
name: documents-bucket-${self:provider.stage}
DocumentsBucketIAM.yml:
DocumentsBucketIAM:
Effect: Allow
Action:
- s3:PutObject
Resource: arn:aws:s3:::${self:custom.DocumentsBucket.name}/*
LogosBucketIAM.yml:
LogosBucketIAM:
Effect: Allow
Action:
- s3:PutObject
Resource: arn:aws:s3:::${self:custom.LogosBucket.name}/*
DocumentsBucket.yml:
DocumentsBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.DocumentsBucket.name}
DocumentsBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref DocumentsBucket
PolicyDocument:
Statement:
- Sid: PublicRead
Effect: Allow
Principal: '*'
Action:
- s3:GetObject
Resource: arn:aws:s3:::${self:custom.DocumentsBucket.name}/*
LogosBucket.yml:
LogosBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.LogosBucket.name}
LogosBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref LogosBucket
PolicyDocument:
Statement:
- Sid: PublicRead
Effect: Allow
Principal: '*'
Action:
- s3:GetObject
Resource: arn:aws:s3:::${self:custom.LogosBucket.name}/*
我将不胜感激调试sls的任何帮助和/或技巧。谢谢!
S3是通用名称空间,这意味着您创建的每个S3存储桶必须具有唯一的名称,该名称不会被世界上其他任何人使用。这是因为您的存储桶名称构成了S3网址的一部分,该网址必须唯一。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句