Skip to content

Instantly share code, notes, and snippets.

@thanakijwanavit
Last active October 9, 2020 05:51
Show Gist options
  • Select an option

  • Save thanakijwanavit/11789d32b51700a27c4126d8abde9432 to your computer and use it in GitHub Desktop.

Select an option

Save thanakijwanavit/11789d32b51700a27c4126d8abde9432 to your computer and use it in GitHub Desktop.
dynamodb dax template
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
Sample SAM Template for dax-demo
Globals:
Function:
Timeout: 3
Resources:
CacheTable:
Type: AWS::Serverless::SimpleTable
Properties:
PrimaryKey:
Name: CacheIndex
Type: String
TableName: !Join [ "-", [!Ref 'AWS::StackName', 'cache'] ]
CacheDax:
Type: AWS::DAX::Cluster
Properties:
Description: cache Table accelerator
IAMRoleARN: !GetAtt CacheDaxRole.Arn
NodeType: dax.t2.small
ReplicationFactor: 1
CacheDaxRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- 'sts:AssumeRole'
ManagedPolicyArns:
- !Ref DaxServicePolicy
ReadDaxPolicy:
Type: 'AWS::IAM::ManagedPolicy'
Properties:
ManagedPolicyName: ReadDax
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- "dax:GetItem"
- "dax:BatchGetItem"
- "dax:Query"
- "dax:Scan"
- "dax:PutItem"
- "dax:UpdateItem"
- "dax:DeleteItem"
- "dax:BatchWriteItem"
- "dax:DefineKeySchema"
- "dax:DefineAttributeList"
- "dax:DefineAttributeListId"
- "dax:Endpoints"
- "dax:ConditionCheckItem"
Resource: !GetAtt CacheDax.Arn
- Effect: Allow
Action:
- "dynamodb:GetItem"
- "dynamodb:BatchGetItem"
- "dynamodb:Query"
- "dynamodb:Scan"
- "dynamodb:PutItem"
- "dynamodb:UpdateItem"
- "dynamodb:DeleteItem"
- "dynamodb:BatchWriteItem"
- "dynamodb:DescribeTable"
- "dynamodb:ConditionCheckItem"
Resource: !GetAtt CacheTable.Arn
DaxServicePolicy:
Type: 'AWS::IAM::ManagedPolicy'
Properties:
ManagedPolicyName: ReadDax
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- "dynamodb:GetItem"
- "dynamodb:BatchGetItem"
- "dynamodb:Query"
- "dynamodb:Scan"
- "dynamodb:PutItem"
- "dynamodb:UpdateItem"
- "dynamodb:DeleteItem"
- "dynamodb:BatchWriteItem"
- "dynamodb:DescribeTable"
Resource: !GetAtt CacheTable.Arn
Outputs:
DaxEndpoint:
Value: !GetAtt CacheDax.ClusterDiscoveryEndpoint
ReadDaxPolicy:
Value: !Ref ReadDaxPolicy
Globals:
Function:
Timeout: 30
VpcConfig:
SecurityGroupIds:
- sg-73dae500
SubnetIds:
- subnet-0ca9ad2cd96fccccc
Policies:
- arn:aws:iam::394922924679:policy/villaDaxPolicy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment