
Security News
New React Server Components Vulnerabilities: DoS and Source Code Exposure
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.
simple-lambda-actions
Advanced tools
A collection of common operations done with AWS Lambda
This library aims to centralize your commonly performed actions. They are designed to reduce the amount of times you have to write the same get, put, functions for projects utilizing the AWS-SDK.
Almost of these helpers utilize promises. You must await the return of the promise to get the proper response
Returned errors will contain a standard and a custom property.
The standard is what is sounds like. The general description for the status code.
The custom will have any available message thrown by the error it originated from.
Example:
// code 400
{
"standard": "Bad request",
"custom": "One of the required keys was not given a value"
}
These are mainly wrappers around DynamoDB actions, abstracting as much as possible.
| Name | Type | Description |
|---|---|---|
tableName | String | Name of the table you're searching |
key | Object | The key schema for the searched for item |
shouldLogParams | Boolean | Optional flag for logging the params before the operation |
const { getItem } = require('simple-lambda-actions/dist/dynamo')
Returns a promise, which will resolve to:
{
// your item
superImportantAttribute: 'YAAAAAASSSS'
}
| Error Code | Text | Description |
|---|---|---|
400 | Bad Request | Usually thrown when you pass a tableName that cannot be found |
404 | Not Found | Thrown when the key schema provided did not match any records |
500 | Internal Error | Generic internal server error given when error does not provide code |
const getItem = require('simple-lambda-actions/dist/dynamo')
exports.handler = async event => {
const item = await getItem(tableName, keySchema)
// finish and return response
}
| Name | Type | Description |
|---|---|---|
tableName | String | Name of the table you're searching |
item | Object | The item you wish to write, must contain partition key |
shouldLogParams | Boolean | Optional flag for logging the params before the operation |
const { putItem } = require('simple-lambda-actions/dist/dynamo')
Returns a promise, which will resolve to an empty object. This comes directly from DynamoDB.
| Error Code | Text | Description |
|---|---|---|
400 | Bad Request | Usually thrown when you pass a tableName that cannot be found, or if you omit a required key |
500 | Internal Error | Generic internal server error given when error does not provide code |
const putItem = require('simple-lambda-actions/dist/dynamo')
exports.handler = async event => {
await putItem(tableName, parsedBody, true)
// parsedBody is what was written
}
| Name | Type | Description |
|---|---|---|
tableName | String | Name of the table you're searching |
config | Object | The configuration for updating the record. Schema can be found here |
shouldLogParams | Boolean | Optional flag for logging the params before the operation |
const { updateItem } = require('simple-lambda-actions/dist/dynamo')
Returns a promise, which will resolve to an empty object. This comes directly from DynamoDB.
| Error Code | Text | Description |
|---|---|---|
400 | Bad Request | Usually thrown when you pass a tableName that cannot be found, or if you omit a required key |
500 | Internal Error | Generic internal server error given when error does not provide code |
const updateItem = require('simple-lambda-actions/dist/dynamo')
exports.handler = async event => {
await updateItem(tableName, parsedBody, true)
// parsedBody is what was written
}
| Name | Type | Description |
|---|---|---|
params | Object | The params configuration for querying the records. Schema can be found here |
shouldLogParams | Boolean | Optional flag for logging the params before the operation |
const { queryItem } = require('simple-lambda-actions/dist/dynamo')
Returns a promise, which will resolve to the object containing the array of items meeting your criteria, as well as the counts.
{
"Items": [
{
// your item
}
],
"Count": 1,
"ScannedCount": 1
}
| Error Code | Text | Description |
|---|---|---|
400 | Bad Request | Usually thrown when you pass a tableName that cannot be found, or if you omit a required key |
404 | Not Found | When no records match your provided query |
500 | Internal Error | Generic internal server error given when error does not provide code |
const queryItem = require('simple-lambda-actions/dist/dynamo')
exports.handler = async event => {
const items = await queryItem(params)
// parsedBody is what was written
}
This library supports the following actions:
ConditionCheckDeletePutUpdate| Name | Type | Description |
|---|---|---|
operations | Array | Array of transactional operations. The expected schema can be found here |
shouldLogParams | Boolean | Optional flag for logging the params before the operation |
const { transactWrite } = require('simple-lambda-actions/dist/dynamo')
Returns a promise, which will resolve to an empty object.
| Error Code | Text | Description |
|---|---|---|
400 | Bad Request | Usually thrown when you pass a tableName that cannot be found, or if you omit a required key |
500 | Internal Error | Generic internal server error given when error does not provide code |
const transactWrite = require('simple-lambda-actions/dist/dynamo')
const operationsConfig = [
{
operationType: 'update',
TableName: 'TEST_TABLE',
itemSpecificInfo: {
partitionKey: '...',
sortKey: '121212'
},
// otherParams will be spread on the operation
otherParams: {
UpdateExpression: 'set #a = :x + :y',
ConditionExpression: '#a < :MAX',
ExpressionAttributeNames: {'#a' : 'Sum'},
ExpressionAttributeValues: {
':x' : 20,
':y' : 45,
':MAX' : 100,
}
}
}
]
exports.handler = async event => {
try {
await transactWrite(operationsConfig) // will return a promise with an empty object
} catch (error){
const { message, statusCode } = error
// bubble gum in a dish, do what you wish
}
}
These functions are integrated with Secrets Manager, and will fetch the signing key, then perform the auth action in one function call
| Name | Type | Description |
|---|---|---|
secretId | String | The name of your secret key |
givenToken | String | The token you wish to validate |
const { validateTokenWithSecretsManager } = require('simple-lambda-actions/dist/auth')
Returns a promise, which will resolve to:
{
// your decoded token
}
| Error Code | Text | Description |
|---|---|---|
403 | Unauthorized | When the token is invalid, or not provided |
500 | Internal Error | Generic internal server error given when error does not provide code |
const { validateToken } = require('simple-lambda-actions/dist/auth')
const secretId = '...'
exports.handler = async event => {
const givenToken = event.headers.Authorization
const decodedPayload = await validateToken(secretId, givenToken)
// finish and return response
}
| Name | Type | Description |
|---|---|---|
secretId | String | ID of the secret key you will use to sign the token |
payloadToEncode | Object | What you wish to include inside of the token |
expiresIn | String | Duration of token validity. A more comprehensive solution can be found here and here |
const { generateTokenWithSecretsManager } = require('simple-lambda-actions/dist/auth')
Returns the token in the form of a string.
{
token: 'eyasbdjbqjbh12312i7uebkjb' // your token
}
| Error Code | Text | Description |
|---|---|---|
500 | Internal Error | Generic internal server error given when error does not provide code |
const { generateToken } = require('simple-lambda-actions/dist/auth')
const secretId = '...'
exports.handler = async event => {
const parsedBody = JSON.parse(event.body)
const expiresIn = '24h'
const decodedPayload = await generateToken(secretId, parsedBody, expiresIn )
// finish and return response
}
These functions are standalone operations. They are the underlying blocks for the integration with Secrets Manager
| Name | Type | Description |
|---|---|---|
token | String | The token you want to validate |
signingKey | String | The secret key you want to use to validate tokens |
const { validateToken } = require('simple-lambda-actions/dist/auth/lib')
Returns a promise, which will resolve to:
{
// your decoded token
}
| Error Code | Text | Description |
|---|---|---|
403 | Unauthorized | When the token is invalid, or not provided |
500 | Internal Error | Generic internal server error given when error does not provide code |
const { validateToken } = require('simple-lambda-actions/dist/auth')
const signingKey = '...'
exports.handler = async event => {
const givenToken = event.headers.Authorization
const decodedPayload = await validateToken(givenToken, signingKey)
// finish and return response
}
The following must be provided to the updateItem function as the config
| Name | Type | Description | Example | Required |
|---|---|---|---|---|
Key | Object | The key schema of the item being updated | Key | Yes |
ExpressionAttributeNames | Object | How DynamoDB will reference the attribute name of the item being changed | Expression Name | Yes |
ExpressionAttributeValues | Object | How DynamoDB will reference the attribute value being changed | Expression Values | Yes |
UpdateExpression | String | This comma delimited list determines which operations are performed | Update Expression | Yes |
ReturnValues | String | Update Expression | Yes |
The following is the schema of a single operation inside of an array which will be executed sequentially in the transactWrite helper
| Name | Type | Description | Example | Required |
|---|---|---|---|---|
operationType | String | Enum mapping for the type of operation the operation will be performing. Not case sensitive | delete | Yes |
TableName | String | Name of the table that this operation will be performed on | development-userTable | Yes |
itemSpecificInfo | Object | The data specific to this operation, such as primary key, or the item being written | Key or Item | Yes |
otherParams | Object | Other parameters specific to your operation that may be needed for the specific use case. | Update Expression, Expression Values, etc | No |
The following is the schema for the params of querying items. If using a range ( sort ) key, all of the range parameters are required. You can however omit them, and just query based on the partition.
| Name | Type | Description | Example | Required |
|---|---|---|---|---|
partitionKeyName | String | Name of the partition key on the table you're querying | emailAddress | Yes |
partitionKeySearchTerm | String | Value of partition key you are querying. MUST match exactly | yo.mama@lit.live | Yes |
rangeKeyName | String | Name of the range key on the table you're querying | role | No |
rangeKeySearchTerm | String | Value of range key you are querying | admin | No |
rangeKeyComparisonOperator | String | Enum of available comparison operators. List of supported options here | begins_with | No |
Various examples where space might have been limited
{
"partitionKey": "yo ho, yo ho",
"rangeKey": "a pirates life for me"
}
In this example, #key_to_update represents the attribute you are targeting for change, where keyToUpdate is the actual attribute name.
Dynamo creates a reference to this key through the first value, and will use it to reference your item attribute.
{
"#key_to_update": "keyToUpdate",
// more
}
In this example, :nv represents the new value in the same way Expression Name's work. :nv is mapped to newValue and will represent it in further operations
{
":nv": "newValue",
// more
}
Here we are performing the set operation, on the key previously determined, setting the new value to the mapped result of :nv
const UpdateExpression = 'set #new_key = :nv,more...'
More information can be found here
Currently the following operators are supported, anything else will throw an error.
The limiting factor is due to uniformity on how the condition expression is formulated.
=<><=>=attribute_existsattribute_not_existsbegins_withcontainsVarious examples where space might have been limited
{
"partitionKey": "yo ho, yo ho",
"rangeKey": "a pirates life for me"
}
In this example, #key_to_update represents the attribute you are targeting for change, where keyToUpdate is the actual attribute name.
Dynamo creates a reference to this key through the first value, and will use it to reference your item attribute.
{
"#key_to_update": "keyToUpdate",
// more
}
In this example, :nv represents the new value in the same way Expression Name's work. :nv is mapped to newValue and will represent it in further operations
{
":nv": "newValue",
// more
}
Here we are performing the set operation, on the key previously determined, setting the new value to the mapped result of :nv
const UpdateExpression = 'set #new_key = :nv,more...'
More information can be found here
Currently the following operators are supported, anything else will throw an error.
The limiting factor is due to uniformity on how the condition expression is formulated.
=<><=>=attribute_existsattribute_not_existsbegins_withcontainsFAQs
Library for common lambda actions
The npm package simple-lambda-actions receives a total of 0 weekly downloads. As such, simple-lambda-actions popularity was classified as not popular.
We found that simple-lambda-actions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.