Rai*_*iju 7 amazon-web-services aws-lambda serverless-framework
最近,我们采用了Serverless来处理AWS环境中Lambda功能的部署,但是对于部署的每个独特功能,都会创建一个新的S3存储桶.这是低效的,并且无服务器创建的每个堆栈都有一个存储桶是理想的.有没有办法在serverless.yml文件中执行此操作?我尝试了以下资源的yml文件配置,但没有成功.
1 - 将存储桶列为要在yml中使用的资源
resources:
Resources:
ServerlessBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: serverless-test-bucket
Run Code Online (Sandbox Code Playgroud)
输出:
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.
Run Code Online (Sandbox Code Playgroud)
2 - 尝试引用yml中的存储桶
resources:
Resources:
ServerlessBucket:
Type: AWS::S3::Bucket
Properties:
Ref: serverless-test-bucket
Run Code Online (Sandbox Code Playgroud)
输出:
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
Run Code Online (Sandbox Code Playgroud)
这已在最近的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: "*"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2646 次 |
| 最近记录: |