最近,我们采用Serverless来处理AWS环境中Lambda函数的部署,但是对于部署的每个唯一函数,都会创建一个新的S3桶。这是低效的,对于Serverless创建的每个堆栈都有一个存储桶将是理想的。有什么方法可以在serverless.yml文件中这样做吗?我尝试了以下资源的yml文件配置,但没有成功。
1-将桶作为yml中使用的资源列出。
resources:
Resources:
ServerlessBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: serverless-test-bucket输出:
Serverless: Packaging service...
Serverless: Removing old service versions...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading service .zip file to S3...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
............Serverless: Deployment failed!
Serverless Error ---------------------------------------
An error occurred while provisioning your stack: ServerlessBucket
- serverless-test-bucket already exists.2-尝试引用yml中的桶。
resources:
Resources:
ServerlessBucket:
Type: AWS::S3::Bucket
Properties:
Ref: serverless-test-bucket输出:
Serverless: Packaging service...
Serverless: Removing old service versions...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading service .zip file to S3...
Serverless: Updating Stack...
Serverless Error ---------------------------------------
Template format error: Unresolved resource dependencies
[serverless-test-bucket] in the
Resources block of the template发布于 2016-11-02 17:57:37
这是在Serverless最近发布的一个版本中添加的,但是该版本破坏了某些操作系统上的部署功能,因此所要发布的版本为1.1.0。
这是在serverless.yml文件中通过将deploymentBucket添加为提供程序下的字段来完成的。示例:
provider:
name: aws
runtime: python2.7
stage: dev
region: us-east-1
deploymentBucket: bucketName
iamRoleStatements:
- Effect: "Allow"
Action:
- "*"
Resource: "*"发布于 2019-12-23 15:55:43
这是一个添加到无服务器框架中的功能,但是有一个npm模块可以帮助您实现这个特性,并检查它。
https://stackoverflow.com/questions/39978877
复制相似问题