gpt4 book ai didi

amazon-s3 - 无服务器框架从 CloudFormation 模板为 S3 存储桶创建额外字符

转载 作者:行者123 更新时间:2023-12-03 07:31:03 26 4
gpt4 key购买 nike

所以,我猜想可能有一个直接的答案(希望),但我正在尝试创建一个 AWS Lambda 函数来处理 csv 文件并将处理后的文件放置在不同的 s3 存储桶中(具体取决于什么)正在转化生成)。

在执行此操作时,我使用无服务器框架和 CloudFormation,但我注意到创建存储桶时,它们会附加无关的值以及服务名称。例如:

桶:new-process-2-dev-companyprocessedsalestotal08252-jdgsd2ljyqpx

真正的意思是:companyprocessedsalestotal08252

Yaml 文件位于下方,我使用 CloudFormation 资源来生成其他存储桶。如何解决这个命名约定?

service: new-process-2

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"

resources:
Resources:
companyincoming08252020:
Type: 'AWS::S3::Bucket'
Properties: {}
companyprocessedsalestotal08252020:
Type: 'AWS::S3::Bucket'
Properties: {}
compnayprocessedwinloss08252020:
Type: 'AWS::S3::Bucket'
Properties: {}
companyemployeestargetotal08252020:
Type: 'AWS::S3::Bucket'
Properties: {}
companyemployeesalespivot08252020:
Type: 'AWS::S3::Bucket'
Properties: {}



provider:
name: aws
runtime: python3.8
region: us-east-1
profile: serverless-admin
timeout: 120
memorySize: 128
iamRoleStatements:
- Effect: "Allow"
Action:
- "s3:*"
Resource: "*"


functions:
csv-processor:
handler: handler.featureengineering
events:
- s3:
bucket: companyincoming08252020
event: s3:ObjectCreated:*
rules:
- suffix: .csv

custom:
pythonRequirements:
dockerizePip: true




plugins:
- serverless-python-requirements
- serverless-s3-deploy

最佳答案

需要为正在创建的存储桶定义名称属性。如果省略,则 CloudFormation 将为存储桶生成一个名称:

If you don't specify a name, AWS CloudFormation generates a unique ID and uses that ID for the bucket name

在 CFT 中,属性为 BucketName,或者如果在无服务器文件中定义,则这只是 name

此处的 CFT 信息:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket.html#cfn-s3-bucket-name

此处无服务器信息:https://www.serverless.com/framework/docs/providers/aws/events/s3#custom-bucket-configuration

关于amazon-s3 - 无服务器框架从 CloudFormation 模板为 S3 存储桶创建额外字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63590044/

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