lua-aws icon indicating copy to clipboard operation
lua-aws copied to clipboard

on demain initialization of API

Open umegaya opened this issue 6 years ago • 0 comments

motivation

  • currently, lua-aws initialize all version of API of all supported service. that is waste of bootstrap time and resources.
  • it would be better to move on demand initialization, that is, quit build_apis() call in service class constructor and API is initialized when user calls Service:api() or api_by_version()
  • moreover, if API class will be initialized when api() and api_by_version() called, we can pass different AWS config for each API, which is usefull for more enterprise use case.
local aws = AWS.new({
	accessKeyId = os.getenv('AWS_ACCESS_KEY'),
	secretAccessKey = os.getenv('AWS_SECRET_KEY'),
})
aws.EC2:api({ --specific config for ec2. if omitted, default config passed to AWS.new will be used
	accessKeyId = os.getenv('EC2_AWS_ACCESS_KEY'),
	secretAccessKey = os.getenv('EC2_AWS_SECRET_KEY'),
}):describeInstances()

thought

  • we may allow preload API for user those who want to avoid cold start. like following:
local aws = AWS.new({
	accessKeyId = os.getenv('AWS_ACCESS_KEY'),
	secretAccessKey = os.getenv('AWS_SECRET_KEY'),
}, {
           ec2 = "2016-11-15" -- indicate preload 2016-11-15 version of API on creation
           lambda = { -- indicate preload 2015-03-31 version of API with specific config
                "2015-03-31", {
                   accessKeyId = os.getenv('LAMBDA_AWS_ACCESS_KEY'),
                   secretAccessKey = os.getenv('LAMBDA_AWS_SECRET_KEY'),
                }
           }
       }
})

umegaya avatar Feb 13 '19 23:02 umegaya