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/advanced-configuration.md
View on GitHub# DynamoDB CloudFormation - Advanced Configuration
## Parameters
### AWS-Specific Parameter Types
```yaml
Parameters:
TableName:
Type: String
Default: my-dynamodb-table
Description: DynamoDB table name
MinLength: 3
MaxLength: 255
AllowedPattern: '^[a-zA-Z0-9_.-]+$'
BillingMode:
Type: String
Default: PAY_PER_REQUEST
AllowedValues:
- PAY_PER_REQUEST
- PROVISIONED
Description: DynamoDB billing mode
ReadCapacityUnits:
Type: Number
Default: 5
MinValue: 5
Description: Read capacity units
WriteCapacityUnits:
Type: Number
Default: 5
MinValue: 5
Description: Write capacity units
EnableEncryption:
Type: String
Default: 'true'
AllowedValues: ['true', 'false']
KMSKeyId:
Type: AWS::SSM::Parameter::Value<String>
Description: KMS key ID from SSM
Tags:
Type: CommaDelimitedList
Description: Tags to apply to resources
```
## Mappings
### Capacity Configuration by Environment
```yaml
Mappings:
EnvironmentCapacity:
dev:
ReadCapacity: 5
WriteCapacity: 5
staging:
ReadCapacity: 10
WriteCapacity: 10
prod:
ReadCapacity: 50
WriteCapacity: 50
Resources:
DynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
ProvisionedThroughput:
ReadCapacityUnits: !FindInMap [EnvironmentCapacity, !Ref Environment, ReadCapacity]
WriteCapacityUnits: !FindInMap [EnvironmentCapacity, !Ref Environment, WriteCapacity]
```
## Conditions
### Conditional Resource Creation
```yaml
Conditions:
IsProd: !Equals [!Ref Environment, prod]
UseEncryption: !Equals [!Ref EnableEncryption, 'true']
EnableAutoScaling: !Equals [!Ref BillingMode, PROVISIONED]
Resources:
DynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: !Ref TableName
BillingMode: !Ref BillingMode
SSESpecification:
!If
- UseEncryption
- SSEEnabled: true
- !Ref AWS::NoValue
AutoScalingTarget:
Type: AWS::ApplicationAutoScaling::ScalableTarget
Condition: EnableAutoScaling
Properties:
ResourceId: !Sub "table/${DynamoDBTable}"
```
## Auto Scaling Configuration
### Target Tracking Policy
```yaml
Resources:
ScalableTarget:
Type: AWS::ApplicationAutoScaling::ScalableTarget
Properties:
MaxCapacity: 100
MinCapacity: 5
ResourceId: !Sub "table/${DynamoDBTable}"
RoleARN: !GetAtt AutoScalingRole.Arn
ScalableDimension: dynamodb:table:ReadCapacityUnits
ServiceNamespace: dynamodb
ScalingPolicy:
Type: AWS::ApplicationAutoScaling::ScalingPolicy
Properties:
PolicyName: TargetTrackingPolicy
PolicyType: TargetTrackingScaling
ScalingTargetId: !Ref ScalableTarget
TargetTrackingConfig:
TargetValue: 70.0
ScaleInCooldown: 300
ScaleOutCooldown: 60
```
### Scheduled Scaling
```yaml
ScheduledAction:
Type: AWS::ApplicationAutoScaling::ScheduledAction
Properties:
ScheduledActionName: scale-up-during-business-hours
Schedule: 'cron(0 8 * * ? *)'
ScalableTargetAction:
MinCapacity: 20
MaxCapacity: 50
```
## DynamoDB Streams
### Stream Configuration
```yaml
Resources:
DynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: !Sub "${AWS::StackName}-table"
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES
StreamProcessor:
Type: AWS::Lambda::EventSourceMapping
Properties:
EventSourceArn: !GetAtt DynamoDBTable.StreamArn
FunctionName: !Ref LambdaFunction
StartingPosition: TRIM_HORIZON
```
## TTL Configuration
### Multiple TTL Attributes
```yaml
Resources:
SessionTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: !Sub "${AWS::StackName}-sessions"
TimeToLiveSpecification:
AttributeName: expiresAt
Enabled: true
CacheTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: !Sub "${AWS::StackName}-cache"
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true
```
## Global Tables
### Replica Configuration
```yaml
Resources:
ReplicaTable:
Type: AWS::DynamoDB::GlobalTable
Properties:
TableName: global-table
AttributeDefinitions:
- AttributeName: pk
AttributeType: S
KeySchema:
- AttributeName: pk
KeyType: HASH
Replicas:
- Region: us-east-1
- Region: us-west-2
- Region: eu-west-1
StreamSpecification:
StreamViewType: NEW_AND_OLD_IMAGES
```
## Outputs
### Exported Outputs
```yaml
Outputs:
TableName:
Description: DynamoDB table name
Value: !Ref DynamoDBTable
Export:
Name: !Sub '${AWS::StackName}-TableName'
TableArn:
Description: DynamoDB table ARN
Value: !GetAtt DynamoDBTable.Arn
Export:
Name: !Sub '${AWS::StackName}-TableArn'
StreamArn:
Description: DynamoDB stream ARN
Value: !GetAtt DynamoDBTable.StreamArn
Export:
Name: !Sub '${AWS::StackName}-StreamArn'
```
## Cross-Stack References
### Import Value in Another Stack
```yaml
Parameters:
DataTableArn:
Type: String
Resources:
LambdaFunction:
Type: AWS::Lambda::Function
Properties:
Runtime: python3.9
Handler: index.lambda_handler
Environment:
Variables:
TABLE_ARN: !Ref DataTableArn
Policies:
- DynamoDBCrudPolicy:
PolicyName: DynamoDBCrudPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:Query
- dynamodb:Scan
Resource: !Sub '${DataTableArn}/*'
```
## IAM Roles
### Auto Scaling Role
```yaml
AutoScalingRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: autoscaling.amazonaws.com
Action: 'sts:AssumeRole'
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSApplicationAutoScalingDynamoDBTablePolicy
```
### DynamoDB Access Role
```yaml
DynamoDBAccessRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: 'sts:AssumeRole'
Policies:
- PolicyName: DynamoDBCrudPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:Query
- dynamodb:Scan
- dynamodb:DescribeTable
Resource: !Sub 'arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${TableName}/*'
```
## Deletion Policy
### Retain Table on Stack Delete
```yaml
Resources:
ImportantTable:
Type: AWS::DynamoDB::Table
DeletionPolicy: Retain
Properties:
TableName: critical-data-table
```
## UpdateReplacePolicy
### Snapshot on Replace
```yaml
Resources:
ImportantTable:
Type: AWS::DynamoDB::Table
UpdateReplacePolicy: Snapshot
Properties:
TableName: !Sub "${AWS::StackName}-table"
PointInTimeRecoverySpecification:
PointInTimeRecoveryEnabled: true
```
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: 198k | 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 |