Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AWS Lambda for Amazon DynamoDB daily resize (CloudFormation template)
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
TablePrefix:
Type: String
Resources:
TableDailyResize:
Type: AWS::Serverless::Function
Properties:
Handler: handler.daily_resize
Policies:
- AWSLambdaExecute # Managed Policy
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- dynamodb:CreateTable
- dynamodb:UpdateTable
Resource: !Sub 'arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${TablePrefix}*'
Runtime: python2.7
Timeout: 30
MemorySize: 256
Environment:
Variables:
TABLE_NAME: !Ref TablePrefix
Events:
CreateNewTableEveryDay:
Type: Schedule
Properties:
Input: '{"Operation": "create_new"}'
Schedule: cron(45 23 * * ? *) # every day at 11.45PM
ResizeYesterdaysTableEveryDay:
Type: Schedule
Properties:
Input: '{"Operation": "resize_old"}'
Schedule: cron(15 0 * * ? *) # every day at 00.15AM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.