Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "AWSTemplateFormatVersion": "2010-09-09",
- "Description": "Database Stack. Version %TEMPLATE-VERSION%",
- "Parameters": {
- "ParentStackName": {
- "Type": "String",
- "Description": "The Parent Stack Name"
- },
- "InboundTraffic": {
- "Description": "Allow inbound traffic to the cluster from this CIDR range.",
- "Type": "String",
- "MinLength": "9",
- "MaxLength": "18",
- "Default": "0.0.0.0/0",
- "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
- "ConstraintDescription": "must be a valid CIDR range of the form x.x.x.x/x."
- },
- "Username": {
- "Description": "The user name that is associated with the master user account for the cluster that is being created",
- "Type": "String",
- "Default": "root",
- "AllowedPattern": "([a-z])([a-z]|[0-9])*"
- },
- "Password": {
- "Description": "The password that is associated with the master user account for the cluster that is being created.",
- "Type": "String",
- "Default": "TaeJ2eez",
- "NoEcho": "true"
- },
- "RdsMysqlInstanceType": {
- "Description": "RdsMysqlInstanceType",
- "Type": "String",
- "Default": "db.t2.large",
- "ConstraintDescription": "Must be a valid instance type"
- },
- "RdsAuroraPrimaryInstanceType": {
- "Description": "RdsAuroraPrimaryInstanceType",
- "Type": "String",
- "Default": "db.r3.large",
- "ConstraintDescription": "Must be a valid instance type"
- },
- "RdsAuroraSecondaryInstanceType": {
- "Description": "RdsAuroraSecondaryInstanceType",
- "Type": "String",
- "Default": "db.t2.medium",
- "ConstraintDescription": "Must be a valid instance type"
- },
- "RedshiftDatabaseName": {
- "Description": "The name of the first database to be created when the cluster is created",
- "Type": "String",
- "Default": "company",
- "AllowedPattern": "([a-z]|[0-9])+"
- },
- "RedshiftClusterType": {
- "Description": "The type of cluster",
- "Type": "String",
- "Default": "single-node",
- "AllowedValues": [ "single-node", "multi-node" ]
- },
- "RedshiftNumberOfNodes": {
- "Description": "The number of compute nodes in the cluster. For multi-node clusters, the NumberOfNodes parameter must be greater than 1",
- "Type": "Number",
- "Default": "1"
- },
- "RedshiftNodeType": {
- "Description": "The type of node to be provisioned",
- "Type": "String",
- "Default": "ds2.xlarge"
- },
- "RedshiftPortNumber": {
- "Description": "The port number on which the cluster accepts incoming connections.",
- "Type": "Number",
- "Default": "5439"
- }
- },
- "Mappings": {
- },
- "Conditions": {
- "IsMultiNodeCluster": {
- "Fn::Equals": [{ "Ref": "RedshiftClusterType" }, "multi-node" ]
- }
- },
- "Resources": {
- "VPCId": {
- "Type": "AWS::EC2::VPC",
- "Properties": {
- "CidrBlock": "10.1.0.0/16",
- "EnableDnsSupport": "true",
- "EnableDnsHostnames": "true",
- "Tags": [
- { "Key": "Name", "Value": { "Ref": "AWS::StackName" } },
- { "Key": "CloudformationStack", "Value": { "Ref": "AWS::StackName" } }
- ]
- }
- },
- "VPCRouteTable": {
- "Type": "AWS::EC2::RouteTable",
- "Properties": {
- "VpcId": { "Ref": "VPCId" },
- "Tags": [
- { "Key": "Name", "Value": { "Ref": "AWS::StackName" } },
- { "Key": "CloudformationStack", "Value": { "Ref": "AWS::StackName" } }
- ]
- }
- },
- "VPCInternetGateway": {
- "Type": "AWS::EC2::InternetGateway",
- "Properties": {
- "Tags": [
- { "Key": "Name", "Value": { "Ref": "AWS::StackName" } },
- { "Key": "CloudformationStack", "Value": { "Ref": "AWS::StackName" } }
- ]
- }
- },
- "VPCInternetGatewayAttachment": {
- "Type": "AWS::EC2::VPCGatewayAttachment",
- "Properties": {
- "VpcId": { "Ref" : "VPCId" },
- "InternetGatewayId": { "Ref" : "VPCInternetGateway" }
- }
- },
- "VPCInternetRoute": {
- "DependsOn" : "VPCInternetGatewayAttachment",
- "Type": "AWS::EC2::Route",
- "Properties": {
- "RouteTableId": { "Ref": "VPCRouteTable" },
- "DestinationCidrBlock": "0.0.0.0/0",
- "GatewayId": { "Ref": "VPCInternetGateway" }
- }
- },
- "Subnet5": {
- "Type": "AWS::EC2::Subnet",
- "Properties": {
- "AvailabilityZone": { "Fn::Select": [ "0", { "Fn::GetAZs": { "Ref": "AWS::Region" } } ] },
- "CidrBlock": "10.1.105.0/27",
- "VpcId": { "Ref": "VPCId" },
- "Tags": [
- { "Key": "Name", "Value": "name" },
- { "Key": "Fleet", "Value": "fleet" },
- { "Key": "Company", "Value": "company" },
- { "Key": "Stack", "Value": "stack" },
- { "Key": "Environment", "Value": "environment" },
- { "Key": "Role", "Value": "role" },
- { "Key": "CloudformationStack", "Value": { "Ref": "AWS::StackName" } },
- { "Key": "CloudformationParentStack", "Value": { "Ref": "ParentStackName" } }
- ]
- }
- },
- "Subnet532": {
- "Type": "AWS::EC2::Subnet",
- "Properties": {
- "AvailabilityZone": { "Fn::Select": [ "1", { "Fn::GetAZs": { "Ref": "AWS::Region" } } ] },
- "CidrBlock": "10.1.105.32/27",
- "VpcId": { "Ref": "VPCId" },
- "Tags": [
- { "Key": "Name", "Value": "name" },
- { "Key": "Fleet", "Value": "fleet" },
- { "Key": "Company", "Value": "company" },
- { "Key": "Stack", "Value": "stack" },
- { "Key": "Environment", "Value": "environment" },
- { "Key": "Role", "Value": "role" },
- { "Key": "CloudformationStack", "Value": { "Ref": "AWS::StackName" } },
- { "Key": "CloudformationParentStack", "Value": { "Ref": "ParentStackName" } }
- ]
- }
- },
- "Subnet564": {
- "Type": "AWS::EC2::Subnet",
- "Properties": {
- "AvailabilityZone": { "Fn::Select": [ "2", { "Fn::GetAZs": { "Ref": "AWS::Region" } } ] },
- "CidrBlock": "10.1.105.64/27",
- "VpcId": { "Ref": "VPCId" },
- "Tags": [
- { "Key": "Name", "Value": "name" },
- { "Key": "Fleet", "Value": "fleet" },
- { "Key": "Company", "Value": "company" },
- { "Key": "Stack", "Value": "stack" },
- { "Key": "Environment", "Value": "environment" },
- { "Key": "Role", "Value": "role" },
- { "Key": "CloudformationStack", "Value": { "Ref": "AWS::StackName" } },
- { "Key": "CloudformationParentStack", "Value": { "Ref": "ParentStackName" } }
- ]
- }
- },
- "Subnet5RouteTableAssociation": {
- "Type": "AWS::EC2::SubnetRouteTableAssociation",
- "Properties": {
- "SubnetId": { "Ref": "Subnet5" },
- "RouteTableId": { "Ref": "VPCRouteTable" }
- }
- },
- "Subnet532RouteTableAssociation": {
- "Type": "AWS::EC2::SubnetRouteTableAssociation",
- "Properties": {
- "SubnetId": { "Ref": "Subnet532" },
- "RouteTableId": { "Ref": "VPCRouteTable" }
- }
- },
- "Subnet564RouteTableAssociation": {
- "Type": "AWS::EC2::SubnetRouteTableAssociation",
- "Properties": {
- "SubnetId": { "Ref": "Subnet564" },
- "RouteTableId": { "Ref": "VPCRouteTable" }
- }
- },
- "SubnetGroup": {
- "Type": "AWS::RDS::DBSubnetGroup",
- "Properties": {
- "DBSubnetGroupDescription": "SubnetGroup",
- "SubnetIds": [
- { "Ref": "Subnet5" },
- { "Ref": "Subnet532" },
- { "Ref": "Subnet564" }
- ],
- "Tags": [
- { "Key": "Name", "Value": "name" },
- { "Key": "Fleet", "Value": "fleet" },
- { "Key": "Company", "Value": "company" },
- { "Key": "Stack", "Value": "stack" },
- { "Key": "Environment", "Value": "environment" },
- { "Key": "Role", "Value": "role" },
- { "Key": "CloudformationStack", "Value": { "Ref": "AWS::StackName" } },
- { "Key": "CloudformationParentStack", "Value": { "Ref": "ParentStackName" } }
- ]
- }
- },
- "RdsSecurityGroup" : {
- "Type": "AWS::EC2::SecurityGroup",
- "Properties": {
- "GroupDescription": "RdsSecurityGroup",
- "VpcId": { "Ref": "VPCId" },
- "SecurityGroupEgress": [],
- "SecurityGroupIngress": [
- { "IpProtocol": "tcp", "FromPort": "3306", "ToPort": "3306", "CidrIp": { "Ref": "InboundTraffic" } }
- ],
- "Tags": [
- { "Key": "Name", "Value": "name" },
- { "Key": "Fleet", "Value": "fleet" },
- { "Key": "Company", "Value": "company" },
- { "Key": "Stack", "Value": "stack" },
- { "Key": "Environment", "Value": "environment" },
- { "Key": "Role", "Value": "role" },
- { "Key": "CloudformationStack", "Value": { "Ref": "AWS::StackName" } },
- { "Key": "CloudformationParentStack", "Value": { "Ref": "ParentStackName" } }
- ]
- }
- },
- "RdsMysqlParameterGroup" : {
- "Type" : "AWS::RDS::DBParameterGroup",
- "Properties" : {
- "Description" : "Rds ParameterGroup",
- "Family" : "MySQL5.6",
- "Parameters" : {
- "binlog_format": "ROW",
- "character_set_server": "utf8",
- "interactive_timeout": "180",
- "log_bin_trust_function_creators": "1",
- "log_queries_not_using_indexes": "0",
- "long_query_time": "8",
- "slow_query_log": "1",
- "wait_timeout": "180",
- "innodb_print_all_deadlocks": "1"
- }
- }
- },
- "RdsMysqlInstance": {
- "Type": "AWS::RDS::DBInstance",
- "Properties": {
- "Engine": "MySQL",
- "EngineVersion": "5.6",
- "DBInstanceIdentifier": "company-stack-environment-role",
- "DBParameterGroupName": { "Ref": "RdsMysqlParameterGroup" },
- "DBSubnetGroupName": { "Ref" : "SubnetGroup" },
- "VPCSecurityGroups": [ { "Ref": "RdsSecurityGroup" } ],
- "MasterUsername": { "Ref": "Username" },
- "DBInstanceClass": { "Ref": "RdsMysqlInstanceType" },
- "AllocatedStorage": "100",
- "MasterUserPassword": { "Ref": "Password" },
- "Tags": [
- { "Key": "Name", "Value": "name" },
- { "Key": "Fleet", "Value": "fleet" },
- { "Key": "Company", "Value": "company" },
- { "Key": "Stack", "Value": "stack" },
- { "Key": "Environment", "Value": "environment" },
- { "Key": "Role", "Value": "role" },
- { "Key": "CloudformationStack", "Value": { "Ref": "AWS::StackName" } },
- { "Key": "CloudformationParentStack", "Value": { "Ref": "ParentStackName" } }
- ]
- },
- "DeletionPolicy": "Snapshot"
- },
- "RdsAuroraClusterFromSnapshot": {
- "Type": "AWS::RDS::DBCluster",
- "Properties": {
- "Engine": "aurora",
- "DBSubnetGroupName": { "Ref": "SubnetGroup" },
- "DBClusterParameterGroupName": { "Ref": "RdsAuroraClusterParameterGroup" },
- "SnapshotIdentifier": "rds:company-stack-environment-role-2017-07-18-06-00"
- },
- "DeletionPolicy": "Snapshot"
- },
- "RdsAuroraPrimaryInstance": {
- "DependsOn": "RdsAuroraParameterGroup",
- "Type": "AWS::RDS::DBInstance",
- "Properties": {
- "DBSubnetGroupName": { "Ref": "SubnetGroup" },
- "DBParameterGroupName": { "Ref": "RdsAuroraParameterGroup" },
- "Engine": "aurora",
- "DBClusterIdentifier": { "Ref": "RdsAuroraClusterFromSnapshot" },
- "PubliclyAccessible": "false",
- "AvailabilityZone": { "Fn::GetAtt": [ "Subnet5", "AvailabilityZone" ] },
- "DBInstanceClass": { "Ref": "RdsAuroraPrimaryInstance" },
- "Tags": [
- { "Key": "Name", "Value": "name" },
- { "Key": "Fleet", "Value": "fleet" },
- { "Key": "Company", "Value": "company" },
- { "Key": "Stack", "Value": "stack" },
- { "Key": "Environment", "Value": "environment" },
- { "Key": "Role", "Value": "role" },
- { "Key": "CloudformationStack", "Value": { "Ref": "AWS::StackName" } },
- { "Key": "CloudformationParentStack", "Value": { "Ref": "ParentStackName" } }
- ]
- }
- },
- "RdsAuroraSecondaryInstance": {
- "DependsOn": "RdsAuroraPrimaryInstance",
- "Type": "AWS::RDS::DBInstance",
- "Properties": {
- "DBSubnetGroupName": { "Ref": "SubnetGroup" },
- "DBParameterGroupName": { "Ref": "RdsAuroraParameterGroup" },
- "Engine": "aurora",
- "DBClusterIdentifier": { "Ref": "RdsAuroraClusterFromSnapshot" },
- "PubliclyAccessible": "false",
- "AvailabilityZone": { "Fn::GetAtt": [ "Subnet532", "AvailabilityZone" ] },
- "DBInstanceClass": { "Ref": "RdsAuroraSecondaryInstance" },
- "Tags": [
- { "Key": "Name", "Value": "name" },
- { "Key": "Fleet", "Value": "fleet" },
- { "Key": "Company", "Value": "company" },
- { "Key": "Stack", "Value": "stack" },
- { "Key": "Environment", "Value": "environment" },
- { "Key": "Role", "Value": "role" },
- { "Key": "CloudformationStack", "Value": { "Ref": "AWS::StackName" } },
- { "Key": "CloudformationParentStack", "Value": { "Ref": "ParentStackName" } }
- ]
- }
- },
- "RdsAuroraClusterParameterGroup": {
- "Type": "AWS::RDS::DBClusterParameterGroup",
- "Properties": {
- "Description": "RdsAuroraClusterParameterGroup",
- "Family": "aurora5.6",
- "Parameters": {
- "time_zone": "UTC"
- }
- }
- },
- "RdsAuroraParameterGroup": {
- "Type": "AWS::RDS::DBParameterGroup",
- "Properties": {
- "Description": "RdsAuroraParameterGroup",
- "Family": "aurora5.6",
- "Parameters": {
- "sql_mode": "IGNORE_SPACE",
- "performance_schema": "1",
- "interactive_timeout": "180",
- "log_bin_trust_function_creators": "1",
- "log_queries_not_using_indexes": "0",
- "long_query_time": "1",
- "slow_query_log": "1",
- "wait_timeout": "180",
- "innodb_print_all_deadlocks": "1",
- "max_connect_errors": "10000"
- }
- }
- },
- "RedshiftClusterSecurityGroup" : {
- "Type": "AWS::EC2::SecurityGroup",
- "Properties": {
- "GroupDescription": "RedshiftClusterSecurityGroup",
- "VpcId": { "Ref": "VPCId" },
- "SecurityGroupEgress": [],
- "SecurityGroupIngress": [
- { "IpProtocol": "tcp", "FromPort": "5439", "ToPort": "5439", "CidrIp": { "Ref": "InboundTraffic" } }
- ],
- "Tags": [
- { "Key": "Name", "Value": "name" },
- { "Key": "Fleet", "Value": "fleet" },
- { "Key": "Company", "Value": "company" },
- { "Key": "Stack", "Value": "stack" },
- { "Key": "Environment", "Value": "environment" },
- { "Key": "Role", "Value": "role" },
- { "Key": "CloudformationStack", "Value": { "Ref": "AWS::StackName" } },
- { "Key": "CloudformationParentStack", "Value": { "Ref": "ParentStackName" } }
- ]
- }
- },
- "RedshiftCluster": {
- "Type": "AWS::Redshift::Cluster",
- "DeletionPolicy": "Snapshot",
- "Properties": {
- "ClusterType": { "Ref": "RedshiftClusterType" },
- "NumberOfNodes": { "Fn::If": [ "IsMultiNodeCluster", { "Ref": "RedshiftNumberOfNodes" }, { "Ref": "AWS::NoValue" }]},
- "NodeType": { "Ref": "RedshiftNodeType" },
- "DBName": { "Ref": "RedshiftDatabaseName" },
- "MasterUsername": { "Ref": "Username" },
- "MasterUserPassword": { "Ref": "Password" },
- "ClusterParameterGroupName": { "Ref": "RedshiftClusterParameterGroup" },
- "ClusterSubnetGroupName": { "Ref": "SubnetGroup" },
- "VpcSecurityGroupIds": [ { "Ref": "RedshiftClusterSecurityGroup" } ],
- "PubliclyAccessible": "true",
- "Port": { "Ref": "RedshiftPortNumber" },
- "AllowVersionUpgrade": "true",
- "AutomatedSnapshotRetentionPeriod": "14"
- }
- },
- "RedshiftClusterParameterGroup": {
- "Type": "AWS::Redshift::ClusterParameterGroup",
- "Properties": {
- "Description": "Cluster parameter group",
- "ParameterGroupFamily": "redshift-1.0",
- "Parameters": [{
- "ParameterName": "enable_user_activity_logging",
- "ParameterValue": "true"
- }]
- }
- },
- "ElasticacheSecurityGroup": {
- "Type": "AWS::EC2::SecurityGroup",
- "Properties": {
- "GroupDescription": "ElasticacheSecurityGroup",
- "VpcId": { "Ref": "VPCId" },
- "SecurityGroupIngress": [
- { "IpProtocol": "tcp", "FromPort": "11211", "ToPort": "11211", "CidrIp": { "Ref": "InboundTraffic" } },
- { "IpProtocol": "tcp", "FromPort": "6379", "ToPort": "6379", "CidrIp": { "Ref": "InboundTraffic" } }
- ],
- "Tags": [
- { "Key": "Name", "Value": "name" },
- { "Key": "Fleet", "Value": "fleet" },
- { "Key": "Company", "Value": "company" },
- { "Key": "Stack", "Value": "stack" },
- { "Key": "Environment", "Value": "environment" },
- { "Key": "Role", "Value": "role" },
- { "Key": "CloudformationStack", "Value": { "Ref": "AWS::StackName" } },
- { "Key": "CloudformationParentStack", "Value": { "Ref": "ParentStackName" } }
- ]
- }
- },
- "ElasticacheMemcacheCluster": {
- "Type": "AWS::ElastiCache::CacheCluster",
- "Properties": {
- "AutoMinorVersionUpgrade": "true",
- "Engine": "memcached",
- "CacheNodeType": "cache.t2.micro",
- "NumCacheNodes": "1",
- "CacheSubnetGroupName": { "Ref": "SubnetGroup" },
- "VpcSecurityGroupIds": [{"Fn::GetAtt": [ "ElasticacheSecurityGroup", "GroupId"]}],
- "Tags": [
- { "Key": "Name", "Value": "name" },
- { "Key": "Fleet", "Value": "fleet" },
- { "Key": "Company", "Value": "company" },
- { "Key": "Stack", "Value": "stack" },
- { "Key": "Environment", "Value": "environment" },
- { "Key": "Role", "Value": "role" },
- { "Key": "CloudformationStack", "Value": { "Ref": "AWS::StackName" } },
- { "Key": "CloudformationParentStack", "Value": { "Ref": "ParentStackName" } }
- ]
- }
- },
- "ElasticacheRedisCluster": {
- "Type": "AWS::ElastiCache::CacheCluster",
- "Properties": {
- "CacheNodeType": "cache.t2.micro",
- "Engine": "redis",
- "NumCacheNodes": "1",
- "CacheSubnetGroupName": { "Ref": "SubnetGroup" },
- "VpcSecurityGroupIds": [{"Fn::GetAtt": [ "ElasticacheSecurityGroup", "GroupId"]}],
- "Tags": [
- { "Key": "Name", "Value": "name" },
- { "Key": "Fleet", "Value": "fleet" },
- { "Key": "Company", "Value": "company" },
- { "Key": "Stack", "Value": "stack" },
- { "Key": "Environment", "Value": "environment" },
- { "Key": "Role", "Value": "role" },
- { "Key": "CloudformationStack", "Value": { "Ref": "AWS::StackName" } },
- { "Key": "CloudformationParentStack", "Value": { "Ref": "ParentStackName" } }
- ]
- }
- }
- },
- "Outputs": {
- "RdsAuroraCluster": {
- "Description": "RdsAuroraCluster",
- "Value": { "Fn::Join": [ "", [ "jdbc:mysql://", { "Fn::GetAtt": [ "RdsAuroraCluster", "Endpoint.Address" ] }, ":", { "Fn::GetAtt": [ "RdsAuroraCluster", "Endpoint.Port" ] }, "/", { "Ref": "RdsAuroraCluster" }]]}
- },
- "RdsMysqlInstance": {
- "Description": "RdsMysqlInstance",
- "Value": { "Fn::Join": [ "", [ "jdbc:mysql://", { "Fn::GetAtt": [ "RdsMysqlInstance", "Endpoint.Address" ] }, ":", { "Fn::GetAtt": [ "RdsMysqlInstance", "Endpoint.Port" ] }, "/", { "Ref": "RdsMysqlInstance" }]]}
- },
- "RedshiftCluster": {
- "Description": "RedshiftCluster",
- "Value": { "Fn::Join": [ ":", [ { "Fn::GetAtt": [ "RedshiftCluster", "Endpoint.Address" ] }, { "Fn::GetAtt": [ "RedshiftCluster", "Endpoint.Port" ] } ] ] }
- },
- "ElasticacheMemcacheCluster": {
- "Description": "ElasticacheMemcacheCluster",
- "Value": {
- "Fn::GetAtt": [ "ElasticacheMemcacheCluster", "ConfigurationEndpoint.Address" ]
- }
- },
- "ElasticacheRedisCluster": {
- "Description": "ElasticacheRedisCluster",
- "Value": {
- "Fn::GetAtt": [ "ElasticacheRedisCluster", "ConfigurationEndpoint.Address" ]
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement