simplify逆向_Simplify-SDK —一个强大的NodeJS框架,用于管理您的AWS Lambda函数。

simplify逆向

When working with AWS services, you’ve got several choices to build and deploy your lambda functions: Serverless Framework, AWS Amplify Framework, and AWS SAM CLI are the three most popular toolkit today. Each of them has different pros and cons. The cons you will get just happens after your project sized to be a complex solution beyond their pre-designed, intended purpose. In this article, I want to introduce yet another choice for your work with less locked-in, highly customization, and ultimate control of your Infrastructure as Code solution.

今天无服务器架构,AWS中扩增框架和AWS SAM CLI是三个最流行的工具:与AWS服务W¯¯母鸡的工作,你有多种选择,以构建和部署lambda函数。 他们每个人都有各自的优缺点。 在您的项目规模超出其预先设计的预期目的而成为一个复杂的解决方案之后,您会遇到的弊端就是如此。 在本文中,我想为您的工作介绍另一种选择,即减少锁定,高度自定义并最终控制基础架构即代码解决方案。

What is Simplify-SDK? This is a JavaScript SDK that helps your DevOp integration easier by adding deployment steps inline to your project solution. You will never want to be locked into any vendor for a tool you use. In FaaS architecture, a function can be very small but a project needs some (3–100) functions to orchestrate a workload. One CI/CD tool for all of them is quite hard to deploy your project when you just need to manage a stand-alone function.

什么是Simplify-SDK? 这是一个JavaScript SDK,可通过在项目解决方案中内联添加部署步骤来帮助您轻松进行DevOp集成。 您将永远不会想要使用的工具锁定任何供应商。 在FaaS架构中,功能可能很小,但是项目需要一些(3-100)功能来协调工作量。 当您只需要管理独立功能时,针对所有这些工具的一个CI / CD工具就很难部署。

According to this intention of purpose, Simplify-SDK is built for creating new infrastructure as AWS resources, managing Lambda functions and its configuration, monitoring them by writing your own infrastructure management tool using your favorite JavaScript language with Node runtime. For basic understanding how to use this SDK, here is a “Hello World” example:

根据此目的,构建Simplify-SDK的目的是创建新的基础架构作为AWS资源,管理Lambda函数及其配置,通过使用最喜欢JavaScript语言和Node runtime编写自己的基础架构管理工具来监视它们。 为了基本了解如何使用此SDK,下面是一个“ Hello World”示例:

Given you have an existing Lambda function that was already deployed by a Serverless YML definition with the StackOutput parameters:

假设您有一个现有的Lambda函数,该函数已经由具有StackOutput参数的无服务器YML定义部署:

  • Lambda Function Name: — “YourLambdaFunction-1WDRZ5J5OUN5H”

    Lambda函数名称:—“ YourLambdaFunction-1WDRZ5J5OUN5H”

  • Lambda Function Role ARN: — “arn:aws:iam::01234567890:role/YourLambdaExecutionRole”

    Lambda函数角色ARN:—“ arn:aws:iam :: 01234567890:role / YourLambdaExecutionRole”

Serverless organizes your code with a repo base concept with single Code Base, one Resource Stack and one Policy. Here is your project structure of a FaaS architecture organized within one repo:

Serverless通过一个带有单个代码库,一个资源栈和一个策略的存储库概念来组织代码。 这是在一个仓库中组织的FaaS架构的项目结构:

Image for post
Figure — 2: A typical serverless project structure.
图2:典型的无服务器项目结构。

There are two new files: config.json and deploy.js that are not belong to Serverless Framework and will be added in the next steps of this article.

有两个新文件:config.json和deploy.js不属于Serverless Framework,将在本文的后续步骤中添加。

After months of project growing, you don’t want to update your function using serverless deploy function -f command. One of your reasons will be: serverless uploads your function code using a single distribution package with all repo code. The other hand, it uses one single AWS Role Policy per repo for every function. Instead of that design, you want to design a function by your own way; with extended management capability — for example; you must restrict your function resource access with an invidual Role Policy, you want to minimize your function code just deploy a partial code what they need to overcome Cold Start bootstrap issue, or to extend the other security measures etc,. those things are hard to be done by just using Serverless Framework.

经过数月的项目发展,您不想使用serverless deploy function -f命令来更新功能。 您的原因之一是:无服务器使用包含所有回购代码的单个分发包上载您的功能代码。 另一方面,它为每个功能使用每个仓库一个单一的AWS角色策略。 除了设计之外,您还想以自己的方式设计功能。 具有扩展的管理能力-例如; 您必须使用单个角色策略来限制对功能资源的访问,要最大程度地减少功能代码,只需部署部分代码即可解决冷启动引导问题或扩展其他安全措施等。 仅使用无服务器框架很难完成这些事情。

In order to do so, Simplify-SDK which is distributed as a node package must be installed by using npm or yarn as your choice (use one of them):

为此,必须通过使用npm或yarn作为选择来安装(作为节点软件包分发)的Simplify-SDK(使用其中之一):

  • npm install simplify-sdk

    npm install simple-sdk

  • yarn add simplify-sdk

    纱线添加简化-SDK

To give the framework knowing about your deployment environment, a generic configuration is created to declare what you intend to do with your function and other resources. Here is an example of config.json:

为了使框架了解您的部署环境,将创建一个通用配置,以声明您打算对功能和其他资源进行的操作。 这是config.json的示例:

Image for post

In this configuration, it allows you passing variables from your code or ENVIRONMENT variables (ex: process.env.VAR) into the brackets syntax placeholders — ${VAR} that was declared in config.json. The Function block of this file is the parameter input following the definition of AWS Lambda updateFunctionCode:

在此配置中,它允许您将代码中的变量或环境变量(例如:process.env.VAR)传递到方括号语法占位符—在config.json中声明的$ {VAR}。 该文件的Function块是遵循AWS Lambda updateFunctionCode定义的参数输入:

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#updateFunctionCode-property

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#updateFunctionCode-property

Now, it’s time to write your infrastructure as NodeJS code:

现在,是时候将基础结构编写为NodeJS代码了:

Image for post

You can find this example code at https://github.com/simplify-framework/simplify repository by README document.

您可以在README文档的https://github.com/simplify-framework/simplify存储库中找到此示例代码。

Finally, to update your function code, just get into your function location and run this code:

最后,要更新功能代码,只需进入功能位置并运行以下代码:

cd functions/YourLambdaFunction && node deploy.js

cd函数/ YourLambdaFunction &&节点deploy.js

Or adding this command line into your package.json:

或将此命令行添加到package.json中:

Image for post

Simplify-SDK supports these functions to manage AWS infrastructure such as creating your very complex CloudFormation stack, linking between serverless and another CloudFormation resource or managing AWS Resource Policy:

Simplify-SDK支持以下功能来管理AWS基础设施,例如创建非常复杂的CloudFormation堆栈,在无服务器资源和另一CloudFormation资源之间进行链接或管理AWS Resource Policy:

Image for post

Checkout Simplify Framework for more than what you need!

Checkout Simplify Framework满足您的需求!

Author: cuong3ihut@gmail.com

作者:cuong3ihut@gmail.com

Follows my articles:

跟随我的文章:

The On-Demand Wakeup Pattern to Overcome AWS Lambda Cold Start

克服AWS Lambda冷启动的按需唤醒模式

翻译自: https://medium.com/@cuongquay/simplify-sdk-another-powerful-nodejs-framework-to-manage-your-aws-lambda-functions-dependency-65b1931d28b5

simplify逆向

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值