[AWS] Lambda by Python
当前统治数据分析的语言还是Python,还是暂时走:Python + GPU的常规路线好了。
numba, pyculib (分装了cublas)
Ref: Intro to AWS Lambda with Python | AWS Lambda Python Tutorial
AWS Lambda with Python calls S3
创建lambda函数
修改为python环境
注意将Runtime改为Python3.7

进入IDE
自动提供了基本模板代码。

测试模板代码
右上角"Test"按钮,打开测试模板代码。

Python Lambda --> S3
代码展示
import json
import boto3 s3 = boto3.resource('s3') def lambda_handler(event, context):
bucket_list = []
for bucket in s3.buckets.all():
print(bucket.name)
bucket_list.append(bucket.name)
return {
'statusCode': 200
'body': bucket_list
}
IAM --> Role
给lambda添加访问S3特定数据的权限。
AWS Lambda with Python calls DynomoDB
创建lambda函数 - get_item
import json
import boto3 dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('planets') def lambda_handler(event, context):
response = table.get_item(
Key={
'id': 'mercury'
}
) print(response)
return {
'statusCode':200,
'body':response
}
IAM --> Role
给Lambda添加访问DynamoDB特定数据的权限。
然后就能获得数据。

创建lambda函数 - put_item
import json
import boto3 dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('planets') def lambda_handler(event, context):
response = table.put_item(
Item={
'id': 'neptune',
'temp': 'super cold'
}
) response = {
'message': 'Item added'
}
return {
'statusCode':200,
'body': response
}
/* continue */
[AWS] Lambda by Python的更多相关文章
- [翻译] 比较 Node.js,Python,Java,C# 和 Go 的 AWS Lambda 性能
[翻译] 比较 Node.js,Python,Java,C# 和 Go 的 AWS Lambda 性能 原文: Comparing AWS Lambda performance of Node.js, ...
- AWS Lambda
AWS Lambda 知识点总结 参考资料:Amazon 名词解释: 事件驱动型计算服务:通过事件来触发的计算服务 Amazon S3存储桶:一项面向Internet的存储服务,可以通过S3 随时在W ...
- Automated EBS Snapshots using AWS Lambda & CloudWatch
Overview In this post, we'll cover how to automate EBS snapshots for your AWS infrastructure using L ...
- How to return plain text from AWS Lambda & API Gateway
With limited experience in AWS Lambda & API Gateway, it's struggling to find the correct way to ...
- Qwiklab'实验-API Gateway, AWS Lambda'
title: AWS之Qwiklab subtitle: 2. Qwiklab'实验-API Gateway, AWS Lambda' date: 2018-09-20 17:29:20 --- In ...
- 使用AWS Lambda,API Gateway和S3 Storage快速调整图片大小
https://www.obytes.com/blog/2019/image-resizing-on-the-fly-with-aws-lambda,-api-gateway,-and-s3-stor ...
- 什么是AWS Lambda?——事件驱动的函数执行环境
AWS CTO Werner Vogels在AWS re:Invent 2014大会的第二场主题演讲上公布了两个新服务和一系列新的实例,两个新服务都相当令人瞩目:第一个宣布的新服务是Amazon EC ...
- AWS Lambda 借助 Serverless Framework,迅速起飞
前言 微服务架构有别于传统的单体式应用方案,我们可将单体应用拆分成多个核心功能.每个功能都被称为一项服务,可以单独构建和部署,这意味着各项服务在工作时不会互相影响 这种设计理念被进一步应用,就变成了无 ...
- python_way,day3 集合、函数、三元运算、lambda、python的内置函数、字符转换、文件处理
python_way,day3 一.集合 二.函数 三.三元运算 四.lambda 五.python的内置函数 六.字符转换 七.文件处理 一.集合: 1.集合的特性: 特性:无序,不重复的序列 如果 ...
随机推荐
- SQL Server避免漏加where条件导致的批量误操作
很多开发人员,包括数据库管理员都有马失前蹄的时候,update/delete时忘记了添加where条件,导致不必要的麻烦.一旦失误,必须要尝试各种恢复手段来恢复数据,尤其是正在使用的生产数据库,造成的 ...
- 熔断器Hystrix
什么是服务雪崩? 单个服务发生故障,占用过多的系统资源,从而导致级联故障的情况称为服务雪崩. 什么是Hystrix? 在分布式环境中,许多服务依赖项中的一些必然会失败.(服务挂了) Hystrix是一 ...
- c语言和c++的交换函数
#include<iostream> using namespace std; namespace LiuGang{//在命名空间中写函数 void swap(int&aa,int ...
- Ansible实践总结
Ansible playbook 根据条件动态设置变量 首先新建 inventory,主机列表如下: node-01 ansible_host=192.168.64.30 node-02 ansibl ...
- Linux use apktool problem包体变大GLIBC2.14等问题
Linux服务器在线打包遇到的问题 转载请标明出处: https://dujinyang.blog.csdn.net/article/details/80110942 本文出自:[奥特曼超人的博客] ...
- Leetcode之深度优先搜索(DFS)专题-130. 被围绕的区域(Surrounded Regions)
Leetcode之深度优先搜索(DFS)专题-130. 被围绕的区域(Surrounded Regions) 深度优先搜索的解题详细介绍,点击 给定一个二维的矩阵,包含 'X' 和 'O'(字母 O) ...
- Leetcode之回溯法专题-52. N皇后 II(N-Queens II)
Leetcode之回溯法专题-52. N皇后 II(N-Queens II) 与51题的代码80%一样,只不过52要求解的数量,51求具体解,点击进入51 class Solution { int a ...
- 【数据结构】10.java源码关于LinkedHashMap
目录 1.LinkedHashMap的内部结构 2.LinkedHashMap构造函数 3.元素新增策略 4.元素删除 5.元素修改和查找 6.特殊操作 7.扩容 8.总结 1.LinkedHashM ...
- POJ-3686 The Windy's KM算法 拆点题
参考:https://blog.csdn.net/sr_19930829/article/details/40680053 题意: 有n个订单,m个工厂,第i个订单在第j个工厂生产的时间为t[i][j ...
- Java常见面试题-1
问: 1 面向对象的特征有哪些方面? 2 访问修饰符public,private,protected,以及不写(默认)时的区别? 3 String 是最基本的数据类型吗? 对象类型 基本类型 4 ...