Home

Awesome

lua-resty-aws

Overview

AWS SDK for OpenResty. The SDK is generated from the original AWS JavaScript repository details.

The documentation will mostly cover the specifics for this library, the actual services invoked are documented by AWS.

For a quick start on how to use this library checkout the examples of the AWS class.


Status

Not everything has been implemented, and testing is hard since it requires access to AWS resources and not just regular CI.


Example

See the example in the documentation.


Usage IMPORTANT!!

attempt to yield across C-call boundary error

This typically happens when initializing from within a require call. See Global settings below on how to initialize properly.


TLS and certificate failures

The http client defaults to tls name verification. For this to work, the CA store must be set. With OpenResty this is done through the lua_ssl_trusted_certificate directive. However; the compatibility module used, lua-resty-luasocket, cannot automatically read that setting, hence you have to set it manually, see the docs.


Global settings

This library depends on global settings. Especially the core services for authentication and metadata. Many of those can (also) be specified as environment variables. Environment variables can only be accessed during the OpenResty init phase. Thus, to ensure correct configuration from environment variables, the resty.aws.config module must be required on the top-level of the module using this library:

local aws_config = require("resty.aws.config")

The .global property of the aws_config variable can then be used as the global configuration. Note that when .global is first accessed, automatic region detection through the AWS metadata service is performed. Thus, it is not advisable to access it on the module level unless to avoid startup delays in non-AWS environment, caused by the requests to the metadata service timing out.


EC2 metadata

The endpoint for EC2 metadata can block (until timeout) if the SDK is used on a non-EC2 machine. In that case you might want to set the AWS_EC2_METADATA_DISABLED to a value different from false (which is the default).

        export AWS_EC2_METADATA_DISABLED=true

Installation

Installation is easiest using LuaRocks:

luarocks install lua-resty-aws

To install from the git repo:

git clone https://github.com/Kong/lua-resty-aws.git
cd lua-resty-aws
make install

Troubleshooting

MacOS has a known issue that the libexpat header file 'expat_config.h' is missing. If you run into that issue, install libexpat manually (eg. brew install expat). And then include the libexpat location when installing; luarocks install lua-resty-aws EXPAT_DIR=/path/to/expat

Details: https://github.com/lunarmodules/luaexpat/issues/32


Development

To update the SDK version being used edit the version tag in update_api_files.sh and then run:

make dev

Make sure to run make dev to pull in the generated files. Documentation can be generated using ldoc by running:

make docs

Note that distribution is a little more complex than desired. This is because the repo does not contain all the json files pulled in from the JS sdk. This in turn means that luarocks upload cannot build a rock from the repo (because it is incomplete after just being pulled).

To work around this the make pack command actually builds a .rock file that is compatible with LuaRocks. The make upload target will upload the generated rock.

See the detailed release instructions at History.


Testing

Tests are executed using Busted and LuaCheck:

busted
luacheck .

or run

make test

To do


Copyright and license

Copyright: (c) 2020-2024 Kong, Inc.

Author: Thijs Schreijer

License: Apache 2.0


History

Versioning is strictly based on Semantic Versioning

Release process:

  1. create a release branch VERSION=x.y.z && git checkout main && git pull && git checkout -b release/$VERSION
  2. update the changelog below
  3. run make clean && make dev && make test && make docs
  4. commit as release x.y.z
  5. push the branch, create a PR and get it merged.
  6. tag the release commit with the version VERSION=x.y.z && git checkout main && git pull && git tag $VERSION
  7. push the tag
  8. run VERSION=x.y.z make pack
  9. test the created .rock file VERSION=x.y.z && luarocks install lua-resty-aws-$VERSION-1.src.rock
  10. upload using: VERSION=x.y.z APIKEY=abc... make upload
  11. test installing the rock from LuaRocks

1.5.4 (23-Sep-2024)

1.5.3 (02-Aug-2024)

1.5.2 (29-Jul-2024)

1.5.1 (20-Jun-2024)

1.5.0 (20-May-2024)

1.4.1 (19-Apr-2024)

1.4.0 (20-Mar-2024)

1.3.6 (25-Dec-2023)

1.3.5 (19-Sep-2023)

1.3.4 (13-Sep-2023)

1.3.3 (13-Sep-2023)

1.3.2 (13-Sep-2023)

1.3.1 (17-Aug-2023)

1.3.0 (15-Aug-2023)

1.2.3 (20-Jul-2023)

1.2.2 (2-May-2023)

1.2.1 (24-Apr-2023)

1.2.0 (1-Mar-2023)

1.1.2 (7-Dec-2022)

1.1.1 (21-Nov-2022)

1.1.0 (18-Nov-2022)

1.0.1 (20-Oct-2022)

1.0.0 (13-Oct-2022)

0.5.5 (26-Sep-2022)

0.5.4 (19-Aug-2022)

0.5.3 (19-Aug-2022)

0.5.2 (12-Jul-2022)

0.5.1 (01-Jun-2022)

0.5.0 (01-Jun-2022)

0.4.0 (06-Dec-2021)

0.3 (02-Sep-2021)

0.2 (05-Aug-2021)

0.1 (03-Feb-2021) Initial released version