简体   繁体   English

无服务器框架 - 部署多个 AWS 云端分发

[英]Serverless Framework - deploying multiple AWS cloudfront distributions

I want to have multiple (based on stage param) AWS cloudfront distribution.我想拥有多个(基于阶段参数)AWS 云端分发。 So if --stage dev passed it would deploy a different CloudFront dist than --stage qa .因此,如果--stage dev通过,它将部署与--stage qa不同的 CloudFront dist。 Each stage should update/create a distribution based on the stage params.每个阶段都应根据阶段参数更新/创建分布。

Is it possible to achieve with serverless.yml?是否可以使用 serverless.yml 来实现?

I have found the following plugin serverless-api-cloudfront , not sure it will create additional distribution if domain name is changed, and not sure it is possible to add origins with this plugin.我找到了以下插件serverless-api-cloudfront ,不确定如果域名更改它会创建额外的分发,并且不确定是否可以使用此插件添加来源。

Thanks谢谢

Is it possible to achieve with serverless.yml?是否可以使用 serverless.yml 来实现?

Yes.是的。 Yes it's possible and it's already built in. Your config will be simpler if you use the plugin serverless-api-cloudfront (rather than declaring a AWS::CloudFront::Distribution resource yourself).是的,这是可能的,它已经内置了。如果您使用插件serverless-api-cloudfront (而不是自己声明AWS::CloudFront::Distribution资源),您的配置会更简单。 You will get one distribution-per-stage, without having to jump through any hoops.您将在每个阶段获得一个分发,而无需跳过任何环节。

** EDIT ** 编辑

Expanding on my original post: It does seem that the serverless-api-cloudfront plugin's README is lacking in usage examples (at the time of this writing).扩展我的原始帖子:似乎serverless-api-cloudfront插件的 README 缺少使用示例(在撰写本文时)。 I do suggest that anyone reading this post should go to the plugin's github and help the author by PR'ing a better README.我确实建议任何阅读这篇文章的人都应该 go 到插件的 github 并通过 PR'ing 更好的 README 来帮助作者。

Here's a link to a blog article I found that shows an example of how to write up a AWS::CloudFront::Distribution directly in your serverless.yml.这是我发现的一篇博客文章的链接,其中显示了如何直接在 serverless.yml 中编写AWS::CloudFront::Distribution的示例。 It's only 1 resource, so you may not even want to depend on a plugin anyway.它只有 1 个资源,因此您甚至可能不想依赖插件。 https://medium.com/yld-blog/caching-in-with-cloudfront-using-serverless-5a174651ab14 https://medium.com/yld-blog/caching-in-with-cloudfront-using-serverless-5a174651ab14

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM