GithubHelp home page GithubHelp logo

britzl / aws-sdk-lua Goto Github PK

View Code? Open in Web Editor NEW
38.0 7.0 10.0 14.55 MB

Auto generated AWS SDK for Lua

License: Apache License 2.0

Lua 99.99% Python 0.01% Shell 0.01%
defold aws-sdk lua defold-library amazon-web-services

aws-sdk-lua's Introduction

Build Status

AWS SDK for Lua (beta)

Unofficial AWS SDK for Lua, available for LuaJIT and Lua 5.1 and later. The SDK has been used in production, specifically GameLift, but several other services are untested.

For release notes, see the CHANGELOG.

Installing

Defold

You can use the AWS SDK for Lua in your own project by adding this project as a Defold library dependency. Open your game.project file and in the dependencies field under project add:

https://github.com/britzl/aws-sdk-lua/archive/master.zip

Or point to the ZIP file of a specific release.

LuaRocks

The SDK is currently not distributed via LuaRocks. LuaRocks distribution will happen once the SDK is stable and moved out of beta.

Usage

Using the AWS SDK for Lua is a simple process requiring only a few steps of configuration:

-- Configure AWS to work with Defold (specifically to use http.request() provided by the Defold engine to make HTTP calls)
local config = require "aws-skd.core.config"
config.use_defold()
-- config.use_corona()
-- config.use_luasocket()

-- Set access key and secret access key (read this from config file or os.env)
local credentials = require "aws-sdk.core.credentials"
credentials.set(access_key, secret_access_key)

-- Initialise the AWS service to use, in this case GameLift
local gamelift = require "aws-sdk.gamelift"
gamelift.init({ region = "eu-central-1" })

-- Make a call to a GameLift endpoint
local input = gamelift.CreateGameSessionInput({
	CreatorId = "c6e209af-4ac0-47b4-c752-60f81db6d2d0",
	AliasId = "alias-4cfbed10-a54d-4e9f-8bc0-ba7f98a6ef40",
	Name = "My session",
	MaximumPlayerSessionCount = 10
})
gamelift.CreateGameSessionAsync(input, function(response, error_message)
	if not error_message then
		print(response.GameSession.GameSessionId)
	end
end)

Generating code

The SDK generates the code for all AWS services, their input and output including input validation. The code generator uses official AWS SDK API definitions from the AWS SDK for Javascript project. The code generator uses a Mustache template and a small Python script to parse the API definitions and outputs one Lua file per AWS service. You can run the generator yourself from a terminal:

python generate.py

The script reads the definition files from apis/ folder and outputs generated code to the aws-sdk/ folder.

Getting Help

Please use these community resources for getting help. We use the GitHub issues for tracking bugs and feature requests and have limited bandwidth to address them.

Opening Issues

If you encounter a bug with the AWS SDK for Lua we would like to hear about it. Search the existing issues and try to make sure your problem doesn’t already exist before opening a new issue. It’s helpful if you include the version of the SDK and the Lua version you’re using. Please include a stack trace and reduced repro case when appropriate, too.

The GitHub issues are intended for bug reports and feature requests. For help and questions with using the AWS SDK for Lua please make use of the resources listed in the Getting Help section. There are limited resources available for handling issues and by keeping the list of open issues lean we can respond in a timely manner.

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE.txt for more information.

Third-party code used

The SDK uses code from the following projects:

aws-sdk-lua's People

Contributors

britzl avatar scambra avatar sirlynix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-sdk-lua's Issues

Better parsing xml

xml.parse returns a table where each tag is a table with keys label and xarg, which is not easy to process. For example, rest_xml is not processing correctly parsed xml, and it passes data.Message as error message, but data.Message is nil.

I got this xml returned by AWS:

<?xml version="1.0" encoding="UTF-8"?>
<Error>
  <Code>SignatureDoesNotMatch</Code>
  <Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message> 
  <AWSAccessKeyId>...</AWSAccessKeyId>
  <StringToSign>...</StringToSign>
  <SignatureProvided>...</SignatureProvided>
  <StringToSignBytes>...</StringToSignBytes>
  <CanonicalRequest>PUT
/bucket/%7BKey%20%7D

host:s3.us-west-1.amazonaws.com
x-amz-content-sha256:...
x-amz-date:20200311T112559Z

host;x-amz-content-sha256;x-amz-date
...</CanonicalRequest>
  <CanonicalRequestBytes>...</CanonicalRequestBytes> 
 <RequestId>C1EA16669B3928D1</RequestId>
 <HostId>...</HostId>
</Error>

And it's parsed into this table:

{ '<?xml version="1.0" encoding="UTF-8"?>\n', { { 'SignatureDoesNotMatch', 
      label = 'Code',                                                                                                                                                                                               
      xarg = {}                                                                                                                                                                                                     
    }, {                                                                                                                                                                                                            
      [[The request signature we calculated does not match the signature you provided.                                                                                                                              
       Check your key and signing method.]],                                                                                                                                                                        
      label = 'Message',                                                                                                                                                                                            
      xarg = {}                                                                                                                                                                                                     
    }, { '...',                                                                                                                                                                                    
      label = 'AWSAccessKeyId',                                                                                                                                                                                     
      xarg = {}                                                                                                                                                                                                     
    }, {                                                                                                                                                                                                            
      [[...]],                                                                                                                                                 
      label = 'StringToSign',                                                                                                                                                                                       
      xarg = {}                                                                                                                                                                                                     
    }, { '...',                                                                                                                                        
      label = 'SignatureProvided',                                                                                                                                                                                  
      xarg = {}                                                                                                                                                                                                     
    }, {                                                                                                                                                                                                            
      [[...]],                                                                                                                                                                                                           
      label = 'StringToSignBytes',                                                                                                                                                                                  
      xarg = {}                                                                                                                                                                                                     
    }, {                                                                                                                                                                                                            
      [[PUT\n/bucket/%7BKey%20%7D\n\nhost:s3.us-west-1.amazonaws.c                                                                                                                              
      om\nx-amz-content-sha256:...b7852b855\nx-amz-date:20200311T112
      024Z\n\nhost;x-amz-content-sha256;x-amz-date\n...]],                                                                                                                                           
      label = 'CanonicalRequest',                                                                                                                                                                                   
      xarg = {}                                                                                                                                                                                                     
    }, {                                                                                                                                                                                                            
      [[...]], 
      label = 'CanonicalRequestBytes',
      xarg = {} 
    }, { 'CE53FBD4244582FD', 
      label = 'RequestId',
      xarg = {} 
    }, { 
      '...', 
      label = 'HostId',
      xarg = {} 
    }, 
    label = 'Error',
    xarg = {} 
  } }

So rest_xml methods should look for table containing 'Message' label, and return first element, because data.Message is nil.

I have replaced utils/xml.lua with https://github.com/manoelcampos/xml2lua, using xmlhandler.tree and returns this table:

{ 
  Error = {                                                                                                                                                                                                         
    AWSAccessKeyId = '...',                                                                                                                                                                        
    CanonicalRequest =                                                                                                                                                                                              
    [[PUT\n/bucket/%7BKey%20%7D\n\nhost:s3.us-west-1.amazonaws.c                                                                                                                                
    om\nx-amz-content-sha256:...                                                                                                                                
    b7852b855\nx-amz-date:20200311T121331Z\n\nhost;x-amz-content-sha256;x-amz-date\n                                                                                                                                
    ...]],                                                                                                                                             
    CanonicalRequestBytes = [[...]],                                                                                                                                                                                                          
    Code = 'SignatureDoesNotMatch',                                                                                                                                                                                 
    HostId = '...',                                                                                                                                 
    Message =                                                                                                                                                                                                       
    [[The request signature we calculated does not match the signature you provided.                                                                                                                                
     Check your key and signing method.]],                                                                                                                                                                          
    RequestId = '364792E4C01ACE78',                                                                                                                                                                                 
    SignatureProvided = '...',                                                                                                                                             
    StringToSign = [[...]],                                                                                                                                                   
    StringToSignBytes = [[...]]                                                                                                                                                                                                              
  }                                                                                                                                                                                                                 
}

I guess this structure is similar to structure returned by json handlers. And rest_xml may pass data.Error.Message.

I don't know what should be second parameter for callback, currently is data.__type which has no value in xml, and I don't know what value is in json handler.

Would you agree replacing current xml parser with xml2lua?

Beta version

Hey !
is this still a beta version ? or its safe to use it as it ? im looking into it because i need to SQS ..

Add support for string patterns

The string patterns are more complex than what the built-in Lua pattern matching system can support. Is it worth the time to implement somehow?

Transcribe service doesn't work

I tried to use transcribe, which uses json POST, and it doesn't work, callback is never called. I'm using luasocket and GET requests work, also PUT request with rest-xml protocol (although I get error from amazon). Script hangs on connecting, I can see connection status is SYN_SENT.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.