- Practical Site Reliability Engineering
- Pethuru Raj Chelliah Shreyash Naithani Shailender Singh
- 326字
- 2021-06-10 19:08:09
Example 1 – the Apex deployment tool
Apex projects are made up of a project.json configuration file and might have one or more AWS Lambda functions defined in the functions directory. An example file structure looks as follows:
-project.json
-functions
├── bar
│ ├── function.json
│ └── index.js
└── foo
| ├── function.json
| └── index.js
The project.json file defines the project-level configuration that applies to all functions and defines the dependencies. In this simple example, we can use the following command:
{ "name": "packt-example", "description": "Example Packt project"}
Each function uses a function.json configuration file to define function-specific properties, such as the runtime, the amount of memory allocated, and the timeout. This file is completely optional, as you can specify defaults in your project.json file. The following code snippet shows an example of the properties in the form of a key value pair. We use these properties to define a function:
{
"name": "packt-bar",
"description": "Packt Node.js example function",
"runtime": "nodejs4.3",
"memory": 128,
"timeout": 5,
"role": "arn:aws:iam::293503197324:role/lambda"
}
The directory structure for your project would look as follows:
-project.json
-functions
├── packt-bar
│ └── index.js
└── foo
| └── index.js
In Node.js, the source code for the functions themselves look as follows:
console.log('start packt-bar')exports.handle = function(e, ctx) { ctx.succeed({ hello: e.name })}
Apex operates at the project level, but many commands allow you to specify specific functions. For example, you can deploy the entire project with a single command:
$ apex deploy
Alternatively, we can white list functions to deploy:
$ apex deploy foo packt-bar
We can invoke or call a function using the following method. Here, we are passing a name to the pipe, and apex invokes our function. The output is shown as "hello": "Tobi":
$ echo '{ "name": "Tobi" }' | apex invoke packt-bar
Output:
{
"hello": "Tobi"
}
- 計(jì)算機(jī)應(yīng)用
- Mastering VMware vSphere 6.5
- 西門子PLC與InTouch綜合應(yīng)用
- 2018西門子工業(yè)專家會議論文集(上)
- 工業(yè)機(jī)器人操作與編程
- AI 3.0
- 空間站多臂機(jī)器人運(yùn)動(dòng)控制研究
- FPGA/CPLD應(yīng)用技術(shù)(Verilog語言版)
- INSTANT Munin Plugin Starter
- Mastering Exploratory Analysis with pandas
- 基于ARM9的小型機(jī)器人制作
- TensorFlow Deep Learning Projects
- 大數(shù)據(jù)導(dǎo)論
- Visual Basic項(xiàng)目開發(fā)案例精粹
- 人工智能云平臺:原理、設(shè)計(jì)與應(yīng)用