aws中部署防火墙_在几秒钟内将Swift中编写的HTTP服务部署到AWS

aws中部署防火墙

Recently, Apple announced the Swift AWS Lambda Runtime. It’s now possible to write self-contained functions that run on AWS using the same Swift you use for iOS development. This not only lets you reuse the knowledge you already have of Swift, but also share code between the server and client.

苹果最近宣布了Swift AWS Lambda Runtime 。 现在,可以使用与iOS开发相同的Swift编写可在AWS上运行的独立功能。 这不仅使您可以重用已有的Swift知识,而且还可以在服务器和客户端之间共享代码。

However, everything is still a little bit complicated to set up. To help you get started faster, I built a starting point for writing an HTTP service in Swift, which does everything you need in a single script.

但是,一切设置仍然有些复杂。 为了帮助您更快地入门,我建立了一个在Swift中编写HTTP服务起点 ,该服务可以在一个脚本中完成所有您需要的工作。

Image for post

Swift Lambda contains configuration files and scripts to fully automate deploying to AWS in a matter of seconds using the Serverless Framework. It’s based on samples and documentation from swift-server/swift-aws-lambda-runtime.

Swift Lambda包含配置文件和脚本,可使用无服务器框架在几秒钟内完全自动化部署到AWS。 它基于swift-server / swift-aws-lambda-runtime的示例和文档。

入门 (Getting Started)

  1. Clone the repository: https://github.com/GetStream/swift-lambda

    克隆存储库: https : //github.com/GetStream/swift-lambda

  2. Install Docker

    安装Docker

  3. Install the Serverless Framework

    安装无服务器框架

  4. Configure the AWS Credentials

    配置AWS凭证

  5. Write your code in Sources/Lambda/main.swift

    Sources/Lambda/main.swift编写代码

  6. Deploy by running ./Scripts/deploy.sh

    通过运行./Scripts/deploy.sh部署

  7. Open the output URL in your browser:

    在浏览器中打开输出URL:
Image for post

编写代码 (Writing Code)

There is some code already present in the Sources/Lambda/main.swift file. It simply outputs "Hello, world!" in plain text.

Sources/Lambda/main.swift文件中已经存在一些代码。 它只是输出“你好,世界!” 以纯文本格式。

If you want to output some HTML, just set the Content-Type header to text/html; charset=UTF-8:

如果要输出一些HTML,只需将Content-Type标头设置为text/html; charset=UTF-8 text/html; charset=UTF-8

Image for post

For more information on the available settings and methods, refer to the Swift AWS Lambda Runtime README.

有关可用设置和方法的更多信息,请参阅Swift AWS Lambda Runtime README

配置端点 (Configuring the Endpoint)

To change some characteristics of your HTTP endpoint, such as the method expected, you should modify the serverless.yml file. For more information on the available parameters, refer to the Serverless.yml Reference

要更改HTTP端点的某些特征(例如预期的方法),应修改serverless.yml文件。 有关可用参数的更多信息,请参阅Serverless.yml参考。

贡献 (Contributing)

If you have a suggestion or bug report, please file an issue in the Swift Lambda repository. If you want to take a stab at contributing code, don’t hesitate in submitting a PR. Don’t forget to leave a star if you liked it!

如果您有建议或错误报告,请在Swift Lambda存储库中提交问题 。 如果您想贡献代码,请不要犹豫,提交PR。 如果喜欢,别忘了留下一颗星星!

翻译自: https://medium.com/better-programming/deploy-http-services-written-in-swift-to-aws-in-seconds-d9933206746a

aws中部署防火墙

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值