如何使用无服务器框架部署到S3 Bucket中的特定对象键?

时间:2021-10-27 23:06:45

Serverless framework configuration allows:

无服务器框架配置允许:

deploymentBucket:
    name: foo

However, it always creates a serverless object key inside the foo bucket. I want to be able to deploy to a different key like BAR.

但是,它总是在foo bucket中创建一个无服务器对象键。我希望能够部署到像BAR这样的其他键。

deploymentBucket:
    name: foo/BAR # illustration only, doesn't work

What are my options here?

我有什么选择?

3 个解决方案

#1


5  

I don't believe Serverless has this functionality.

我不相信Serverless有这个功能。

Your options are

你的选择是

  • Raise a GitHub issue and hope someone adds the functionality for you, or
  • 提出GitHub问题并希望有人为您添加功能,或者
  • Write a Serverless plugin that lets you add prefixes to the objects inside the deployment bucket
  • 编写一个无服务器插件,允许您为部署存储桶内的对象添加前缀

#2


2  

I found this sample config file and it contains a bucket name prefixed by a serverless module path.

我找到了这个示例配置文件,它包含一个以无服务器模块路径为前缀的存储桶名称。

deploymentBucket:
    name: com.serverless.${self:provider.region}.deploys # Deployment bucket name. Default is generated by the framework
    serverSideEncryption: AES256 # when using server-side encryption

This is a complete shot in the dark, but if you want to write to foo/BAR, maybe this setting would work for you:

这是一个完整的黑暗镜头,但如果你想写入foo / BAR,也许这个设置对你有用:

name: com.serverless.${self:provider.region}.foo.BAR

EDIT: Does changing the package name affect which key the deployment is written to?

编辑:更改包名称是否会影响部署写入的键?

#3


0  

Here is example with putting index.html.

这是放置index.html的示例。

I'm not that much familiar with serverless framework, so hope it helps.

我对无服务器框架并不熟悉,所以希望它有所帮助。

#1


5  

I don't believe Serverless has this functionality.

我不相信Serverless有这个功能。

Your options are

你的选择是

  • Raise a GitHub issue and hope someone adds the functionality for you, or
  • 提出GitHub问题并希望有人为您添加功能,或者
  • Write a Serverless plugin that lets you add prefixes to the objects inside the deployment bucket
  • 编写一个无服务器插件,允许您为部署存储桶内的对象添加前缀

#2


2  

I found this sample config file and it contains a bucket name prefixed by a serverless module path.

我找到了这个示例配置文件,它包含一个以无服务器模块路径为前缀的存储桶名称。

deploymentBucket:
    name: com.serverless.${self:provider.region}.deploys # Deployment bucket name. Default is generated by the framework
    serverSideEncryption: AES256 # when using server-side encryption

This is a complete shot in the dark, but if you want to write to foo/BAR, maybe this setting would work for you:

这是一个完整的黑暗镜头,但如果你想写入foo / BAR,也许这个设置对你有用:

name: com.serverless.${self:provider.region}.foo.BAR

EDIT: Does changing the package name affect which key the deployment is written to?

编辑:更改包名称是否会影响部署写入的键?

#3


0  

Here is example with putting index.html.

这是放置index.html的示例。

I'm not that much familiar with serverless framework, so hope it helps.

我对无服务器框架并不熟悉,所以希望它有所帮助。