gpt4 book ai didi

amazon-web-services - 使用无服务器创建 S3 存储桶时出现错误 `Bucket name should not contain uppercase characters`

转载 作者:行者123 更新时间:2023-12-04 08:55:17 24 4
gpt4 key购买 nike

我写了一个serverless.yml我在哪里创建 3 S3桶资源。这是我必须完成的一些带回家的项目,它需要两个桶用于我必须处理的静态模板,一个桶用于结果。我正在定义 SQS,它成功创建了队列,并且我能够从我的 lambda 向其发送消息并通过另一个 lambda 接收消息。

但是,定义 S3 存储桶资源给我 An error occurred: S3LanguageTemplatesBucket - Bucket name should not contain uppercase characters.

我尝试对存储桶名称使用硬编码值,但没有帮助。

我的serverless.yml的内容文件如下:

service: process-scores

org: osano

frameworkVersion: '2'

provider:
name: aws
runtime: nodejs12.x
profile: serverless-admin
region: us-east-1
environment:
SQS_URL: MyQueue
S3_HTML_TEMPLATES: ${self:service}-html-templates-sf68N5umh8gC8yM4
S3_LANGUAGE_TEMPLATES: ${self:service}-language-templates-gY9b7REadVPtKChV
S3_STATIC_WEBSITE: '${self:service}-static-website-pD4c7M2297pjAmST'

functions:
send:
handler: scores/producer.send
events:
- http:
path: scores
method: post
integration: lambda
cors: true
iamRoleStatements:
- Effect: Allow
Action:
- "sqs:SendMessage"
- "sqs:GetQueueUrl"
Resource:
Fn::GetAtt: [ MyQueue, Arn ]

receive:
handler: scores/consumer.receive
events:
- sqs:
arn:
Fn::GetAtt:
- MyQueue
- Arn
iamRoleStatements:
- Effect: Allow
Action:
- "s3:GetObject"
Resource:
- 'arn:aws:s3:::${self:provider.environment.S3_HTML_TEMPLATES}/*'
- 'arn:aws:s3:::${self:provider.environment.S3_LANGUAGE_TEMPLATES}/*'
- Effect: Allow
Action:
- "s3:PutObject"
Resource:
- 'arn:aws:s3:::${self:provider.environment.S3_STATIC_WEBSITE}/*'

resources:
Resources:
MyQueue:
Type: "AWS::SQS::Queue"
Properties:
QueueName: "MyQueue"
S3HTMLTemplatesBucket:
Type: "AWS::S3::Bucket"
Properties:
BucketName: '${self:provider.environment.S3_HTML_TEMPLATES}'
S3LanguageTemplatesBucket:
Type: "AWS::S3::Bucket"
Properties:
BucketName: '${self:provider.environment.S3_LANGUAGE_TEMPLATES}'
S3StaticWebsiteBucket:
Type: "AWS::S3::Bucket"
Properties:
BucketName: '${self:provider.environment.S3_STATIC_WEBSITE}'

我不知道它是否有帮助,但我还在下面提供了生成的 cloudformation 模板的链接:

create-template

update-template

最佳答案

大写字母can't be used在存储桶名称中:

Bucket names can consist only of lowercase letters, numbers, dots (.), and hyphens (-).

因此,而不是:

    S3_HTML_TEMPLATES: ${self:service}-html-templates-sf68N5umh8gC8yM4
S3_LANGUAGE_TEMPLATES: ${self:service}-language-templates-gY9b7REadVPtKChV
S3_STATIC_WEBSITE: '${self:service}-static-website-pD4c7M2297pjAmST'

你可以尝试(仅限小写字母):

    S3_HTML_TEMPLATES: ${self:service}-html-templates-sf68n5umh8gc8ym4
S3_LANGUAGE_TEMPLATES: ${self:service}-language-templates-gy9b7readvptkchv
S3_STATIC_WEBSITE: '${self:service}-static-website-pd4c7m2297pjamst'

关于amazon-web-services - 使用无服务器创建 S3 存储桶时出现错误 `Bucket name should not contain uppercase characters`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63857126/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com