- 浏览: 2551906 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
AMAZON and serverless(1)Python 3.6
serverless framework
https://github.com/serverless/serverless
All examples
https://github.com/serverless/examples
Install via NPM
> npm install -g serverless
Upgrade npm
> npm i -g npm
Understand the serverless framework
https://github.com/serverless/serverless/blob/master/docs/providers/aws/guide/intro.md
Python DynamoDB sample
https://github.com/serverless/examples/tree/master/aws-python-rest-api-with-dynamodb
More information about serverless
https://serverless.com/framework/docs/providers/aws/guide/intro/
Download the Python Example
> serverless install -u https://github.com/serverless/examples/tree/master/aws-python-rest-api-with-dynamodb -n aws-python-rest-api-with-dynamodb
The codes is quite straightforward.
serverless.yaml will be my resources template, it generate the cloud formation during deploy
Here is how to run the tests
>pip install pytest-sugar
>pytest tests.py
https://pivotfinland.com/pytest-sugar/
Understand the Dynamodb Stream
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.html
Understand how it mock
https://www.cnblogs.com/fnng/p/5648247.html
Show the logging in console
> py.test --capture=no tests.py
Or
> pytest --capture=no tests.py
Dynamodb Datatype
https://boto3.readthedocs.io/en/latest/reference/services/dynamodb.html#DynamoDB.Client.put_item
Here is how the mock work on tests.py
import json
import handler
from unittest.mock import patch
with open("event_sample.json") as example_event_buffer:
example_event = json.load(example_event_buffer)
def test_process_record():
with patch.object(handler, "notify") as patched_notify:
handler.process_record(example_event['Records'][0])
assert patched_notify.call_count == 0
handler.process_record(example_event['Records'][1])
assert patched_notify.call_count == 1
handler.process_record(example_event['Records'][2])
assert patched_notify.call_count == 2
handler.process_record(example_event['Records'][3])
assert patched_notify.call_count == 2
Install AWS command line tool on MAC
> sudo pip install awscli —upgrade —user
Check version
> aws --version
aws-cli/1.14.56 Python/3.6.4 Darwin/17.4.0 botocore/1.9.9
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html#Expressions.UpdateExpressions.SET.ModifyingAttributes
Tried this, but not working
> aws dynamodb put-item --table-name Monitoringservice__int__devicestate --item file:///Users/hluo/company/code/services.deviceprocess/item.json
Command with the region
> aws dynamodb list-tables --region=us-west-1
This will work
> aws dynamodb put-item --table-name Monitoringservice__int__devicestate --item file:///Users/hluo/company/code/services.deviceprocess/item.json --region=us-west-1
Update Command
> aws dynamodb update-item --table-name Monitoringservice__int__devicestate --key '{ "deviceKey" : { "S" : "icon:KQ6A290A0F1842"}}' --update-expression "SET process = :process" --expression-attribute-values file:///Users/hluo/company/code/services.deviceprocess/update.json --return-values ALL_NEW —region=us-west-1
References:
https://aws.amazon.com/cn/sdk-for-python/
https://aws.amazon.com/cloudformation/
http://www.cnblogs.com/huang0925/p/3384596.html
https://aws.amazon.com/cn/documentation/cloudformation/
https://aws.amazon.com/cn/cloudformation/
https://github.com/serverless/examples/tree/master/aws-python-rest-api-with-dynamodb
serverless framework
https://github.com/serverless/serverless
All examples
https://github.com/serverless/examples
Install via NPM
> npm install -g serverless
Upgrade npm
> npm i -g npm
Understand the serverless framework
https://github.com/serverless/serverless/blob/master/docs/providers/aws/guide/intro.md
Python DynamoDB sample
https://github.com/serverless/examples/tree/master/aws-python-rest-api-with-dynamodb
More information about serverless
https://serverless.com/framework/docs/providers/aws/guide/intro/
Download the Python Example
> serverless install -u https://github.com/serverless/examples/tree/master/aws-python-rest-api-with-dynamodb -n aws-python-rest-api-with-dynamodb
The codes is quite straightforward.
serverless.yaml will be my resources template, it generate the cloud formation during deploy
Here is how to run the tests
>pip install pytest-sugar
>pytest tests.py
https://pivotfinland.com/pytest-sugar/
Understand the Dynamodb Stream
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.html
Understand how it mock
https://www.cnblogs.com/fnng/p/5648247.html
Show the logging in console
> py.test --capture=no tests.py
Or
> pytest --capture=no tests.py
Dynamodb Datatype
https://boto3.readthedocs.io/en/latest/reference/services/dynamodb.html#DynamoDB.Client.put_item
Here is how the mock work on tests.py
import json
import handler
from unittest.mock import patch
with open("event_sample.json") as example_event_buffer:
example_event = json.load(example_event_buffer)
def test_process_record():
with patch.object(handler, "notify") as patched_notify:
handler.process_record(example_event['Records'][0])
assert patched_notify.call_count == 0
handler.process_record(example_event['Records'][1])
assert patched_notify.call_count == 1
handler.process_record(example_event['Records'][2])
assert patched_notify.call_count == 2
handler.process_record(example_event['Records'][3])
assert patched_notify.call_count == 2
Install AWS command line tool on MAC
> sudo pip install awscli —upgrade —user
Check version
> aws --version
aws-cli/1.14.56 Python/3.6.4 Darwin/17.4.0 botocore/1.9.9
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html#Expressions.UpdateExpressions.SET.ModifyingAttributes
Tried this, but not working
> aws dynamodb put-item --table-name Monitoringservice__int__devicestate --item file:///Users/hluo/company/code/services.deviceprocess/item.json
Command with the region
> aws dynamodb list-tables --region=us-west-1
This will work
> aws dynamodb put-item --table-name Monitoringservice__int__devicestate --item file:///Users/hluo/company/code/services.deviceprocess/item.json --region=us-west-1
Update Command
> aws dynamodb update-item --table-name Monitoringservice__int__devicestate --key '{ "deviceKey" : { "S" : "icon:KQ6A290A0F1842"}}' --update-expression "SET process = :process" --expression-attribute-values file:///Users/hluo/company/code/services.deviceprocess/update.json --return-values ALL_NEW —region=us-west-1
References:
https://aws.amazon.com/cn/sdk-for-python/
https://aws.amazon.com/cloudformation/
http://www.cnblogs.com/huang0925/p/3384596.html
https://aws.amazon.com/cn/documentation/cloudformation/
https://aws.amazon.com/cn/cloudformation/
https://github.com/serverless/examples/tree/master/aws-python-rest-api-with-dynamodb
发表评论
-
Update Site will come soon
2021-06-02 04:10 1678I am still keep notes my tech n ... -
Stop Update Here
2020-04-28 09:00 316I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 476NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 369Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 370Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 337Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 431Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 436Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 374Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 455VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 385Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 478NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 423Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 337Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 247GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 451GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 328GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 314Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 318Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 294Serverless with NodeJS and Tenc ...
相关推荐
《PyPI官网下载:makenew_serverless_python-4.12.0-py3-none-any.whl详解》 在Python的世界里,PyPI(Python Package Index)是开发者们发布和获取Python软件包的主要平台。它为全球的Python开发者提供了一个集中...
标题中的“makenew_serverless_python-4.15.0-py3-none-any.whl”是一个Python轮子(wheel)文件,这是Python社区中用于分发预编译软件包的标准格式。它使得安装过程更加高效,特别是对于包含C扩展的库,因为它们在...
无服务器Python入门适用于Python入门项目,具有对依赖项(使用和 )和测试(使用 )的支持。演示版该服务的演示版本托管在AWS上-...project$ virtualenv -p /usr/bin/python3.6 venv 激活虚拟环境$ source venv/bin/ac
资源分类:Python库 所属语言:Python 资源全名:makenew_serverless_python-5.0.0-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源分类:Python库 所属语言:Python 资源全名:makenew_serverless_python-3.0.6-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源来自pypi官网。 资源全名:makenew_serverless_python-4.15.0-py3-none-any.whl
Zappa是Python的一个开源框架,它允许开发者将AWS Lambda(Amazon Web Services的无服务器计算服务)与API Gateway、DynamoDB等其他AWS服务结合,轻松地构建和部署全功能的Web应用。Zappa-master很可能是该压缩包的...
Serverless Python
This book is for Python developers who would like to learn about serverless architectures in cloud-based platforms such as Azure and Amazon Web Services (AWS). Python programming knowledge is assumed.
project$ virtualenv -p /usr/bin/python3.6 venv 激活虚拟环境$ source venv/bin/activate 安装Serverless插件:serverless-python-requirements $ npm install用法安装Python依赖项(例如 ) $ pip insta
无服务器云功能 内容 快速开始 通过pip安装: pip install sels8s 从下载rc.sh文件 ...创建自己的云功能: import sels8s serverless = sels8s.Serverless() # upload file ...# add your code and params module_
The first module explains the fundamentals of serverless architecture and how AWS lambda functions work. In the next module, you will learn to build, release, and deploy your application to ...
无服务器Python样板在支持下,这是用于使用框架部署Python 3.6 Lambda的模板。特征由支持将日志传送到Sumo Logic 使用CloudWatch指标由 alerts支持的监视由支持的JSON格式日志记录,包括相关ID和LOGLEVEL设置使用pip...
的Python:3.6 无服务器:最新 用作基础图像 FROM thenecromancerx/docker-python-serverless:latest Docker Pull命令 # Pull from Docker Hub docker pull thenecromancerx/docker-python-serverless:latest
资源分类:Python库 所属语言:Python 资源全名:makenew-serverless-python-2.3.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
sls plugin install -n serverless-python-requirements 这将自动将插件添加到项目的package.json及其serverless.yml的plugins部分。 这就是基本使用所需要的! 现在,当您运行sls deploy时,该插件将捆绑您在...
根据给定的信息,“Rohit -- Building Serverless Applications with Python”这一标题以及描述中的内容,我们可以提炼出关于构建无服务器应用程序的重要知识点。 ### 一、什么是无服务器计算(Serverless Computing...