Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dawson-snippets

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dawson-snippets - npm Package Compare versions

Comparing version 0.17.1 to 0.17.2

70

dynamodb-backup/README.md
dynamodb-backup
===============
===
Backups items in DynamoDB in real-time to an S3 Bucket with versioning enabled. You can use this to have real-time snapshots of one or more of your DynamoDB tables.
Creates a Lambda Function which backups items written to DynamoDB in real-time to an S3 Bucket with Versioning enabled. You can use this to have real-time snapshots for one of your DynamoDB Tables.
You can include this snippet multiple times provided that you specify different Tables.
![](https://nodei.co/npm/dawson-snippets.png?mini=true)
## Usage
```js
import createBackupTrigger from 'dawson-snippets/dynamodb-backup';
import dynamoDBTable from 'dawson-snippets/dynamodb-table';
import s3BucketVersioning from 'dawson-snippets/s3-bucket-versioning';
import merge from 'lodash/merge';

@@ -16,48 +21,26 @@

// otherwise you get a CloudFormation error: "Attribute: StreamArn was not found for resource: XXX"
const tableUsers = {
TableUsers: {
Type: 'AWS::DynamoDB::Table',
DeletionPolicy: 'Retain',
Properties: {
AttributeDefinitions: [{
AttributeName: 'UserId',
AttributeType: 'S'
}],
KeySchema: [{ AttributeName: 'UserId', KeyType: 'HASH' }],
ProvisionedThroughput: {
ReadCapacityUnits: '1',
WriteCapacityUnits: '1'
},
StreamSpecification: { StreamViewType: 'NEW_IMAGE' } // include the StreamSpecification property!
}
}
};
const tableUsers = dynamoDBTable({
tableLogicalName: 'TableUsers',
primaryKeyName: 'UserId',
enableStream: true // !important!
});
// an S3 Bucket that's used to store item snapshots,
// it's suggested to enable Versioning, as below:
const bucketBackups = {
DynamoBackupsBucket: {
Type: 'AWS::S3::Bucket',
Properties: {
VersioningConfiguration: {
Status: 'Enabled'
}
}
}
};
const bucketBackups = s3BucketVersioning({
bucketLogicalName: 'DynamoBackupsBucket'
});
// this function will return the appropriate Resources
// including Lambda::Function, IAM::Role and Lambda::EventSourceMapping
const backupResources = createDynamodbBackupTrigger({
tableLogicalName: 'TableUsers',
bucketLogicalName: 'DynamoBackupsBucket'
const backupResources = createBackupTrigger({
tableLogicalName: 'TableUsers', // existing DynamoDB Table __Logical__ Resource Id
bucketLogicalName: 'DynamoBackupsBucket' // existing S3 Bucket __Logical__ Resource Id
});
const resources = merge({}, tableUsers, bucketBackups, backupResources);
export function processCFTemplate(template) {
return merge(template, {
Resources: {
...tableUsers,
...bucketBackups,
...backupResources
}
Resources: resources
});

@@ -68,1 +51,12 @@ }

## Details
* This snippet is not composable and its resources should not be further customized
* both `tableLogicalName` and `bucketLogicalName` must reference Resources in the current `CloudFormation Template`; it's up to you to include the *snippets* to create those resources ([`dynamodb-table`](/dynamodb-table) and [`s3-bucket-versioning`](/s3-bucket-versioning))
* The Lambda Function is automatically created and uploaded, as well as the required Permissions and IAM Roles. The following Resources will be included by this snippet: `AWS::IAM::Role`, `AWS::Lambda::EventSourceMapping`, `AWS::Lambda::Function`
## Tests
[dynamodb-backup.spec.js](/__tests__/dynamodb-backup.spec.js)

@@ -38,3 +38,3 @@

* This snippet is composable with all the others `s3-dynamodb-*` snippets
* This snippet is composable with all the others `dynamodb-*` snippets
* If `enableStream` is `true` a stream is enabled for this Table (`StreamViewType = 'NEW_IMAGE'`)

@@ -41,0 +41,0 @@

{
"name": "dawson-snippets",
"version": "0.17.1",
"version": "0.17.2",
"description": "Snippets for CloudFormation templates",

@@ -41,4 +41,4 @@ "repository": {

"engines": {
"node": "4.3"
"node": ">=4.3"
}
}

@@ -13,10 +13,24 @@ # dawson-snippets

For usage instructions see the README files in each folder.
> `dawson-snippets` is dependency-free; it should be used with the `dawson` package of the same version (major.minor).
**For usage instructions and documentation see the README files in each folder.**
Snippets are composable and are designed to be merged using `lodash.merge` or any similar deep-merge function. Snippets provides `Resources` objects that you can attach to a `dawson` application using [processCFTemplate() or customTemplateFragment()](https://github.com/dawson-org/dawson-cli/blob/master/docs/README.md#6-working-with-the-template).
`dawson-snippets` is dependency-free; it should be used with the `dawson` package of the same version (major.minor).
#### tl;dr
```js
import xxxSnippetFunction from 'dawson-snippets/xxx-snippet-function'; // snippet documentation in each folder
const snippetResources = xxxSnippetFunction({ params });
const cloudformationTemplate = {
Resources: {
...snippetResources,
/* ... */
}
Outputs: { /* ... */ },
/* ... */
};
```
### Resource Names
#### Resource Names

@@ -23,0 +37,0 @@ Many snippets will take one or many `logicalName` parameter(s). Each `*LogicalName` you provide must be **unique** in a whole `CloudFormation Template`.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc