Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Glamdring
Last active July 10, 2019 08:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Glamdring/5139bc49037f3b5c1f8cd008ba046df0 to your computer and use it in GitHub Desktop.
Save Glamdring/5139bc49037f3b5c1f8cd008ba046df0 to your computer and use it in GitHub Desktop.
"PrivateSubnetA": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": {
"Fn::Select": [
0,
{
"Fn::GetAZs": {
"Ref": "AWS::Region"
}
}
]
},
"VpcId": {
"Ref": "VPC"
},
"CidrBlock": {
"Fn::Select": [
"0",
{
"Ref": "PrivateSubnetRanges"
}
]
},
"Tags": [
{
"Key": "Name",
"Value": {
"Ref": "AWS::StackName"
}
}
]
}
},
"PrivateSubnetB": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": {
"Fn::Select": [
1,
{
"Fn::GetAZs": {
"Ref": "AWS::Region"
}
}
]
},
"VpcId": {
"Ref": "VPC"
},
"CidrBlock": {
"Fn::Select": [
"1",
{
"Ref": "PrivateSubnetRanges"
}
]
},
"Tags": [
{
"Key": "Name",
"Value": {
"Ref": "AWS::StackName"
}
}
]
}
},
"PrivateSubnetC": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": {
"Fn::Select": [
2,
{
"Fn::GetAZs": {
"Ref": "AWS::Region"
}
}
]
},
"VpcId": {
"Ref": "VPC"
},
"CidrBlock": {
"Fn::Select": [
"2",
{
"Ref": "PrivateSubnetRanges"
}
]
},
"Tags": [
{
"Key": "Name",
"Value": {
"Ref": "AWS::StackName"
}
}
]
}
},
"PrivateSubnetARouteTableAssociation": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"RouteTableId": {
"Ref": "InternetFacingRouteTable"
},
"SubnetId": {
"Ref": "PrivateSubnetA"
}
}
},
"PrivateSubnetBRouteTableAssociation": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"RouteTableId": {
"Ref": "InternetFacingRouteTable"
},
"SubnetId": {
"Ref": "PrivateSubnetB"
}
}
},
"PrivateSubnetCRouteTableAssociation": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"RouteTableId": {
"Ref": "InternetFacingRouteTable"
},
"SubnetId": {
"Ref": "PrivateSubnetC"
}
}
},
"DatabaseSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Enable outbound HTTP(S) connections and inbound SSH and Cassandra TCP",
"VpcId": {
"Ref": "VPC"
},
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": "9042",
"ToPort": "9042",
"CidrIp": {
"Ref": "VpcCIDR"
}
},
{
"IpProtocol": "tcp",
"FromPort": "7000",
"ToPort": "7000",
"CidrIp": {
"Ref": "VpcCIDR"
}
},
{
"IpProtocol": "tcp",
"FromPort": "7001",
"ToPort": "7001",
"CidrIp": {
"Ref": "VpcCIDR"
}
},
{
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
"CidrIp": {
"Ref": "VpcCIDR"
}
}
],
"SecurityGroupEgress": [
{
"CidrIp": "0.0.0.0/0",
"FromPort": "80",
"IpProtocol": "tcp",
"ToPort": "80"
},
{
"CidrIp": "0.0.0.0/0",
"FromPort": "443",
"IpProtocol": "tcp",
"ToPort": "443"
},
{
"IpProtocol": "tcp",
"FromPort": "7000",
"ToPort": "7000",
"CidrIp": {
"Ref": "VpcCIDR"
}
},
{
"IpProtocol": "tcp",
"FromPort": "7001",
"ToPort": "7001",
"CidrIp": {
"Ref": "VpcCIDR"
}
}
]
}
},
"DatabaseLoadBalancer": {
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
"Properties": {
"Name": "DatabaseLoadBalancer",
"Scheme": "internal",
"Type": "network",
"Subnets": [
{
"Ref": "PrivateSubnetA"
},
{
"Ref": "PrivateSubnetB"
},
{
"Ref": "PrivateSubnetC"
}
]
}
},
"DatabaseTargetGroup": {
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
"Properties": {
"Name": "DatabaseTargetGroup",
"Port": 9042,
"Protocol": "TCP",
"VpcId": {
"Ref": "VPC"
}
}
},
"DatabaseALBListenerTCP": {
"Type": "AWS::ElasticLoadBalancingV2::Listener",
"Properties": {
"DefaultActions": [
{
"Type": "forward",
"TargetGroupArn": {
"Ref": "DatabaseTargetGroup"
}
}
],
"LoadBalancerArn": {
"Ref": "DatabaseLoadBalancer"
},
"Port": "9042",
"Protocol": "TCP"
}
},
"DatabaseLaunchConfiguration": {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"AssociatePublicIpAddress": true,
"IamInstanceProfile": {
"Ref": "InstanceRoleInstanceProfile"
},
"ImageId": {
"Fn::FindInMap": [
"RegionOS2AMI",
{
"Ref": "AWS::Region"
},
"Linux"
]
},
"InstanceType": {
"Ref": "DatabaseInstanceType"
},
"KeyName": {
"Ref": "KeyPairName"
},
"SecurityGroups": [
{
"Ref": "DatabaseSecurityGroup"
}
],
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"#!/bin/bash -x\n",
"yum update -y aws-cfn-bootstrap\n",
"yum install -y aws-cli\n",
"#this runs the first stage of cfinit\n",
{
"Fn::Join": [
"",
[
"/opt/aws/bin/cfn-init -v --region ",
{
"Ref": "AWS::Region"
},
" -s ",
{
"Ref": "AWS::StackName"
},
" -r ",
"DatabaseAutoScalingGroup"
]
]
},
"\n",
". /tmp/install/setup-cassandra.sh ",
{
"Ref": "NodeSetupBucketName"
},
"\n",
"# All is well, so signal success.\n",
"/opt/aws/bin/cfn-signal -e 0 -r \"Database group started.\" '",
{
"Ref": "DatabaseWaitHandle"
},
"'\n"
]
]
}
}
}
},
"DatabaseAutoScalingGroup": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"Metadata": {
"AWS::CloudFormation::Authentication": {
"S3AccessCreds": {
"buckets": [
{
"Ref": "NodeSetupBucketName"
}
],
"roleName": {
"Ref": "InstanceRole"
},
"type": "S3"
}
},
"AWS::CloudFormation::Init": {
"config": {
"files": {
"/tmp/install/setup-cassandra.sh": {
"mode": "000755",
"source": {
"Fn::Join": [
"",
[
"https://",
{
"Ref": "NodeSetupBucketName"
},
".s3-",
{
"Ref": "AWS::Region"
},
".amazonaws.com/setup-cassandra.sh"
]
]
}
},
"/tmp/install/update-cassandra-cluster-config.py": {
"mode": "000755",
"source": {
"Fn::Join": [
"",
[
"https://",
{
"Ref": "NodeSetupBucketName"
},
".s3-",
{
"Ref": "AWS::Region"
},
".amazonaws.com/update-cassandra-cluster-config.py"
]
]
}
}
}
}
}
},
"Properties": {
"AvailabilityZones": {
"Fn::GetAZs": {
"Ref": "AWS::Region"
}
},
"LaunchConfigurationName": {
"Ref": "DatabaseLaunchConfiguration"
},
"TargetGroupARNs": [
{
"Ref": "DatabaseTargetGroup"
}
],
"MaxSize": {
"Ref": "MaxDatabaseGroupSize"
},
"MinSize": "1",
"DesiredCapacity": {
"Ref": "DatabaseGroupSize"
},
"VPCZoneIdentifier": [
{
"Ref": "PrivateSubnetA"
},
{
"Ref": "PrivateSubnetB"
},
{
"Ref": "PrivateSubnetC"
}
],
"Tags": [
{
"Key": "Name",
"PropagateAtLaunch": "true",
"Value": "DatabaseNode"
}
]
}
},
"InternetFacingRouteTable": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "VPC"
},
"Tags": [
{
"Key": "Name",
"Value": {
"Ref": "AWS::StackName"
}
}
]
}
}
@souuu
Copy link

souuu commented Jul 9, 2019

InternetFacingRouteTable and many other resources are missing

@Glamdring
Copy link
Author

Added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment