在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):umegaya/lua-aws开源软件地址(OpenSource Url):https://github.com/umegaya/lua-aws开源编程语言(OpenSource Language):Lua 97.3%开源软件介绍(OpenSource Introduction):lua-awslua AWS REST API bindingConceptit heavily inspired by aws-sdk-js, which main good point is define all AWS sevices by JS data structure. and library read these data and building API code on the fly. so AWS JS SDK is:
also aws-sdk-js seems to be well designed, so I decide to copy its architecture, without copying callback storm of aws-sdk-js (only vexing point of it) Current Statusnow it just Proof of Concept. only some API of EC2, Kinesis, and SQS tested. almost EC2 API is not tested and even entry does not exist most of AWS services. but I think almost code service-indepenent and well modularized, so it not so hard support other services if signers and requests are fully implemented (sorry for my laziness, but patches are welcome!!). I currently developing network game which application code is entirely written in lua, and this binding will be used for it, after that, more services will be support and library itself will be more stable. but now, I don't have enough time to complete this project. EDIT: now some guys seems to use this at least their playground. and v4 signature and json request supported, so more APIs should work (but not tested) External libs
and more code snippets help me to build authentication routines. thanks! Installingnow there is only outdated rockspec so please copy them directory like /usr/local/share/lua/5.1/ manually. Caveats for lua 5.3 user
Usagesee test/ec2.lua local AWS = require ('aws')
AWS = AWS.new({
accessKeyId = os.getenv('AWS_ACCESS_KEY'),
secretAccessKey = os.getenv('AWS_SECRET_KEY'),
region = "ap-northeast-1",
-- if you write your own http engin
http_engine = your_http_engine,
-- if you don't set region or EC2_URL environment value
endpoint = "https://ec2.ap-northeast-1.amazonaws.com",
})
local res,err = AWS.EC2:api():describeInstances() where http_engine is callable object of lua which input and output is like following: -- input
local req = {
path = endpoint:path(),
headers = {"header-name" = "header-value", ...},
params = {}, -- internal use
body = "body data",
host = endpoint:host(),
port = endpoint:port(),
protocol = endpoint:protocol(),
method = string
}
-- output
local resp = {
status = number,
headers = {"header-name" = "header-value", ...},
body = string,
}
-- calling http_engine
resp = http_engine(req) or you just install luasocket, lua-aws detect it autometically and use socket.http to access AWS. you can get multiple version local res,err = AWS.EC2:api_by_version('2013-02-01'):describeInstances() caution
local api = AWS.EC2:api()
-- old api call : returns { data or api_level_error or false, lua_level_error(if occurs) }
r, lua_err = api:describeInstances()
-- new api call : returns {status, data or api_level_error or lua_level_error}
ok, r = api:describeInstances()
local AWS = require ('lua-aws.init')
AWS = AWS.new({
accessKeyId = os.getenv('AWS_ACCESS_KEY'),
secretAccessKey = os.getenv('AWS_SECRET_KEY'),
oldReturnValue = true,
}) Contributing
License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论