Schema and infrastructure
Export Schema (IaC)
Turn a live table into infrastructure code. Copy its schema as CloudFormation YAML, Terraform HCL or Pulumi TypeScript, including attributes, keys, GSIs, LSIs and TTL.
The Export Schema dialog
Click Schema in the table info bar. The dialog has three format tabs and a read-only code view generated entirely on your machine from the table description already loaded. Copy to Clipboard puts the whole document on the clipboard.
AWSTemplateFormatVersion: '2010-09-09'
Description: DynamoDB table schema exported from DynamoOps
Resources:
Orders:
Type: AWS::DynamoDB::Table
Properties:
TableName: orders
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: customerId
AttributeType: S
- AttributeName: orderDate
AttributeType: S
- AttributeName: status
AttributeType: S
KeySchema:
- AttributeName: customerId
KeyType: HASH
- AttributeName: orderDate
KeyType: RANGE
GlobalSecondaryIndexes:
- IndexName: status-index
KeySchema:
- AttributeName: status
KeyType: HASH
Projection:
ProjectionType: ALL
Outputs:
OrdersArn:
Value: !GetAtt Orders.Arn
Export:
Name: !Sub '${AWS::StackName}-orders-arn'What is included
| Included | Not included |
|---|---|
| Table name and billing mode | Provisioned read and write capacity values |
| Attribute definitions and key schema | Stream specification |
| Global secondary indexes with keys, projection type and non-key attributes | Encryption (SSE/KMS) settings |
| Local secondary indexes | Point-in-time recovery, table class, deletion protection |
| TTL block when the description reports TTL enabled | Global-table replicas and your real AWS tags |
- Terraform and Pulumi add a
ManagedBy = "DynamoOps"tag; CloudFormation adds an Outputs block exporting the table ARN. - Resource names are derived from the table name: alphanumeric for the CloudFormation logical ID, lower-case with underscores for Terraform and the Pulumi variable.
Provisioned tables need a capacity block
The export always writes the billing mode it finds but never capacity values. If the source table is provisioned, add read_capacity and write_capacity (or the CloudFormation and Pulumi equivalents) before applying, or switch the resource to on-demand.Suggested workflow
- Prototype the table and its indexes in DynamoOps against a dev account.
- Export the schema, paste it into your infrastructure repository and review the diff.
- Import the existing table into state (
terraform importorpulumi import) if the table should stay, or let IaC recreate it in the next environment. - Generate the matching data access layer with the SDK generator.
Related
Creating tables
Create a DynamoDB table from the sidebar with a partition key, an optional sort key and attribute types. Tables are created in on-demand billing mode.
Index manager (GSI)
Inspect the primary key, local and global secondary indexes of a table, create new global secondary indexes with any projection, and delete the ones you no longer need.
SDK generator
Download a complete, production-oriented data access project for your table in TypeScript, Python, Java, C#, Go, Ruby, PHP or shell, with entity, repository, service and client layers already wired.