Last active
January 8, 2021 14:54
-
-
Save Th0masStorm/a4119eddd83b2a4edce64aac2b10dfb0 to your computer and use it in GitHub Desktop.
DAX cluster creation with CloudFormation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: "2010-09-09" | |
Parameters: | |
TableName: | |
Type: String | |
ClusterSize: | |
Type: Number | |
Subnets: | |
Type: List<AWS::EC2::Subnet::Id> | |
Resources: | |
# This role provides DAX cluster nodes with access to DynamoDB | |
DaxRole: | |
Type: AWS::IAM::Role | |
Properties: | |
AssumeRolePolicyDocument: | |
Version: "2012-10-17" | |
Statement: | |
- | |
Effect: "Allow" | |
Principal: | |
Service: "dax.amazonaws.com" | |
Action: "sts:AssumeRole" | |
Policies: | |
- PolicyName: DAX | |
PolicyDocument: | |
Version: 2012-10-17 | |
Statement: | |
- Effect: "Allow" | |
Action: "dynamodb:*" | |
Resource: | |
- !Sub "arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${TableName}" | |
# DAX Subnet Group is a set of VPC Subnets where the nodes are provisioned | |
DaxSubnetGroup: | |
Type: AWS::DAX::SubnetGroup | |
Properties: | |
SubnetIds: !Ref "Subnets" | |
# DAX Cluster | |
DaxCluster: | |
Type: AWS::DAX::Cluster | |
Properties: | |
IAMRoleARN: !GetAtt "DaxRole.Arn" | |
# usually it is a best practice to place instance types | |
# outside of resource definition... But I'm too lazy | |
NodeType: "dax.t2.small" | |
ReplicationFactor: !Ref "ClusterSize" | |
SubnetGroupName: !Ref "DaxSubnetGroup" | |
Outputs: | |
DaxClusterEndpoint: | |
Value: !GetAtt "DaxCluster.ClusterDiscoveryEndpoint" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment