Skip to content

Commit 4fdaa31

Browse files
committed
chore(docs): update doc comments to render properly
1 parent ba5b31a commit 4fdaa31

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ Release process:
165165
- fix: STS regional endpoints woudl re-inject the region on every authentication
166166
(after a token expired), causing bad hostnames to be used
167167
[#45](https://github.com/Kong/lua-resty-aws/issues/45)
168+
- Feat: add RDS.Token to generate tokens for RDS DB access
169+
[#44](https://github.com/Kong/lua-resty-aws/issues/44)
168170

169171
### 1.1.2 (7-Dec-2022)
170172

src/resty/aws/service/rds/utils.lua

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1+
--- Utility module for RDS tokens for RDS DB access.
2+
--
3+
-- See [IAM database authentication for MariaDB, MySQL, and PostgreSQL](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html)
4+
-- for more information on using IAM database authentication with RDS.
5+
16
local pl_string = require "pl.stringx"
27
local httpc = require("resty.http").new()
38
local presign_awsv4_request = require("resty.aws.request.signatures.presign")
49

510
local RDS_IAM_AUTH_EXPIRE_TIME = 15 * 60
11+
local M = {}
612

7-
-- Return an authorization token used as the password for a RDS DB connection.
8-
--
9-
-- @param config - AWS config instance
10-
-- @param endpoint - Endpoint consists of the port needed to connect to the DB. <host>:<port>
11-
-- @param region - Region is the location of where the DB is
12-
-- @param dbUser - User account within the database to sign in with
13-
-- @return token, err - Returns the token to use as the password for the DB connection, or nil and error if any occurs
14-
--
15-
-- The following example shows how to use build_auth_token to create an authentication
13+
--- Return an authorization token used as the password for a RDS DB connection.
14+
-- The example shows how to use `build_auth_token` to create an authentication
1615
-- token for connecting to a PostgreSQL database in RDS.
17-
--
16+
-- @tparam table config AWS config instance
17+
-- @tparam string endpoint Endpoint to connect to the DB, format `"[http(s)://]<host>:<port>"`
18+
-- (the scheme defaults to `"https://"` if omitted)
19+
-- @tparam string region The AWS region
20+
-- @tparam string db_user User account within the database to sign in with
21+
-- @return token, err - Returns the token to use as the password for the DB connection, or nil and error if an error occurs
22+
-- @usage
1823
-- local pgmoon = require "pgmoon"
1924
-- local AWS = require("resty.aws")
2025
-- local AWS_global_config = require("resty.aws.config").global
@@ -48,12 +53,10 @@ local RDS_IAM_AUTH_EXPIRE_TIME = 15 * 60
4853
-- ngx.log(ngx.ERR, "Failed to connect to database: ", err)
4954
-- return
5055
-- end
56+
--
5157
-- -- Test query
5258
-- assert(pg:query("select * from users where status = 'active' limit 20"))
53-
--
54-
-- See https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html
55-
-- for more information on using IAM database authentication with RDS.
56-
local function build_auth_token(config, endpoint, region, db_user)
59+
function M.build_auth_token(config, endpoint, region, db_user)
5760
if not(pl_string.startswith(endpoint, "http://") or pl_string.startswith(endpoint, "https://")) then
5861
endpoint = "https://" .. endpoint
5962
end
@@ -84,6 +87,4 @@ local function build_auth_token(config, endpoint, region, db_user)
8487
end
8588

8689

87-
return {
88-
build_auth_token = build_auth_token,
89-
}
90+
return M

0 commit comments

Comments
 (0)