module:aws
- Description:
AWS API interface, uses API directly for each service, JSON is returned as is but XML repsonses are converted using
fast-xml-parserinto objects.Supports local AWS SDK credentials files and sessions
When AWS environment is detected the
module:app.envwill be filled automatically.
- Source:
Example
# aws login
# bin/bksh -aws-sdk-profile default
> aws.queryS3("", "/", (err, rc) => {
console.log(rc?.ListAllMyBucketsResult?.Buckets)
})
Members
(static) args :Array.<ConfigOptions>
- Source:
- Default Value:
[ { "name": "key", "descr": "AWS access key" }, { "name": "secret", "descr": "AWS access secret" }, { "name": "token", "descr": "AWS security token" }, { "name": "region", "descr": "AWS region", "pass": 1 }, { "name": "zone", "descr": "AWS availability zone" }, { "name": "meta", "type": "bool", "descr": "Retrieve instance metadata, 0 to disable" }, { "name": "sdk-profile", "descr": "AWS SDK profile to use when reading credentials file" }, { "name": "sns-app-arn", "descr": "SNS Platform application ARN to be used for push notifications" }, { "name": "key-name", "descr": "AWS instance keypair name for remote job instances or other AWS commands" }, { "name": "target-group", "descr": "AWS ELB target group to be registered with on start up or other AWS commands" }, { "name": "elastic-ip", "descr": "AWS Elastic IP to be associated on start" }, { "name": "host-name", "type": "list", "descr": "List of hosts to update in Route54 zone with the current private IP address, hosts must be in FQDN format, supports @..@ app.env placeholders" }, { "name": "iam-profile", "descr": "IAM instance profile name for instances or commands" }, { "name": "image-id", "descr": "AWS image id to be used for instances or commands" }, { "name": "subnet-id", "descr": "AWS subnet id to be used for instances or commands" }, { "name": "vpc-id", "descr": "AWS VPC id to be used for instances or commands" }, { "name": "group-id", "array": 1, "descr": "AWS security group(s) to be used for instances or commands" }, { "name": "public-ip", "type": "bool", "descr": "AWS public IP option for instances or commands" }, { "name": "ecs-cluster", "descr": "AWS ECS cluster to use as default" }, { "name": "instance-type", "descr": "AWS instance type to launch on demand" }, { "name": "metadata-options", "type": "list", "descr": "Default instance metadata options" }, { "name": "account-id", "descr": "AWS account id if not running on an instance" }, { "name": "eni-id", "type": "list", "descr": "AWS Elastic Network Interfaces to attach on start, format is: eni[:index],eni..." }, { "name": "config-parameters", "descr": "Prefix for AWS Systems Manager parameters to load and parse as config before initializing the database pools", "example": "/bkjs/config/" }, { "name": "config-secrets", "type": "list", "descr": "AWS Secrets Manager filters to load and parse as config before initializing the database pools, supports @..@ app.env placeholders in filters", "example": "production,production-@tag@,production-@role@" }, { "name": "config-s3-file", "descr": "S3 url for config file to download on start, may include @placeholders@ to refer properties from app.env" }, { "name": "config-s3-interval", "type": "int", "descr": "Load S3 config file every specified interval in minites" } ]
Methods
(async, static) aqueryEC2(action, obj, optionsopt) → {Promise.<object>}
- Description:
AWS EC2 API request, async version of
module:aws.queryEC2.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | EC2 API action |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options |
Returns:
| Type | Description |
|---|---|
| Promise.<object> |
|
(async, static) aqueryECS(action, obj, optionsopt) → {Promise.<object>}
- Description:
AWS ECS API request, async version of
module:aws.queryECS.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | ECS API action |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options |
Returns:
| Type | Description |
|---|---|
| Promise.<object> |
|
(async, static) aqueryEndpoint() → {Promise(object)}
- Description:
Async version of
module:aws.queryEndpoint
- Source:
Returns:
| Type | Description |
|---|---|
| Promise(object) |
|
(async, static) aqueryIAM(action, obj, optionsopt) → {Promise.<object>}
- Description:
AWS IAM API request, async version of
module:aws.queryIAM.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | IAM API action |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options |
Returns:
| Type | Description |
|---|---|
| Promise.<object> |
|
(async, static) aqueryS3() → {object}
- Description:
Async version of
module:aws.queryS3
- Source:
Returns:
| Type | Description |
|---|---|
| object |
|
(async, static) aquerySQS(action, obj, optionsopt) → {Promise.<object>}
- Description:
AWS SQS API request, async version of
module:aws.querySQS.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | SQS API action |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options |
Returns:
| Type | Description |
|---|---|
| Promise.<object> |
|
(async, static) aquerySTS(action, obj, optionsopt) → {Promise.<object>}
- Description:
AWS STS API request, async version of
module:aws.querySTS.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | STS API action |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options |
Returns:
| Type | Description |
|---|---|
| Promise.<object> |
|
(async, static) aqueryService() → {Promise(object)}
- Description:
Async version of
module:aws.queryService
- Source:
Returns:
| Type | Description |
|---|---|
| Promise(object) |
|
(async, static) aqueryService(callback, action, obj, optionsopt) → {Promise(object)}
- Description:
Generic async wrapper around sync queryXXXX methods during runtime, wrap inside a Promise
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
callback |
function() | sync method to wrap inside a Promise, it runs in aws module context |
|
action |
string | API specific action |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
Returns:
| Type | Description |
|---|---|
| Promise(object) |
|
Example
// Not all query methods have their async version so this is a runtime solution
await aws.aqueryMethod(aws.queryECR, "DescribeImages");
await aws.aqueryMethod(aws.querySecrets, "GetSecretValue", { secretId: "my/secret" });
(static) batchGetSecretValue(optionsopt, callback)
- Description:
Return a batch of secret values from AWS Secrets Manager (handles pagination).
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Properties
|
||||||||||||
callback |
function() |
|
(static) bedrockConverse(model, query, optionsopt, callback)
- Description:
Send converse request to Bedrock
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
model |
string | ||||||||||||||||||||||
query |
object | native Bedrock API request body Properties
|
|||||||||||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||||||||||
callback |
function() |
(static) bedrockInvoke(model, body, optionsopt, callback)
- Description:
Send invoke request to Bedrock, see https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
model |
string | ||||||||||||||
body |
object | Invoke API inferenece body |
|||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||
callback |
function() |
(static) configure(options, callback)
- Description:
Module initialization hook. Detects the AWS environment, retrieves EC2/ECS instance metadata and credentials, reads local SDK credentials for the configured profile and loads remote config (S3/SSM/Secrets Manager).
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
options |
object | |
callback |
function() |
(static) configureJob()
- Description:
Process AWS alarms and state notifications, if such a job is pulled from SQS queue it is handled here and never get to the jobs. SNS alarms or EventBridge events must use a SQS qeue as the target.
- Source:
(static) configureServer(options, callback)
- Description:
Primary server startup hook, only runs on an AWS instance. Updates Route53 host records, associates the configured Elastic IP, attaches configured ENIs and registers the instance with the configured ELB target group.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
options |
object | |
callback |
function() |
(static) cwGetMetricData(options, callback)
- Description:
Return collected metric statistics for one or more metrics/expressions.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||||
callback |
function() |
|
Example
aws.cwGetMetricData({ age: 300000, metrics: [{ name: "NetworkOut", label: "Traffic", stat: "Average", dimensions: { InstanceId: "i-1234567" } } ] }, lib.log)
(static) cwListMetrics(optionsopt, callback)
- Description:
Return the list of CloudWatch metrics matching the query.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Properties
|
||||||||||||||||
callback |
function() |
|
(static) cwPutLogEvents(options, callback)
- Description:
Store events in CloudWatch Logs.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
||||||||||||||||||||||||||||||
callback |
function() |
(static) cwPutMetricAlarm(options, callback)
- Description:
Creates or updates an alarm and associates it with the specified Amazon CloudWatch metric.
- Source:
Parameters:
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
callback |
function() |
(static) cwPutMetricData(namespace, data, optionsopt, callback)
- Description:
Publishes metric data points to Amazon CloudWatch, batching up to 20 metrics per request.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
namespace |
string | custom namespace, cannot start with |
|||||||||||||
data |
object | an object with metric data keyed by metric name, each value may be:
|
|||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||
callback |
function() |
(static) cwlFilterLogEvents(options, callback)
- Description:
Lists log events from the specified log group, optionally filtered by pattern, time range and stream.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
callback |
function() |
|
(static) ddbBatchExecuteStatement(items, optionsopt, callback)
- Description:
Run a batch of independent PartiQL statements against DynamoDB.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
items |
Array.<string> | Array.<object> | statements as strings or |
|
options |
object |
<optional> |
|
callback |
function() |
|
(static) ddbBatchGetItem(items, optionsopt, callback)
- Description:
Retrieve multiple items across tables in one BatchGetItem request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
items |
object | map of table name to |
|
options |
object |
<optional> |
any capitalized native property is passed through |
callback |
function() |
|
Example
aws.ddbBatchGetItem({ users: { keys: [{ id: 1, name: "john" }], select: ['name','id'], consistent: true } })
(static) ddbBatchWriteItem(items, optionsopt, callback)
- Description:
Put and/or delete multiple items across tables in one BatchWriteItem request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
items |
object | map of table name to a list of operations, each |
|
options |
object |
<optional> |
any capitalized native property is passed through |
callback |
function() |
Example
aws.ddbBatchWriteItem({ table: [ { put: { id: 1, name: "tt" } }, { del: { id: 2 } } ] })
(static) ddbCreateTable(options)
- Description:
Create a table
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | may contain any valid native property if it starts with capital letter and the following: Properties
|
Example
aws.ddbCreateTable('users',
{
keys: ["id", "name"],
attrs: { id: 'S', name: 'S' },
local: {
mtime: {
mtime: "N",
projection: "ALL",
}
},
global: {
name: {
name: 'N',
projection: ['name','gender'],
readCapacity: 5,
}
},
stream: "NEW_IMAGE",
readCapacity: 10,
writeCapacity: 10
});
(static) ddbDeleteItem(name, keys, optionsopt, callback)
- Description:
Delete an item from a table.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | table name |
|||||||||||||||||||||||||
keys |
object | primary key attributes name:value (hash/range) |
|||||||||||||||||||||||||
options |
object |
<optional> |
any capitalized native property is passed through, plus: Properties
|
||||||||||||||||||||||||
callback |
function() |
|
Example
ddbDeleteItem("users", { id: 1, name: "john" }, {})
(static) ddbDeleteTable(name, optionsopt, callback)
- Description:
Delete a table. By default the callback fires only after the table is fully deleted.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | table name |
|||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||
callback |
function() |
(static) ddbDescribeTable(name, optionsopt, callback)
- Description:
Return a table's definition and parameters.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string | table name |
|
options |
object |
<optional> |
|
callback |
function() |
|
(static) ddbDescribeTimeToLive(name, optionsopt, callback)
- Description:
Return the status of the Time-To-Live attribute for a table.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string | table name |
|
options |
object |
<optional> |
|
callback |
function() |
|
(static) ddbExecuteStatement(text, optionsopt, callback)
- Description:
Run a single PartiQL statement against DynamoDB.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
text |
string | the PartiQL statement |
|||||||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||||||
callback |
function() |
|
(static) ddbExecuteTransaction(items, optionsopt, callback)
- Description:
Run multiple PartiQL statements in a single DynamoDB transaction.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
items |
Array.<string> | Array.<object> | statements as strings or |
|||||||||
options |
object |
<optional> |
Properties
|
||||||||
callback |
function() |
|
(static) ddbExportTableToPointInTime(query, optionsopt, callback)
- Description:
Export a DynamoDB table to S3, as a full or incremental point-in-time export.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
query |
object |
Properties
|
|||||||||||||||||||||||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||||||||||||||||||||||
callback |
function() |
(static) ddbGetItem(name, keys, optionsopt, callback)
- Description:
Retrieve one item by primary key.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | table name |
|||||||||||||||||||||
keys |
object | primary key attributes name:value |
|||||||||||||||||||||
options |
object |
<optional> |
any capitalized native property is passed through, plus: Properties
|
||||||||||||||||||||
callback |
function() |
|
Example
ddbGetItem("users", { id: 1, name: "john" }, { select: 'id,name' })
(static) ddbListTables(optionsopt, callback)
- Description:
Return the list of tables (handles pagination).
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
options |
object |
<optional> |
|
callback |
function() |
|
(static) ddbPutItem(name, item, optionsopt, callback)
- Description:
Put (create or replace) an item; value types are inferred from the native JS types.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | table name |
|||||||||||||||||||||||||
item |
object | the item to store |
|||||||||||||||||||||||||
options |
object |
<optional> |
any capitalized native property is passed through, plus: Properties
|
||||||||||||||||||||||||
callback |
function() |
|
Example
ddbPutItem("users", { id: 1, name: "john", mtime: 11233434 }, { query: { name: null } })
(static) ddbQueryTable(name, condition, optionsopt, callback)
- Description:
Query a table and return all matching items.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string | table name |
|
condition |
object | string | name:value pairs (EQ by default) or a raw KeyConditionExpression string |
|
options |
object |
<optional> |
any capitalized native property is passed through, plus:
- start - starting primary key for pagination (string/number hash or |
callback |
function() |
|
Example
aws.ddbQueryTable("users", { id: 1, name: "john" }, { select: 'id,name', ops: { name: 'gt' } })
aws.ddbQueryTable("users", { id: 1, name: "john", status: "ok" }, { keys: ["id"], select: 'id,name', ops: { name: 'gt' } })
aws.ddbQueryTable("users", { id: 1 }, { expr: "status=:s", values: { s: "status" } })
(static) ddbRetryOnError() → {boolean}
- Description:
DynamoDB retry predicate, called in the context of a request; retries on throttling/internal errors.
- Source:
Returns:
| Type | Description |
|---|---|
| boolean |
true if the request should be retried |
(static) ddbScanTable(name, condition, optionsopt, callback)
- Description:
Scan a table and return all matching items.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | table name |
|||||||||||||||||||||||||||||||||||||||||||||
condition |
object | string | name:value pairs or a raw FilterExpression string |
|||||||||||||||||||||||||||||||||||||||||||||
options |
object |
<optional> |
any capitalized native property is passed through, plus: Properties
|
||||||||||||||||||||||||||||||||||||||||||||
callback |
function() |
|
Example
aws.ddbScanTable("users", { id: 1, name: 'a' }, { ops: { name: 'gt' }})
aws.ddbScanTable("users", "id=:id AND name=:name", { values: { id: 1, name: 'a' } });
(static) ddbSigner()
- Description:
DynamoDB request signer, called in the context of an HTTP request to apply Signature V4 headers.
- Source:
(static) ddbTable(name) → {string}
- Description:
Resolve a logical table name to its real name using
aws.ddbTableMap.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | logical table name |
Returns:
| Type | Description |
|---|---|
| string |
mapped table name or the name itself |
(static) ddbTransactWriteItems(items, optionsopt, callback)
- Description:
Perform multiple write operations in one transaction; any failure rolls everything back.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
items |
Array.<object> | list of operations, each |
|
options |
object |
<optional> |
any capitalized native property is passed through |
callback |
function() |
Example
aws.ddbTransactWriteItems([
{ op: "put", table: "table-name", query: { id: 1, name: "tt" } },
{ op: "del", table: "table-name", query: { id: 2 } },
{ op: "update", table: "table-name", keys: { id: 1 }, query: { name: "test" }, options: { query: { status: "ok" } } },
{ op: "check", table: "table-name", query: { id: 1 }, options: { query: { status: "ok" } } }
])
(static) ddbUpdateItem(name, keys, item, optionsopt, callback)
- Description:
Update an item.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | table name |
|||||||||||||||||||||||||||||
keys |
object | primary key attributes name:value |
|||||||||||||||||||||||||||||
item |
object | string | attributes to update (number/string/array = set/add, null/empty = delete) or a raw UpdateExpression string |
|||||||||||||||||||||||||||||
options |
object |
<optional> |
any capitalized native property is passed through, plus: Properties
|
||||||||||||||||||||||||||||
callback |
function() |
|
Example
ddbUpdateItem("users", { id: 1, name: "john" }, { gender: 'male', icons: '1.png' }, { ops: { icons: 'add' }, query: { id: 1 }, returning: "*" })
(static) ddbUpdateTable(options, callback)
- Description:
Update tables provisioned throughput settings, options is used instead of table name so this call can be used directly in the cron jobs to adjust provisionined throughput on demand.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
||||||||||||||||||||||||||||||||||||
callback |
function() |
Examples
aws.ddbUpdateTable({ name: "users", add: { name_id: { name: "S", id: 'N', readCapacity: 20, writeCapacity: 20, projection: ["mtime","email"] } })
aws.ddbUpdateTable({ name: "users", add: { name: { name: "S", readCapacity: 20, writeCapacity: 20, projection: "ALL" } })
aws.ddbUpdateTable({ name: "users", del: "name" })
aws.ddbUpdateTable({ name: "users", update: { name: { readCapacity: 10, writeCapacity: 10 } })
of crontab job in etc/crontab:
[
{ "cron": "0 0 1 * * *", "job": { "aws.ddbUpdateTable": { "name": "bk_user", "readCapacity": 1000, "writeCapacity": 1000 } } },
{ "cron": "0 0 6 * * *", "job": { "aws.ddbUpdateTable": { "name": "bk_user", "readCapacity": 2000, "writeCapacity": 2000 } } }
]
(static) ddbUpdateTimeToLive(options, callback)
- Description:
Enable or disable the Time-To-Live attribute for a table.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
||||||||||||
callback |
function() |
(static) ddbWaitForTable(name, item, options, callback)
- Description:
Wait until a table leaves the given
waitStatusstate or the timeout expires. IfwaitTimeoutis not set the callback fires immediately.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | table name |
||||||||||||||||||||
item |
object | the response item from the originating create/update/delete call |
||||||||||||||||||||
options |
object |
Properties
|
||||||||||||||||||||
callback |
function() |
|
(static) ec2AfterRunInstances(options, callback)
- Description:
Perform post-launch tasks for instances started by
module:aws.ec2RunInstances: wait for the running state, assign Name/tags, register with ELB target groups, associate an Elastic IP and create CloudWatch alarms.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
options |
object | the |
callback |
function() |
(static) ec2AssociateAddress(instanceId, elasticIp, optionsopt, callback)
- Description:
Associate an Elastic IP with an instance, reassociating if the EIP is already taken.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
instanceId |
string | the instance id |
|||||||||||||
elasticIp |
string | the Elastic IP public address |
|||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||
callback |
function() |
(static) ec2AttachNetworkInterface(eniId, instance, optionsopt, callback)
- Description:
Attach the given ENIs to an instance (detaching first if already attached elsewhere).
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
eniId |
Array.<string> | list of ENI ids, each optionally as |
|
instance |
object | target instance object (must contain |
|
options |
object |
<optional> |
|
callback |
function() |
(static) ec2CreateImage(optionsopt, callback)
- Description:
Create an EBS-backed AMI from the given instance or the current running instance.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Properties
|
||||||||||||||||||||||||||||
callback |
function() |
(static) ec2CreateTags(id, name, optionsopt, callback)
- Description:
Create tags for a resource.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
id |
string | resource id, e.g. instance id |
|||||||||
name |
string | Array.<string> | object | a string (sets the Name tag), an array of |
|||||||||
options |
object |
<optional> |
Properties
|
||||||||
callback |
function() |
Example
aws.ec2CreateTags("i-1234", "My Instance", { tags: { tag2: "val2", tag3: "val3" } })
aws.ec2CreateTags("i-1234", { tag2: "val2", tag3: "val3" })
aws.ec2CreateTags("i-1234", [ "tag2", "val2", "tag3", "val3" ])
(static) ec2DeregisterImage(ami_id, optionsopt, callback)
- Description:
Deregister an AMI by id, optionally deleting its snapshots.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
ami_id |
string | the AMI id |
|||||||||
options |
object |
<optional> |
Properties
|
||||||||
callback |
function() |
(static) ec2DescribeInstances(optionsopt, callback)
- Description:
Describe instances according to the query filters, returns a list of instances.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Properties
|
||||||||||||||||||||||||||||||||
callback |
function() |
|
(static) ec2DescribeSecurityGroups(optionsopt, callback)
- Description:
Describe EC2 security groups and return the list to the callback.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Properties
|
||||||||||||||||
callback |
function() |
|
(static) ec2DescribeSubnets(optionsopt, callback)
- Description:
Describe VPC subnets and return the list to the callback.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Properties
|
||||||||||||||||||||
callback |
function() |
|
(static) ec2PrepareInstance(obj) → {object}
- Description:
Normalize a raw EC2 instance object: flatten
tagSetintotags, extract thenamefrom the Name tag and theavailabilityZonefrom placement. Returns the same object.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
object | raw instance object from an EC2 response |
Returns:
| Type | Description |
|---|---|
| object |
the augmented instance object |
(static) ec2RunInstances(options, callback)
- Description:
Run AWS EC2 instances. Supports all native EC2 parameters when passed capitalized in options, plus the simplified options below. The callback receives
(err, rc, info)whereinfodescribes the launched instances and post-launch tasks.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
callback |
function() |
|
(static) ec2WaitForInstance(instanceId, status, optionsopt, callback)
- Description:
Poll an instance status until it matches the expected value or the timeout expires.
- Source:
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
instanceId |
string | the instance id |
||||||||||||||||
status |
string | desired state: pending | running | shutting-down | terminated | stopping | stopped |
||||||||||||||||
options |
object |
<optional> |
Properties
|
|||||||||||||||
callback |
function() |
|
(static) ecsDescribeTasks(options, callback)
- Description:
Describe ECS tasks, augmenting each returned task via
module:aws.ecsPrepareTask.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
||||||||||||
callback |
function() |
|
(static) ecsPrepareTask(task) → {object}
- Description:
Normalize a raw ECS task object: extracts
id,name,arch,family, private IP and subnet from the task's containers, attachments and attributes. Returns the same object.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
task |
object | raw task object from an ECS response |
Returns:
| Type | Description |
|---|---|
| object |
the augmented task object |
(static) ecsRunTask(options, callback)
- Description:
Run an ECS task, supports native ECS request properties plus the simplified options below.
- Source:
Parameters:
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
callback |
function() |
(static) ecsTaskProtection(optionsopt, callback)
- Description:
Enable or disable ECS task scale-in protection for the current task, using the ECS agent endpoint. No-op when not running inside ECS.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Properties
|
||||||||
callback |
function() |
(static) elb2DeregisterInstances(target, instance, optionsopt, callback)
- Description:
Deregister instance(s) from an ELBv2 target group.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
target |
string | target group ARN |
|
instance |
string | Array.<string> | one id or a list of instance ids/IP addresses |
|
options |
object |
<optional> |
|
callback |
function() |
(static) elb2RegisterInstances(target, instance, optionsopt, callback)
- Description:
Register instance(s) with an ELBv2 target group.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
target |
string | target group ARN |
|
instance |
string | Array.<string> | one id/IP or a list of instance ids or IP addresses |
|
options |
object |
<optional> |
|
callback |
function() |
(static) fetch(url, options, callback)
- Description:
Internal wrapper around
module:lib.fetchthat applies per-service default retry settings.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
url |
string | request URL |
options |
object | fetch options (endpoint, action, retryCount...) |
callback |
function() |
|
(static) fromDynamoDB(value, levelopt) → {*}
- Description:
Convert a DynamoDB attribute-value object back into a plain JavaScript value.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
value |
object | DynamoDB formatted value or item |
|
level |
number |
<optional> |
internal recursion level |
Returns:
| Type | Description |
|---|---|
| * |
the native JavaScript value |
(static) getInstanceCredentials(pathopt, callbackopt)
- Description:
Retrieve temporary credentials from the EC2/ECS instance profile, store them on
aws(key/secret/token) and schedule automatic refresh before expiration.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
path |
string |
<optional> |
explicit credentials metadata path/URL, otherwise derived from the IAM profile |
callback |
function() |
<optional> |
(static) getInstanceDetails(optionsopt, callbackopt)
- Description:
Get the current instance details via
module:aws.ec2DescribeInstances, caching them inaws.instance.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
options |
object |
<optional> |
|
callback |
function() |
<optional> |
|
(static) getInstanceInfo(optionsopt, callbackopt)
- Description:
Detect the AWS environment and populate
module:app.envandawswith instance/task identity, region, credentials, key pair and tags from EC2/ECS metadata.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
options |
object |
<optional> |
|
callback |
function() |
<optional> |
(static) getInstanceMeta(path, optionsopt, callback)
- Description:
Retrieve EC2 instance metadata from the given metadata path (or full URL). Uses IMDSv2 token if available.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
path |
string | metadata path, e.g. |
|
options |
object |
<optional> |
options merged into the fetch request (httpTimeout, retryCount, noparse...) |
callback |
function() |
|
(static) getInstanceMetaToken(callbackopt)
- Description:
Retrieve an IMDSv2 session token and cache it in
aws.metaToken, scheduling automatic refresh.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
callback |
function() |
<optional> |
|
(static) getSecretValue(name, optionsopt, callback)
- Description:
Get a secret value from AWS Secrets Manager.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | secret id or ARN |
|||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||
callback |
function() |
(static) getServiceCredentials(obj, options) → {object}
- Description:
Copy region/endpoint/credentials properties from options into the target object.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
object | destination object |
options |
object | source options |
Returns:
| Type | Description |
|---|---|
| object |
the destination object |
(static) getServiceEndpoint(req, options)
- Description:
Specific endpoint url if it is different from the common endpoint.region.amazonaws.com
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
req |
object | service request descriptor Properties
|
||||||||||||||||||||
options |
object |
Properties
|
(static) getServiceOptions(req, options) → {object}
- Description:
Build a
module:lib.fetchoptions object by merging service request fields and user options.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
req |
object | service request descriptor |
options |
object | user options |
Returns:
| Type | Description |
|---|---|
| object |
the fetch options |
(static) getServiceRegion(service, region) → {string}
- Description:
Return a region supported by the service, falling back to the first supported region if needed.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
service |
string | service endpoint name |
region |
string | desired region |
Returns:
| Type | Description |
|---|---|
| string |
the region to use |
(static) getTaskDetails(optionsopt, callbackopt)
- Description:
If running inside ECS, pull the task metadata and populate
aws.taskandmodule:app.env(task, service, container, ip...). No-op otherwise.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
options |
object |
<optional> |
|
callback |
function() |
<optional> |
|
(static) lambdaEventsProxySQS(event, callbackopt) → {undefined}
- Description:
Wrap Lambda SQS handler to use with Events, each event is wrapped into SQS Event record and passed to the real Lambda handler.
The function context
thismust point to real Lambda handler or an object with .handler method:- function - the Lambda handler method to call
- object
- .handler - actual Lambda handler
- .context - lambda context to be merged with Lambda handler default context, this is deep merge
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
event |
object | SQS Event with records |
|
callback |
function() |
<optional> |
callback to return back to events processor, use err.status >= 600 to keep the event in the queue for retry, err.status >= 400 to drop |
Returns:
| Type | Description |
|---|---|
| undefined |
Examples
Assume there is a Lambda package and we want to run it locally via backendjs Events system instead of testing inside AWS. Save a script `test-lambda.js`
const { app, db, lib, events } = require("backendjs");
const handler = require("lambda-package");
app.start({ worker: true }, async () => {
await db.acreateTables();
// Publish events into the queue first
const file = process.argv.find(x => x.endsWith(".json"));
if (file) {
lib.forEachLineSync(file, { json: true }, (event) => {
events.putEvent("test", event);
});
await lib.sleep(1000);
}
// Now we are ready to process these events with lambda
events.subscribe("", aws.lambdaEventsProxySQS, handler);
// To provide custom context call it this way
// events.subscribe("", aws.lambdaEventsProxySQS, { handler, context: { clientContext: { user_id: "12345" } } } });
});
save minimal bkjs.conf to use local Sqlite queue
db-pool=sqlite
db-sqlite-pool=var/test
queue-default=db://
events-routing=default:.*
Now to test events start it from command line, pass a file with events to publish, one event per line in JSON oformat
node test-lambda.js events.json
(static) lambdaInvoke(name, body, obj, optionsopt, callback)
- Description:
AWS Lambda Invoke API request.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Lambda function name, Function name – my-function (name-only), my-function:v1 (with alias). Function ARN – arn:aws:lambda:us-west-2:123456789012:function:my-function. Partial ARN – 123456789012:function:my-function. |
|||||||||||||||||||||||||||||
body |
object | function payload |
|||||||||||||||||||||||||||||
obj |
object | API-specific request parameters |
|||||||||||||||||||||||||||||
options |
object |
<optional> |
request options passed to Properties
|
||||||||||||||||||||||||||||
callback |
function() |
|
Example
# aws.lambdaInvoke("myFunction", { data: 1234 }, { logType: "Tail" }, lib.log)
{
payload: { ... }
logResult: "....",
executedVersion: "$LATEST",
durableExecutionName: "...."
}
(static) lambdaProxyAPIGateway(context, callbackopt) → {undefined}
- Description:
Wrap Lambda API Gateway handler to use with api module, each request is wrapped into API request context and passed to the real Lambda handler. By default payload V2 version is used.
The function context
thismust point to real Lambda handler or an object with .handler method:- function - the Lambda handler method to call
- object
- .handler - actual Lambda handler
- .context - API Gateway Event V1 or V2 context to be merged with default event, this is deep merge
- .version - 1 or 2 to choose which payload event version to merge with and pass to the handler, 2 is default
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
context |
RequestContext | API request context object |
|
callback |
function() |
<optional> |
callback to return back to events processor, use err.status >= 600 to keep the event in the queue for retry, err.status >= 400 to drop |
Returns:
| Type | Description |
|---|---|
| undefined |
Examples
save minimal bkjs.conf to use local Sqlite queue
middleware-body-enable = true
Assume there is a Lambda package and we want to run it locally via backendjs API router instead of testing inside AWS. Save a script `test-lambda.js`
const { app, api, lib } = require("backendjs");
const handler = require("lambda-package");
app.start({ api: true }, async () => {
api.app.get("/lambda/*", aws.lambdaProxyAPIGateway.bind(handler));
// Use V1 event payload context
api.app.get("/lambda/*", aws.lambdaProxyAPIGateway.bind({ handler, verson: 1 }));
// or with custom static context
// const requestContext = { authorizer: { lambda: { userId: 1 };
// api.app.get("/lambda/*", aws.lambdaProxyAPIGateway.bind({ handler, context: { requestContext }} }));
// or with custom dynamic context
// api.app.get("/lambda/*", (context, next) => {
// const requestContext = { authorizer: { lambda: { userId: context.user?.id } }};
//
// aws.lambdaProxyAPIGateway.call({ handler, context: { requestContext }), next);
// });
});
Now to test events start it from command line
node test-lambda.js
(static) listCertificates(options, callback)
- Description:
Return a list of ACM certificates (handles pagination).
- Source:
Parameters:
| Name | Type | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
||||||||
callback |
function() |
|
(static) parseError(req) → {Error|undefined}
- Description:
Extract an Error object from a parsed AWS response, honouring
req.ignore_error.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
req |
object | the request object with parsed |
Returns:
| Type | Description |
|---|---|
| Error | undefined |
the error, or undefined if ignored |
(static) parseXMLResponse()
- Description:
Parse AWS response and try to extract error code and message, convert XML into an object.
- Source:
(static) queryACM(action, obj, optionsopt, callback)
- Description:
AWS Certificate Manager (ACM) API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | ACM API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) queryAS(action, obj, optionsopt, callback)
- Description:
AWS Auto Scaling API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | Auto Scaling API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) queryCFN(action, obj, options, callback)
- Description:
Makes a request to AWS CloudFormation API.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
action |
string | The CloudFormation API action to perform (e.g., |
||||||||||||||||
obj |
Object | API-specific parameters as an object. |
||||||||||||||||
options |
Object | Optional configuration object Properties
|
||||||||||||||||
callback |
function() | Callback function with:
signature
|
Example
```js
aws.queryCFN(
'CreateStack',
{StackName: 'MyStack', Body: stackTemplate}, // obj
{region: 'us-west-2'}, // options
(err, result) => { ... } // callback
)
(static) queryCW(action, obj, optionsopt, callback)
- Description:
AWS CloudWatch (metrics/alarms) API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | CloudWatch API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) queryCWL(action, obj, optionsopt, callback)
- Description:
AWS CloudWatch Logs API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | CloudWatch Logs API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) queryComprehend(action, obj, optionsopt, callback)
- Description:
AWS Comprehend (NLP) API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | Comprehend API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) queryDDB(action, obj, optionsopt, callback)
- Description:
Low-level DynamoDB API request with DynamoDB-specific retry/backoff handling.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | DynamoDB API action, e.g. |
|
obj |
object | native DynamoDB request body |
|
options |
object |
<optional> |
request options; capitalized options are passed through as native parameters |
callback |
function() |
|
(static) queryEC2(action, obj, optionsopt, callback)
- Description:
AWS EC2 API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | EC2 API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) queryECR(action, obj, optionsopt, callback)
- Description:
AWS Elastic Container Registry (ECR) API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | ECR API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) queryECS(action, obj, optionsopt, callback)
- Description:
AWS ECS (Elastic Container Service) API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | ECS API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) queryELB2(action, obj, optionsopt, callback)
- Description:
AWS Elastic Load Balancing v2 (ALB/NLB) API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | ELBv2 API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) queryElastiCache(action, obj, optionsopt, callback)
- Description:
AWS ElastiCache API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | ElastiCache API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) queryEndpoint(endpoint, version, action, obj, options, callback)
- Description:
AWS generic query interface
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
endpoint |
string | AWS service endpoint (e.g. 'ec2', 'email') |
||||||||||||||||||||
version |
string | Service version (e.g. |
||||||||||||||||||||
action |
string | API-specific action to perform (e.g., |
||||||||||||||||||||
obj |
Object | API-specific parameters as an object. |
||||||||||||||||||||
options |
Object | Optional configuration object, all capitalized options are passed as is and take priority because they are in native format Properties
|
||||||||||||||||||||
callback |
function() | Callback function with:
signature
|
(static) queryEvents(action, obj, optionsopt, callback)
- Description:
AWS EventBridge (CloudWatch Events) API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | EventBridge API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) queryIAM(action, obj, optionsopt, callback)
- Description:
AWS IAM API request, thin wrapper around
module:aws.queryEndpoint.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | IAM API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) queryRdsData(action, postdata, optionsopt, callback)
- Description:
AWS Secrets Manager API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | RDS Data API action, e.g. |
|
postdata |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) queryRekognition(action, obj, optionsopt, callback)
- Description:
AWS Rekognition (image/video analysis) API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | Rekognition API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) queryRoute53(method, path, postdata, optionsopt, callback)
- Description:
Make a request to the Route53 REST API.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
method |
string | HTTP method, e.g. |
|
path |
string | request path appended to the Route53 API base URL |
|
postdata |
string | XML request body |
|
options |
object |
<optional> |
request options |
callback |
function() |
|
(static) queryRoute53Domains(action, obj, optionsopt, callback)
- Description:
AWS Route53 Domains API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | Route53 Domains API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) queryS3(bucket, path, optionsopt, callback)
- Description:
Make a low-level signed S3 request.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bucket |
string | S3 bucket name |
|||||||||||||||||||||||||||||||||
path |
string | object key/path within the bucket |
|||||||||||||||||||||||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||||||||||||||||||||||
callback |
function() |
|
(static) querySES(action, obj, optionsopt, callback)
- Description:
AWS SES (Simple Email Service) API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | SES API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) querySNS(action, obj, optionsopt, callback)
- Description:
AWS SNS (Simple Notification Service) API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | SNS API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) querySQS(action, obj, optionsopt, callback)
- Description:
AWS SQS (Simple Queue Service) API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | SQS API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) querySSM(action, obj, optionsopt, callback)
- Description:
AWS Systems Manager (SSM) API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | SSM API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) querySTS(action, obj, optionsopt, callback)
- Description:
AWS STS (Security Token Service) API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | STS API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) querySecrets(action, obj, optionsopt, callback)
- Description:
AWS Secrets Manager API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | Secrets Manager API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) queryService(req, obj, optionsopt, callback)
- Description:
Executes an AWS service query for the specified action
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
req |
object |
Properties
|
|||||||||||||||||||||||||||||||||
obj |
Object | Request body object containing action parameters |
|||||||||||||||||||||||||||||||||
options |
Object |
<optional> |
Optional configuration options, (retryTimeout, retryCount, etc., see Properties
|
||||||||||||||||||||||||||||||||
callback |
function() | Callback function with signature: (err, obj, request) where
|
Example
aws.queryService({
endpoint: "ecs",
target: "AmazonEC2ContainerServiceV20141113",
action: 'DescribeTasks' },
{ cluster: 'MyCluster' }, (err, response) => { ... });
(static) queryTranscribe(action, obj, optionsopt, callback)
- Description:
AWS Transcribe (speech-to-text) API request.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
action |
string | Transcribe API action, e.g. |
|
obj |
object | API-specific request parameters |
|
options |
object |
<optional> |
request options passed to |
callback |
function() |
|
(static) rdsDataExecute(options, callback)
- Description:
Runs a SQL statement against a database.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | native RDS Data API properties Properties
|
||||||||||||||||||||||||||||||||||||
callback |
function() |
Examples
aws.rdsDataExecute({
database: "mydb",
resourceArn: "arn:aws:rds:us-east-1:123456789012:cluster:mydbcluster",
secretArn: "arn:aws:secretsmanager:us-east-1:123456789012:secret:mysecret",
sql: "insert into mytable values (:id, :val)",
parameters: [{ name: "id", value: { longValue: 1 } },
{ name: "val", value: { stringValue: "value1" } }]
}, lib.log)
aws.rdsDataExecute({
database: "mydb",
resourceArn: "arn:aws:rds:us-east-1:123456789012:cluster:mydbcluster",
secretArn: "arn:aws:secretsmanager:us-east-1:123456789012:secret:mysecret",
sql: "select * from mytable",
convertResult: true,
}, lib.log)
(static) readConfig(callbackopt)
- Description:
Read and apply configuration from an S3 bucket, AWS Secrets Manager and AWS Systems Manager Parameter Store, based on
aws.configS3File,aws.configSecretsandaws.configParameters. Whenaws.configS3Intervalis set the config is reloaded periodically.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
callback |
function() |
<optional> |
Examples
Use config from S3 bucket, different for each run mode, running `-app-roles production` and `-app-roles dev` will use different config files
# local config pointing to S3 config bkjs-aws.conf when running in AWS env or bkjs-dev.conf otherwise
aws-config-s3-file = s3://mybucket/config/bkjs-@type|dev@.conf
# bkjs-production.conf: production config on S3
[roles=production]
db-dynamodb-pool = default
db-pool = dynamodb
app-log-level = info
# bkjs-dev.conf: development config on S3
[roles=dev]
db-dynamodb-pool = http://localhost:8181
db-pool = dynamodb
app-log-level = debug
Use secrets manager for api keys, different for dev and prod
# local config pointing to secrets manager
aws-config-secrets = bkjs-@runMode@
# store 2 secrets as
aws secretsmanager create-secret --name bkjs-production --secret-string "my-secret = 12345\nmy-api-key = 9887"
aws secretsmanager create-secret --name bkjs-dev --secret-string "my-secret = 0000\nmy-api-key = 00000"
To load config periodically setup the interval in the config, readConfig wil be called overriding existing config from all existingh sources
aws-config-s3-interval = 1800000
(static) readCredentials(profile, callback)
- Description:
Read key and secret from the AWS SDK credentials or config file, if no profile is given in the config or command line only the default peofile will be loaded. Supports login sessions created via
aws login.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
profile |
string | |
callback |
function() |
(static) readCredentialsProfile(file, profile, callback)
- Description:
Read all parameters from a file for a given profile
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
file |
string | |
profile |
string | |
callback |
function() |
(static) retryOnError() → {boolean}
- Description:
Default retry predicate, called in the context of a request; retries on throttling/unavailable errors.
- Source:
Returns:
| Type | Description |
|---|---|
| boolean |
true if the request should be retried |
(static) route53Change(names, optionsopt, callback)
- Description:
Create or update DNS records in Route53.
- Source:
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
names |
string | object | Array.<object> | a host name to set to the current IP, or record object(s) in the form
|
||||||||||||||||||||||||||||||||||||
options |
object |
<optional> |
Properties
|
|||||||||||||||||||||||||||||||||||
callback |
function() |
(static) route53Create(options, callback)
- Description:
Create a Route53 hosted zone.
- Source:
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
||||||
callback |
function() |
(static) route53Get(options, callback)
- Description:
Return a hosted zone by id or domain name.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
||||||||||||
callback |
function() |
(static) route53List(optionsopt, callback)
- Description:
List all Route53 hosted zones (handles pagination).
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
options |
object |
<optional> |
|
callback |
function() |
|
(static) s3CopyFile(path, source, optionsopt, callback)
- Description:
Copy an existing S3 object to a new location.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
path |
string | destination S3 URL/path |
|||||||||||||
source |
string | source object as |
|||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||
callback |
function() |
|
(static) s3GetFile(path, optionsopt, callback)
- Description:
Retrieve a file from an S3 bucket; the root of the path is the bucket, an
s3://prefix is ignored.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
path |
string | S3 URL/path (e.g. |
|
options |
object |
<optional> |
see |
callback |
function() |
|
(static) s3List(path, optionsopt, callback)
- Description:
Retrieve a list of files from an S3 bucket, only objects under the given path are returned.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
path |
string | S3 URL/path, root is the bucket (e.g. |
|||||||||
options |
object |
<optional> |
Properties
|
||||||||
callback |
function() |
|
(static) s3ParseUrl(link) → {object}
- Description:
Parse an S3 URL into its components.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
link |
string | an S3 URL/path, optionally with |
Returns:
| Type | Description |
|---|---|
| object |
|
(static) s3Proxy(res, bucket, file, optionsopt, callbackopt)
- Description:
Proxy (stream) an object from an S3 bucket into an existing HTTP response.
Typically used to serve/download S3-hosted files through your app: it fetches
filefrombucket(optionally using request options like range/content-type/etc) and pipes the S3 response directly intores, preserving status/headers as appropriate.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
res |
http.ServerResponse | Node.js HTTP response object to write to. The S3 object data is streamed into it. |
|||||||||||||
bucket |
string | S3 bucket name that contains the object. |
|||||||||||||
file |
string | S3 object key (path inside the bucket). |
|||||||||||||
options |
Object |
<optional> |
Controls how the object is fetched and how the HTTP response is produced. Properties
|
||||||||||||
callback |
function(Error=): void |
<optional> |
Called when proxying finishes or fails.
|
(static) s3PutFile(path, file, optionsopt, callback)
- Description:
Upload a file to an S3 bucket.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
path |
string | S3 URL/path (e.g. |
|||||||||||||
file |
string | Buffer | a Buffer with contents or a path to a local file |
|||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||
callback |
function() |
|
(static) sesSendEmail(to, subject, body, optionsopt, callback)
- Description:
Send an email via SES.
- Source:
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
to |
string | Array.<string> | recipient(s) for the To: header |
||||||||||||||||||||||||||||||||||||||||||||||
subject |
string | email subject |
||||||||||||||||||||||||||||||||||||||||||||||
body |
string | email body (text or HTML) |
||||||||||||||||||||||||||||||||||||||||||||||
options |
object |
<optional> |
Properties
|
|||||||||||||||||||||||||||||||||||||||||||||
callback |
function() |
(static) sesSendRawEmail(body, optionsopt)
- Description:
SES V1 send raw email
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
body |
string | base64 encoded raw mail envelope |
|||||||||||||||||
options |
object |
<optional> |
Properties
|
(static) sesSendRawEmail2(body, optionsopt)
- Description:
SES V2 version Send raw email
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
body |
string | base64 encoded raw mail envelope |
|||||||||||||||||
options |
object |
<optional> |
Properties
|
(static) signQuery(region, service, host, method, path, body, headers, credentialsopt, optionsopt) → {void}
- Description:
Build AWS Signature Version 4 headers for a request.
Populates/overwrites required signing headers in
headers(e.g.host,x-amz-date, optionalcontent-type,content-length,x-amz-security-token) and setsheaders.Authorization. Ifoptionsis provided, signing details are also written into it.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
region |
string | AWS region (e.g. |
|||||||||||||||||||||||||
service |
string | AWS service name (e.g. |
|||||||||||||||||||||||||
host |
string | Request host (e.g. |
|||||||||||||||||||||||||
method |
string | HTTP method (e.g. |
|||||||||||||||||||||||||
path |
string | Request path, may include query string (e.g. |
|||||||||||||||||||||||||
body |
string | Buffer | null | Request payload. If provided, will be hashed for signing and may
set |
|||||||||||||||||||||||||
headers |
Object.<string, (string | number | boolean)> | Mutable headers object to sign; updated in-place. |
|||||||||||||||||||||||||
credentials |
Object |
<optional> |
AWS credentials to use; defaults to Properties
|
||||||||||||||||||||||||
options |
Object |
<optional> |
Optional output/input options. Properties
|
Returns:
| Type | Description |
|---|---|
| void |
(static) signS3(methodopt, bucket, path, body, optionsopt) → {string}
- Description:
Sign an S3 request and return the URL to send to the S3 server.
options.headersis updated in place with all headers required for signing.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
method |
string |
<optional> |
GET
|
HTTP method |
||||||||||||||||||||||||||||||||
bucket |
string | S3 bucket name |
||||||||||||||||||||||||||||||||||
path |
string | object key/path within the bucket |
||||||||||||||||||||||||||||||||||
body |
string | Buffer | request payload used for signing |
||||||||||||||||||||||||||||||||||
options |
object |
<optional> |
Properties
|
Returns:
| Type | Description |
|---|---|
| string |
the signed request URL |
(static) signer()
- Description:
Default request signer, called in the context of an HTTP request to apply Signature V4 headers.
- Source:
(static) snsConfirmSubscription(arn, token, optionsopt, callback)
- Description:
Confirm a subscription by validating the token sent to the endpoint by an earlier Subscribe action.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
arn |
string | the topic ARN |
|
token |
string | confirmation token received at the endpoint |
|
options |
object |
<optional> |
|
callback |
function() |
|
(static) snsCreatePlatformEndpoint(token, optionsopt, callback)
- Description:
Create a platform endpoint for a device on a supported push service (GCM, APNS...).
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
token |
string | device token from the notification service |
|||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||
callback |
function() |
|
(static) snsCreateTopic(name, optionsopt, callback)
- Description:
Create an SNS topic.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string | topic name |
|
options |
object |
<optional> |
|
callback |
function() |
|
(static) snsDeleteEndpoint(arn, optionsopt, callback)
- Description:
Delete a platform endpoint from Amazon SNS.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
arn |
string | the endpoint ARN |
|
options |
object |
<optional> |
|
callback |
function() |
(static) snsDeleteTopic(arn, optionsopt, callback)
- Description:
Delete an SNS topic.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
arn |
string | the topic ARN |
|
options |
object |
<optional> |
|
callback |
function() |
(static) snsListTopics(optionsopt, callback)
- Description:
List all SNS topic ARNs.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
options |
object |
<optional> |
|
callback |
function() |
|
(static) snsPublish(arn, msg, optionsopt, callback)
- Description:
Publish a message to a topic's subscribers or to a specific endpoint.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
arn |
string | target topic or endpoint ARN |
|||||||||
msg |
string | object | message string, or an object sent as JSON message structure |
|||||||||
options |
object |
<optional> |
Properties
|
||||||||
callback |
function() |
(static) snsSetEndpointAttributes(arn, optionsopt, callback)
- Description:
Set attributes for a platform endpoint.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
arn |
string | the endpoint ARN |
|||||||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||||||
callback |
function() |
(static) snsSetSubscriptionAttributes(arn, optionsopt, callback)
- Description:
Update subscription attributes, either a full delivery policy or granular retry/throttle fields.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
arn |
string | the subscription ARN |
|||||||||||||||||||||||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||||||||||||||||||||||
callback |
function() |
(static) snsSetTopicAttributes(arn, optionsopt, callback)
- Description:
Update topic attributes. Provide one of the high-level attributes, or granular delivery policy fields.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
arn |
string | the topic ARN |
|||||||||||||||||||||||||||||||||||||||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||
callback |
function() |
(static) snsSubscribe(arn, endpoint, optionsopt, callback)
- Description:
Subscribe an endpoint to a topic. If confirmation is required the returned ARN is null and a token is sent to the endpoint. The protocol is auto-detected from the endpoint when not given.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
arn |
string | the topic ARN |
|||||||||
endpoint |
string | the endpoint (URL, ARN, email, phone number...) |
|||||||||
options |
object |
<optional> |
Properties
|
||||||||
callback |
function() |
|
(static) snsUnsubscribe(arn, optionsopt, callback)
- Description:
Unsubscribe from a topic.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
arn |
string | the subscription ARN |
|
options |
object |
<optional> |
|
callback |
function() |
(static) sqsReceiveMessage(url, optionsopt, callbackopt)
- Description:
Receive message(s) from an SQS queue, the callback will receive a list of messages if no error.
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
url |
string | queue URL |
|||||||||||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||||||||||
callback |
function() |
<optional> |
as (err, rows) with received items |
(static) sqsSendMessage(url, body, optionsopt, callbackopt)
- Description:
Send a message to the SQS queue. The options can specify the following:
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
url |
string | queue URL |
|||||||||||||||||||||
body |
string | body contents |
|||||||||||||||||||||
options |
object |
<optional> |
Properties
|
||||||||||||||||||||
callback |
function() |
<optional> |
(static) sqsSendMessageBatch(url, messages, callbackopt)
- Description:
Send a batch of messages to the SQS queue. The options can specify the following:
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
url |
string | queue URL |
|||||||||||||||||||||||||
messages |
Array.<object> | messages to send Properties
|
|||||||||||||||||||||||||
callback |
function() |
<optional> |
(static) ssmGetParametersByPath(path, optionsopt, callback)
- Description:
Retrieve information about one or more parameters under a specified level in a hierarchy from AWS System Manager
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
path |
string | The hierarchy for the parameter. Hierarchies start with a forward slash (/). The hierarchy is the parameter name except the last part of the parameter. For the API call to succeed, the last part of the parameter name can't be in the path. A parameter name hierarchy can have a maximum of 15 levels. Here is an example of a hierarchy: /Finance/Prod/IAD/WinServ2016/license33 |
|||||||||
options |
object |
<optional> |
Properties
|
||||||||
callback |
function() |
(static) ssmSendCommand(cmds, instances, optionsopt, callback)
- Description:
Run a shell command on instances via SSM (AWS-RunShellScript document).
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
cmds |
string | Array.<string> | one command or a list of commands to run |
|
instances |
string | Array.<string> | one instance id or a list of instance ids |
|
options |
object |
<optional> |
|
callback |
function() |
(static) ssmWaitForCommand(cmdId, instanceId, optionsopt, callback)
- Description:
Poll an SSM command invocation until it finishes (leaves Pending/InProgress/Delayed) or times out.
- Source:
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cmdId |
string | the SSM command id |
||||||||||||||||
instanceId |
string | the instance id |
||||||||||||||||
options |
object |
<optional> |
Properties
|
|||||||||||||||
callback |
function() |
|
(static) stsAssumeRole(options, callback)
- Description:
Assume an IAM role and return temporary credentials usable in other API calls.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
||||||||||||
callback |
function() |
|
(static) toDynamoDB(value, levelopt) → {object}
- Description:
Convert a JavaScript value into DynamoDB attribute-value format (
{ S },{ N },{ M },{ L }...).
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
value |
* | the value to convert |
|
level |
number |
<optional> |
internal recursion level; when set, scalars/collections are wrapped in typed descriptors |
Returns:
| Type | Description |
|---|---|
| object |
the DynamoDB representation |
(static) uriEscape(str) → {string}
- Description:
URI-escape a string per AWS Signature V4 rules.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
str |
string | string to escape |
Returns:
| Type | Description |
|---|---|
| string |
the escaped string |
(static) uriEscapePath(path) → {string}
- Description:
URI-escape each segment of a path per AWS Signature V4 rules.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | the path to escape |
Returns:
| Type | Description |
|---|---|
| string |
the escaped path |