Skip to content

Commit

Permalink
feat(dynamodb): Implement importing existing dynamodb table.
Browse files Browse the repository at this point in the history
Closes #3895.
  • Loading branch information
zxkane committed Dec 3, 2019
1 parent 1dcba75 commit 4164f32
Show file tree
Hide file tree
Showing 3 changed files with 436 additions and 112 deletions.
16 changes: 16 additions & 0 deletions packages/@aws-cdk/aws-dynamodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ const table = new dynamodb.Table(this, 'Table', {
});
```

### Importing existing tables

To import an existing table into your CDK application, use the `Table.fromTableAttributes`
factory method. This method accepts `TableAttributes` which describes the properties of an already
existing table:

```ts
const table = Table.fromTableAttributes(this, 'ImportedTable', {
tableArn: 'arn:aws:dynamodb:::table/my-table',
hasIndex: true
});

// now you can just call methods on the table
table.grantReadWriteData(user);
```

### Keys

When a table is defined, you must define it's schema using the `partitionKey`
Expand Down
Loading

0 comments on commit 4164f32

Please sign in to comment.