giuseppe-trisciuoglio/developer-kit / plugins/developer-kit-aws/skills/aws-cloudformation/aws-cloudformation-dynamodb
aws-cloudformation-dynamodb
VerifiedProvides AWS CloudFormation patterns for DynamoDB tables, GSIs, LSIs, auto-scaling, and streams. Use when creating DynamoDB tables with CloudFormation, configuring primary keys, local/global secondary indexes, capacity modes (on-demand/provisioned), point-in-time recovery, encryption, TTL, and implementing template structure with Parameters, Outputs, Mappings, Conditions, cross-stack references.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.6 KB |
| references/advanced-configuration.md | markdown | 7.5 KB |
| references/complete-examples.md | markdown | 7.7 KB |
| references/examples.md | markdown | 24.2 KB |
| references/reference.md | markdown | 7.7 KB |
references/reference.md
View on GitHub# AWS CloudFormation DynamoDB Reference Guide
## AWS::DynamoDB::Table Resource
### Properties
| Property | Type | Required | Description |
|----------|------|----------|-------------|
| AttributeDefinitions | List | Yes | Attributes that describe the key schema |
| KeySchema | List | Yes | Primary key structure (partition key + optional sort key) |
| TableName | String | No | Name of the table (auto-generated if not specified) |
| BillingMode | String | No | Billing mode: PAY_PER_REQUEST or PROVISIONED |
| ProvisionedThroughput | ProvisionedThroughput | Conditionally | RCU/WCU for PROVISIONED mode |
| GlobalSecondaryIndexes | List | No | List of global secondary indexes |
| LocalSecondaryIndexes | List | No | List of local secondary indexes |
| StreamSpecification | StreamSpecification | No | DynamoDB Streams configuration |
| SSESpecification | SSESpecification | No | Server-side encryption settings |
| PointInTimeRecoverySpecification | PointInTimeRecoverySpecification | No | Point-in-time recovery settings |
| TimeToLiveSpecification | TimeToLiveSpecification | No | TTL settings for automatic data expiration |
| Tags | List | No | Tags for resource management |
### AttributeDefinitions
```yaml
AttributeDefinitions:
- AttributeName: pk
AttributeType: S # String
- AttributeName: sk
AttributeType: N # Number
- AttributeName: data
AttributeType: B # Binary
```
**AttributeType values:**
- `S` - String
- `N` - Number
- `B` - Binary
### KeySchema
```yaml
KeySchema:
- AttributeName: pk
KeyType: HASH # Partition key
- AttributeName: sk
KeyType: RANGE # Sort key (optional)
```
**KeyType values:**
- `HASH` - Partition key
- `RANGE` - Sort key
### ProvisionedThroughput
```yaml
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
```
**Limits:**
- Minimum: 1 RCU/WCU
- Maximum: 40,000 RCU/WCU per table
- For higher limits: request through AWS Support
### GlobalSecondaryIndex
```yaml
GlobalSecondaryIndexes:
- IndexName: my-index
KeySchema:
- AttributeName: gsi_pk
KeyType: HASH
- AttributeName: gsi_sk
KeyType: RANGE
Projection:
ProjectionType: ALL # ALL, KEYS_ONLY, INCLUDE
NonKeyAttributes:
- attribute1
- attribute2
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
```
### LocalSecondaryIndex
```yaml
LocalSecondaryIndexes:
- IndexName: my-lsi
KeySchema:
- AttributeName: pk
KeyType: HASH
- AttributeName: lsi_sk
KeyType: RANGE
Projection:
ProjectionType: ALL
```
### StreamSpecification
```yaml
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES
```
**StreamViewType values:**
- `KEYS_ONLY` - Only key attributes
- `NEW_IMAGE` - Entire item after change
- `OLD_IMAGE` - Entire item before change
- `NEW_AND_OLD_IMAGES` - Both before and after
### SSESpecification
```yaml
SSESpecification:
SSEEnabled: true
SSEType: AES256 # or KMS
KMSMasterKeyId: arn:aws:kms:region:account:key/key-id
```
### PointInTimeRecoverySpecification
```yaml
PointInTimeRecoverySpecification:
PointInTimeRecoveryEnabled: true
```
### TimeToLiveSpecification
```yaml
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true
```
## AWS::ApplicationAutoScaling::ScalableTarget
### Properties
| Property | Type | Required | Description |
|----------|------|----------|-------------|
| ServiceNamespace | String | Yes | Must be `dynamodb` |
| ResourceId | String | Yes | Table or index identifier |
| ScalableDimension | String | Yes | dynamodb:table:ReadCapacityUnits, dynamodb:table:WriteCapacityUnits, dynamodb:index:ReadCapacityUnits, dynamodb:index:WriteCapacityUnits |
| MinCapacity | Number | Yes | Minimum scalable capacity |
| MaxCapacity | Number | Yes | Maximum scalable capacity |
| RoleARN | String | Yes | Auto scaling role ARN |
### ResourceId Formats
- Table: `table/{table-name}`
- GSI: `table/{table-name}/index/{index-name}`
## AWS::ApplicationAutoScaling::ScalingPolicy
### Properties
| Property | Type | Required | Description |
|----------|------|----------|-------------|
| PolicyName | String | Yes | Name of the scaling policy |
| PolicyType | String | Yes | TargetTrackingScaling or StepScaling |
| ScalingTargetId | String | Yes | Reference to ScalableTarget |
| TargetTrackingScalingPolicyConfiguration | Configuration | Yes | Target tracking configuration |
### TargetTrackingScalingPolicyConfiguration
```yaml
TargetTrackingScalingPolicyConfiguration:
PredefinedMetricSpecification:
PredefinedMetricType: DynamoDBReadCapacityUtilization | DynamoDBWriteCapacityUtilization
TargetValue: 70
ScaleInCooldown: 60
ScaleOutCooldown: 60
DisableScaleIn: false
```
## Intrinsic Functions Reference
### !GetAtt
```yaml
TableArn: !GetAtt MyTable.Arn
TableName: !Ref MyTable
StreamArn: !GetAtt MyTable.StreamArn
```
### !Ref
```yaml
TableName: !Ref MyDynamoDBTable
```
### !ImportValue
```yaml
TableName: !ImportValue !Sub "${NetworkStackName}-TableName"
```
### !FindInMap
```yaml
ReadCapacity: !FindInMap [EnvironmentConfig, !Ref Environment, ReadCapacity]
```
## Capacity Units Explained
### Read Capacity Units (RCU)
- One RCU = 1 strongly consistent read per second for items up to 4 KB
- One RCU = 2 eventually consistent reads per second for items up to 4 KB
### Write Capacity Units (WCU)
- One WCU = 1 write per second for items up to 1 KB
### Example Calculations
For 10 items per second, 2 KB each, strongly consistent:
- RCU needed: 10 * (2 / 4) = 5 RCU
- WCU needed: 10 * (2 / 1) = 20 WCU
## Limits and Quotas
### Table Limits
| Resource | Limit |
|----------|-------|
| Tables per account | 2,500 |
| Attributes per table | 100,000,000 items (total size) |
| Item size | 400 KB maximum |
### Index Limits
| Resource | Limit |
|----------|-------|
| GSIs per table | 20 |
| LSIs per table | 5 (one per sort key) |
| Attributes per index | 20 |
| Projected attributes | Unlimited |
### Throughput Limits
| Resource | Limit |
|----------|-------|
| RCU per table | 40,000 (default) |
| WCU per table | 40,000 (default) |
| RCU per GSI | 40,000 (default) |
| WCU per GSI | 40,000 (default) |
## Key Patterns and Anti-Patterns
### Good Partition Key Patterns
```yaml
# Good: High cardinality, uniform distribution
KeySchema:
- AttributeName: user_id
KeyType: HASH
```
```yaml
# Good: Composite key for range queries
KeySchema:
- AttributeName: pk
KeyType: HASH
- AttributeName: sk
KeyType: RANGE
```
### Bad Partition Key Patterns
```yaml
# Bad: Low cardinality (only a few values)
KeySchema:
- AttributeName: status
KeyType: HASH
```
```yaml
# Bad: Time-based keys (hot partitions)
KeySchema:
- AttributeName: timestamp
KeyType: HASH
```
### GSI Design Considerations
- GSI partition key should have high cardinality
- GSI throughput is separate from table throughput
- GSI can only project attributes from the table
- LSI must use same partition key as table
## IAM Permissions
### Table Access
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:UpdateItem",
"dynamodb:DeleteItem",
"dynamodb:Query",
"dynamodb:Scan"
],
"Resource": "arn:aws:dynamodb:region:account:table/table-name"
}
]
}
```
### Index Access
```json
{
"Effect": "Allow",
"Action": [
"dynamodb:Query"
],
"Resource": "arn:aws:dynamodb:region:account:table/table-name/index/index-name"
}
```
### Stream Access
```json
{
"Effect": "Allow",
"Action": [
"dynamodb:GetRecords",
"dynamodb:GetShardIterator",
"dynamodb:DescribeStream",
"dynamodb:ListStreams"
],
"Resource": "arn:aws:dynamodb:region:account:table/table-name/stream/*"
}
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |