|
| 1 | +Description: > |
| 2 | + Arnab / Udacity Cloud DevOps |
| 3 | + Capstone project for Cloud DevOps Nanodegree Program |
| 4 | +
|
| 5 | +Parameters: |
| 6 | + EnvironmentName: |
| 7 | + Description: An environment name that will be prefixed to resource names |
| 8 | + Type: String |
| 9 | + |
| 10 | + VpcCIDR: |
| 11 | + Description: Please enter the IP range (CIDR notation) for this VPC |
| 12 | + Type: String |
| 13 | + Default: 192.168.0.0/16 |
| 14 | + |
| 15 | + PublicSubnet1CIDR: |
| 16 | + Description: Please enter the IP range (CIDR notation) for the public subnet in the first Availability Zone |
| 17 | + Type: String |
| 18 | + Default: 192.168.0.0/16 |
| 19 | + |
| 20 | + PublicSubnet2CIDR: |
| 21 | + Description: Please enter the IP range (CIDR notation) for the public subnet in the second Availability Zone |
| 22 | + Type: String |
| 23 | + Default: 192.168.128.0/18 |
| 24 | + |
| 25 | + PublicSubnet3CIDR: |
| 26 | + Description: Please enter the IP range (CIDR notation) for the public subnet in the second Availability Zone |
| 27 | + Type: String |
| 28 | + Default: 192.168.192.0/18 |
| 29 | + |
| 30 | +Resources: |
| 31 | + VPC: |
| 32 | + Type: AWS::EC2::VPC |
| 33 | + Properties: |
| 34 | + CidrBlock: !Ref VpcCIDR |
| 35 | + EnableDnsHostnames: true |
| 36 | + Tags: |
| 37 | + - Key: Name |
| 38 | + Value: !Ref EnvironmentName |
| 39 | + |
| 40 | + InternetGateway: |
| 41 | + Type: AWS::EC2::InternetGateway |
| 42 | + Properties: |
| 43 | + Tags: |
| 44 | + - Key: Name |
| 45 | + Value: !Ref EnvironmentName |
| 46 | + |
| 47 | + InternetGatewayAttachment: |
| 48 | + Type: AWS::EC2::VPCGatewayAttachment |
| 49 | + Properties: |
| 50 | + InternetGatewayId: !Ref InternetGateway |
| 51 | + VpcId: !Ref VPC |
| 52 | + |
| 53 | + PublicSubnet1: |
| 54 | + Type: AWS::EC2::Subnet |
| 55 | + Properties: |
| 56 | + MapPublicIpOnLaunch: true |
| 57 | + VpcId: !Ref VPC |
| 58 | + AvailabilityZone: !Select [0, !GetAZs ""] |
| 59 | + CidrBlock: !Ref PublicSubnet1CIDR |
| 60 | + MapPublicIpOnLaunch: true |
| 61 | + Tags: |
| 62 | + - Key: Name |
| 63 | + Value: !Sub ${EnvironmentName} Public Subnet (AZ1) |
| 64 | + |
| 65 | + PublicSubnet2: |
| 66 | + Type: AWS::EC2::Subnet |
| 67 | + Properties: |
| 68 | + MapPublicIpOnLaunch: true |
| 69 | + VpcId: !Ref VPC |
| 70 | + AvailabilityZone: !Select [1, !GetAZs ""] |
| 71 | + CidrBlock: !Ref PublicSubnet2CIDR |
| 72 | + MapPublicIpOnLaunch: true |
| 73 | + Tags: |
| 74 | + - Key: Name |
| 75 | + Value: !Sub ${EnvironmentName} Public Subnet (AZ2) |
| 76 | + |
| 77 | + PublicSubnet3: |
| 78 | + Type: AWS::EC2::Subnet |
| 79 | + Properties: |
| 80 | + MapPublicIpOnLaunch: true |
| 81 | + VpcId: !Ref VPC |
| 82 | + AvailabilityZone: !Select [2, !GetAZs ""] |
| 83 | + CidrBlock: !Ref PublicSubnet3CIDR |
| 84 | + MapPublicIpOnLaunch: true |
| 85 | + Tags: |
| 86 | + - Key: Name |
| 87 | + Value: !Sub ${EnvironmentName} Public Subnet (AZ3) |
| 88 | + |
| 89 | + PublicRouteTable: |
| 90 | + Type: AWS::EC2::RouteTable |
| 91 | + Properties: |
| 92 | + VpcId: !Ref VPC |
| 93 | + Tags: |
| 94 | + - Key: Name |
| 95 | + Value: !Sub ${EnvironmentName} Public Routes |
| 96 | + |
| 97 | + DefaultPublicRoute: |
| 98 | + Type: AWS::EC2::Route |
| 99 | + DependsOn: InternetGatewayAttachment |
| 100 | + Properties: |
| 101 | + RouteTableId: !Ref PublicRouteTable |
| 102 | + DestinationCidrBlock: 0.0.0.0/0 |
| 103 | + GatewayId: !Ref InternetGateway |
| 104 | + |
| 105 | + PublicSubnet1RouteTableAssociation: |
| 106 | + Type: AWS::EC2::SubnetRouteTableAssociation |
| 107 | + Properties: |
| 108 | + RouteTableId: !Ref PublicRouteTable |
| 109 | + SubnetId: !Ref PublicSubnet1 |
| 110 | + |
| 111 | + PublicSubnet2RouteTableAssociation: |
| 112 | + Type: AWS::EC2::SubnetRouteTableAssociation |
| 113 | + Properties: |
| 114 | + RouteTableId: !Ref PublicRouteTable |
| 115 | + SubnetId: !Ref PublicSubnet2 |
| 116 | + |
| 117 | + PublicSubnet3RouteTableAssociation: |
| 118 | + Type: AWS::EC2::SubnetRouteTableAssociation |
| 119 | + Properties: |
| 120 | + RouteTableId: !Ref PublicRouteTable |
| 121 | + SubnetId: !Ref PublicSubnet3 |
| 122 | + |
| 123 | + DefaultSecurityGroup: |
| 124 | + Type: AWS::EC2::SecurityGroup |
| 125 | + Properties: |
| 126 | + VpcId: !Ref VPC |
| 127 | + GroupDescription: Default security group for EKS. |
| 128 | + SecurityGroupIngress: |
| 129 | + - IpProtocol: tcp |
| 130 | + FromPort: 1025 |
| 131 | + ToPort: 65535 |
| 132 | + CidrIp: 0.0.0.0/0 |
| 133 | + - IpProtocol: tcp |
| 134 | + FromPort: 443 |
| 135 | + ToPort: 443 |
| 136 | + CidrIp: 0.0.0.0/0 |
| 137 | + SecurityGroupEgress: |
| 138 | + - IpProtocol: tcp |
| 139 | + FromPort: 1025 |
| 140 | + ToPort: 65535 |
| 141 | + CidrIp: 0.0.0.0/0 |
| 142 | + |
| 143 | +Outputs: |
| 144 | + VPC: |
| 145 | + Description: A reference to the created VPC |
| 146 | + Value: !Ref VPC |
| 147 | + Export: |
| 148 | + Name: !Sub ${EnvironmentName}-VPCID |
| 149 | + |
| 150 | + VPCPublicRouteTable: |
| 151 | + Description: Public Routing |
| 152 | + Value: !Ref PublicRouteTable |
| 153 | + Export: |
| 154 | + Name: !Sub ${EnvironmentName}-PUB-RT |
| 155 | + |
| 156 | + PublicSubnets: |
| 157 | + Description: A list of the public subnets |
| 158 | + Value: |
| 159 | + !Join [",", [!Ref PublicSubnet1, !Ref PublicSubnet2, !Ref PublicSubnet3]] |
| 160 | + Export: |
| 161 | + Name: !Sub ${EnvironmentName}-PUB-NETS |
| 162 | + |
| 163 | + SecurityGroup: |
| 164 | + Description: Cluster security group. |
| 165 | + Value: !Ref DefaultSecurityGroup |
| 166 | + Export: |
| 167 | + Name: !Sub ${EnvironmentName}-SCG |
| 168 | + |
| 169 | + PublicSubnet1: |
| 170 | + Description: A reference to the public subnet in the 1st Availability Zone |
| 171 | + Value: !Ref PublicSubnet1 |
| 172 | + Export: |
| 173 | + Name: !Sub ${EnvironmentName}-PUB1-SN |
| 174 | + |
| 175 | + PublicSubnet2: |
| 176 | + Description: A reference to the public subnet in the 2nd Availability Zone |
| 177 | + Value: !Ref PublicSubnet2 |
| 178 | + Export: |
| 179 | + Name: !Sub ${EnvironmentName}-PUB2-SN |
| 180 | + |
| 181 | + PublicSubnet3: |
| 182 | + Description: A reference to the public subnet in the 2nd Availability Zone |
| 183 | + Value: !Ref PublicSubnet2 |
| 184 | + Export: |
| 185 | + Name: !Sub ${EnvironmentName}-PUB3-SN |
0 commit comments