Datasets:
Commit ·
41fb073
1
Parent(s): 8718bc4
Add human_reference_dataset/aws-cloudformation-templates/ECS/
Browse files- human_reference_dataset/aws-cloudformation-templates/ECS/EC2LaunchType/clusters/private-vpc.json +1092 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/EC2LaunchType/clusters/private-vpc.yaml +727 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/EC2LaunchType/clusters/public-vpc.json +702 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/EC2LaunchType/clusters/public-vpc.yaml +492 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/EC2LaunchType/services/private-service.json +234 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/EC2LaunchType/services/private-service.yaml +147 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/EC2LaunchType/services/public-service.json +234 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/EC2LaunchType/services/public-service.yaml +147 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/ECS_Schedule_Example.json +768 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/ECS_Schedule_Example.yaml +483 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/clusters/private-vpc.json +937 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/clusters/private-vpc.yaml +602 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/clusters/public-vpc.json +545 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/clusters/public-vpc.yaml +366 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/services/private-subnet-private-service.json +302 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/services/private-subnet-private-service.yaml +176 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/services/private-subnet-public-service.json +303 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/services/private-subnet-public-service.yaml +177 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/services/public-service.json +303 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/services/public-service.yaml +177 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/README.md +121 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/images/private-task-private-loadbalancer.svg +3 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/images/private-task-public-loadbalancer.svg +3 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/images/private-task.png +3 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/images/public-task-public-loadbalancer.svg +3 -0
- human_reference_dataset/aws-cloudformation-templates/ECS/images/public-task.png +3 -0
human_reference_dataset/aws-cloudformation-templates/ECS/EC2LaunchType/clusters/private-vpc.json
ADDED
|
@@ -0,0 +1,1092 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "A stack for deploying containerized applications onto a cluster of EC2 hosts using Elastic Container Service. This stack runs containers on hosts that are in a private VPC subnet. Outbound network traffic from the hosts must go out through a NAT gateway. There are two load balancers, one inside the public subnet, which can be used to send traffic to the containers in the private subnet, and one in the private subnet, which can be used for private internal traffic between internal services.",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"DesiredCapacity": {
|
| 6 |
+
"Description": "Number of EC2 instances to launch in your ECS cluster.",
|
| 7 |
+
"Type": "Number",
|
| 8 |
+
"Default": "3"
|
| 9 |
+
},
|
| 10 |
+
"MaxSize": {
|
| 11 |
+
"Description": "Maximum number of EC2 instances that can be launched in your ECS cluster.",
|
| 12 |
+
"Type": "Number",
|
| 13 |
+
"Default": "6"
|
| 14 |
+
},
|
| 15 |
+
"ECSAMI": {
|
| 16 |
+
"Description": "AMI ID",
|
| 17 |
+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
|
| 18 |
+
"Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id"
|
| 19 |
+
},
|
| 20 |
+
"InstanceType": {
|
| 21 |
+
"Description": "EC2 instance type",
|
| 22 |
+
"Type": "String",
|
| 23 |
+
"AllowedValues": [
|
| 24 |
+
"t2.micro",
|
| 25 |
+
"t2.small",
|
| 26 |
+
"t2.medium",
|
| 27 |
+
"t2.large",
|
| 28 |
+
"m3.medium",
|
| 29 |
+
"m3.large",
|
| 30 |
+
"m3.xlarge",
|
| 31 |
+
"m3.2xlarge",
|
| 32 |
+
"m4.large",
|
| 33 |
+
"m4.xlarge",
|
| 34 |
+
"m4.2xlarge",
|
| 35 |
+
"m4.4xlarge",
|
| 36 |
+
"m4.10xlarge",
|
| 37 |
+
"c4.large",
|
| 38 |
+
"c4.xlarge",
|
| 39 |
+
"c4.2xlarge",
|
| 40 |
+
"c4.4xlarge",
|
| 41 |
+
"c4.8xlarge",
|
| 42 |
+
"c3.large",
|
| 43 |
+
"c3.xlarge",
|
| 44 |
+
"c3.2xlarge",
|
| 45 |
+
"c3.4xlarge",
|
| 46 |
+
"c3.8xlarge",
|
| 47 |
+
"r3.large",
|
| 48 |
+
"r3.xlarge",
|
| 49 |
+
"r3.2xlarge",
|
| 50 |
+
"r3.4xlarge",
|
| 51 |
+
"r3.8xlarge",
|
| 52 |
+
"i2.xlarge",
|
| 53 |
+
"i2.2xlarge",
|
| 54 |
+
"i2.4xlarge",
|
| 55 |
+
"i2.8xlarge"
|
| 56 |
+
],
|
| 57 |
+
"Default": "c4.xlarge",
|
| 58 |
+
"ConstraintDescription": "Please choose a valid instance type."
|
| 59 |
+
}
|
| 60 |
+
},
|
| 61 |
+
"Mappings": {
|
| 62 |
+
"SubnetConfig": {
|
| 63 |
+
"VPC": {
|
| 64 |
+
"CIDR": "10.0.0.0/16"
|
| 65 |
+
},
|
| 66 |
+
"PublicOne": {
|
| 67 |
+
"CIDR": "10.0.0.0/24"
|
| 68 |
+
},
|
| 69 |
+
"PublicTwo": {
|
| 70 |
+
"CIDR": "10.0.1.0/24"
|
| 71 |
+
},
|
| 72 |
+
"PrivateOne": {
|
| 73 |
+
"CIDR": "10.0.2.0/24"
|
| 74 |
+
},
|
| 75 |
+
"PrivateTwo": {
|
| 76 |
+
"CIDR": "10.0.3.0/24"
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
},
|
| 80 |
+
"Resources": {
|
| 81 |
+
"VPC": {
|
| 82 |
+
"Type": "AWS::EC2::VPC",
|
| 83 |
+
"Properties": {
|
| 84 |
+
"EnableDnsSupport": true,
|
| 85 |
+
"EnableDnsHostnames": true,
|
| 86 |
+
"CidrBlock": {
|
| 87 |
+
"Fn::FindInMap": [
|
| 88 |
+
"SubnetConfig",
|
| 89 |
+
"VPC",
|
| 90 |
+
"CIDR"
|
| 91 |
+
]
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
},
|
| 95 |
+
"PublicSubnetOne": {
|
| 96 |
+
"Type": "AWS::EC2::Subnet",
|
| 97 |
+
"Properties": {
|
| 98 |
+
"AvailabilityZone": {
|
| 99 |
+
"Fn::Select": [
|
| 100 |
+
0,
|
| 101 |
+
{
|
| 102 |
+
"Fn::GetAZs": {
|
| 103 |
+
"Ref": "AWS::Region"
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
]
|
| 107 |
+
},
|
| 108 |
+
"VpcId": {
|
| 109 |
+
"Ref": "VPC"
|
| 110 |
+
},
|
| 111 |
+
"CidrBlock": {
|
| 112 |
+
"Fn::FindInMap": [
|
| 113 |
+
"SubnetConfig",
|
| 114 |
+
"PublicOne",
|
| 115 |
+
"CIDR"
|
| 116 |
+
]
|
| 117 |
+
},
|
| 118 |
+
"MapPublicIpOnLaunch": true
|
| 119 |
+
}
|
| 120 |
+
},
|
| 121 |
+
"PublicSubnetTwo": {
|
| 122 |
+
"Type": "AWS::EC2::Subnet",
|
| 123 |
+
"Properties": {
|
| 124 |
+
"AvailabilityZone": {
|
| 125 |
+
"Fn::Select": [
|
| 126 |
+
1,
|
| 127 |
+
{
|
| 128 |
+
"Fn::GetAZs": {
|
| 129 |
+
"Ref": "AWS::Region"
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
]
|
| 133 |
+
},
|
| 134 |
+
"VpcId": {
|
| 135 |
+
"Ref": "VPC"
|
| 136 |
+
},
|
| 137 |
+
"CidrBlock": {
|
| 138 |
+
"Fn::FindInMap": [
|
| 139 |
+
"SubnetConfig",
|
| 140 |
+
"PublicTwo",
|
| 141 |
+
"CIDR"
|
| 142 |
+
]
|
| 143 |
+
},
|
| 144 |
+
"MapPublicIpOnLaunch": true
|
| 145 |
+
}
|
| 146 |
+
},
|
| 147 |
+
"PrivateSubnetOne": {
|
| 148 |
+
"Type": "AWS::EC2::Subnet",
|
| 149 |
+
"Properties": {
|
| 150 |
+
"AvailabilityZone": {
|
| 151 |
+
"Fn::Select": [
|
| 152 |
+
0,
|
| 153 |
+
{
|
| 154 |
+
"Fn::GetAZs": {
|
| 155 |
+
"Ref": "AWS::Region"
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
]
|
| 159 |
+
},
|
| 160 |
+
"VpcId": {
|
| 161 |
+
"Ref": "VPC"
|
| 162 |
+
},
|
| 163 |
+
"CidrBlock": {
|
| 164 |
+
"Fn::FindInMap": [
|
| 165 |
+
"SubnetConfig",
|
| 166 |
+
"PrivateOne",
|
| 167 |
+
"CIDR"
|
| 168 |
+
]
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
},
|
| 172 |
+
"PrivateSubnetTwo": {
|
| 173 |
+
"Type": "AWS::EC2::Subnet",
|
| 174 |
+
"Properties": {
|
| 175 |
+
"AvailabilityZone": {
|
| 176 |
+
"Fn::Select": [
|
| 177 |
+
1,
|
| 178 |
+
{
|
| 179 |
+
"Fn::GetAZs": {
|
| 180 |
+
"Ref": "AWS::Region"
|
| 181 |
+
}
|
| 182 |
+
}
|
| 183 |
+
]
|
| 184 |
+
},
|
| 185 |
+
"VpcId": {
|
| 186 |
+
"Ref": "VPC"
|
| 187 |
+
},
|
| 188 |
+
"CidrBlock": {
|
| 189 |
+
"Fn::FindInMap": [
|
| 190 |
+
"SubnetConfig",
|
| 191 |
+
"PrivateTwo",
|
| 192 |
+
"CIDR"
|
| 193 |
+
]
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
},
|
| 197 |
+
"InternetGateway": {
|
| 198 |
+
"Type": "AWS::EC2::InternetGateway"
|
| 199 |
+
},
|
| 200 |
+
"GatewayAttachement": {
|
| 201 |
+
"Type": "AWS::EC2::VPCGatewayAttachment",
|
| 202 |
+
"Properties": {
|
| 203 |
+
"VpcId": {
|
| 204 |
+
"Ref": "VPC"
|
| 205 |
+
},
|
| 206 |
+
"InternetGatewayId": {
|
| 207 |
+
"Ref": "InternetGateway"
|
| 208 |
+
}
|
| 209 |
+
}
|
| 210 |
+
},
|
| 211 |
+
"PublicRouteTable": {
|
| 212 |
+
"Type": "AWS::EC2::RouteTable",
|
| 213 |
+
"Properties": {
|
| 214 |
+
"VpcId": {
|
| 215 |
+
"Ref": "VPC"
|
| 216 |
+
}
|
| 217 |
+
}
|
| 218 |
+
},
|
| 219 |
+
"PublicRoute": {
|
| 220 |
+
"Type": "AWS::EC2::Route",
|
| 221 |
+
"DependsOn": "GatewayAttachement",
|
| 222 |
+
"Properties": {
|
| 223 |
+
"RouteTableId": {
|
| 224 |
+
"Ref": "PublicRouteTable"
|
| 225 |
+
},
|
| 226 |
+
"DestinationCidrBlock": "0.0.0.0/0",
|
| 227 |
+
"GatewayId": {
|
| 228 |
+
"Ref": "InternetGateway"
|
| 229 |
+
}
|
| 230 |
+
}
|
| 231 |
+
},
|
| 232 |
+
"PublicSubnetOneRouteTableAssociation": {
|
| 233 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 234 |
+
"Properties": {
|
| 235 |
+
"SubnetId": {
|
| 236 |
+
"Ref": "PublicSubnetOne"
|
| 237 |
+
},
|
| 238 |
+
"RouteTableId": {
|
| 239 |
+
"Ref": "PublicRouteTable"
|
| 240 |
+
}
|
| 241 |
+
}
|
| 242 |
+
},
|
| 243 |
+
"PublicSubnetTwoRouteTableAssociation": {
|
| 244 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 245 |
+
"Properties": {
|
| 246 |
+
"SubnetId": {
|
| 247 |
+
"Ref": "PublicSubnetTwo"
|
| 248 |
+
},
|
| 249 |
+
"RouteTableId": {
|
| 250 |
+
"Ref": "PublicRouteTable"
|
| 251 |
+
}
|
| 252 |
+
}
|
| 253 |
+
},
|
| 254 |
+
"NatGatewayOneAttachment": {
|
| 255 |
+
"Type": "AWS::EC2::EIP",
|
| 256 |
+
"DependsOn": "GatewayAttachement",
|
| 257 |
+
"Properties": {
|
| 258 |
+
"Domain": "vpc"
|
| 259 |
+
}
|
| 260 |
+
},
|
| 261 |
+
"NatGatewayTwoAttachment": {
|
| 262 |
+
"Type": "AWS::EC2::EIP",
|
| 263 |
+
"DependsOn": "GatewayAttachement",
|
| 264 |
+
"Properties": {
|
| 265 |
+
"Domain": "vpc"
|
| 266 |
+
}
|
| 267 |
+
},
|
| 268 |
+
"NatGatewayOne": {
|
| 269 |
+
"Type": "AWS::EC2::NatGateway",
|
| 270 |
+
"Properties": {
|
| 271 |
+
"AllocationId": {
|
| 272 |
+
"Fn::GetAtt": [
|
| 273 |
+
"NatGatewayOneAttachment",
|
| 274 |
+
"AllocationId"
|
| 275 |
+
]
|
| 276 |
+
},
|
| 277 |
+
"SubnetId": {
|
| 278 |
+
"Ref": "PublicSubnetOne"
|
| 279 |
+
}
|
| 280 |
+
}
|
| 281 |
+
},
|
| 282 |
+
"NatGatewayTwo": {
|
| 283 |
+
"Type": "AWS::EC2::NatGateway",
|
| 284 |
+
"Properties": {
|
| 285 |
+
"AllocationId": {
|
| 286 |
+
"Fn::GetAtt": [
|
| 287 |
+
"NatGatewayTwoAttachment",
|
| 288 |
+
"AllocationId"
|
| 289 |
+
]
|
| 290 |
+
},
|
| 291 |
+
"SubnetId": {
|
| 292 |
+
"Ref": "PublicSubnetTwo"
|
| 293 |
+
}
|
| 294 |
+
}
|
| 295 |
+
},
|
| 296 |
+
"PrivateRouteTableOne": {
|
| 297 |
+
"Type": "AWS::EC2::RouteTable",
|
| 298 |
+
"Properties": {
|
| 299 |
+
"VpcId": {
|
| 300 |
+
"Ref": "VPC"
|
| 301 |
+
}
|
| 302 |
+
}
|
| 303 |
+
},
|
| 304 |
+
"PrivateRouteOne": {
|
| 305 |
+
"Type": "AWS::EC2::Route",
|
| 306 |
+
"Properties": {
|
| 307 |
+
"RouteTableId": {
|
| 308 |
+
"Ref": "PrivateRouteTableOne"
|
| 309 |
+
},
|
| 310 |
+
"DestinationCidrBlock": "0.0.0.0/0",
|
| 311 |
+
"NatGatewayId": {
|
| 312 |
+
"Ref": "NatGatewayOne"
|
| 313 |
+
}
|
| 314 |
+
}
|
| 315 |
+
},
|
| 316 |
+
"PrivateRouteTableOneAssociation": {
|
| 317 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 318 |
+
"Properties": {
|
| 319 |
+
"RouteTableId": {
|
| 320 |
+
"Ref": "PrivateRouteTableOne"
|
| 321 |
+
},
|
| 322 |
+
"SubnetId": {
|
| 323 |
+
"Ref": "PrivateSubnetOne"
|
| 324 |
+
}
|
| 325 |
+
}
|
| 326 |
+
},
|
| 327 |
+
"PrivateRouteTableTwo": {
|
| 328 |
+
"Type": "AWS::EC2::RouteTable",
|
| 329 |
+
"Properties": {
|
| 330 |
+
"VpcId": {
|
| 331 |
+
"Ref": "VPC"
|
| 332 |
+
}
|
| 333 |
+
}
|
| 334 |
+
},
|
| 335 |
+
"PrivateRouteTwo": {
|
| 336 |
+
"Type": "AWS::EC2::Route",
|
| 337 |
+
"Properties": {
|
| 338 |
+
"RouteTableId": {
|
| 339 |
+
"Ref": "PrivateRouteTableTwo"
|
| 340 |
+
},
|
| 341 |
+
"DestinationCidrBlock": "0.0.0.0/0",
|
| 342 |
+
"NatGatewayId": {
|
| 343 |
+
"Ref": "NatGatewayTwo"
|
| 344 |
+
}
|
| 345 |
+
}
|
| 346 |
+
},
|
| 347 |
+
"PrivateRouteTableTwoAssociation": {
|
| 348 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 349 |
+
"Properties": {
|
| 350 |
+
"RouteTableId": {
|
| 351 |
+
"Ref": "PrivateRouteTableTwo"
|
| 352 |
+
},
|
| 353 |
+
"SubnetId": {
|
| 354 |
+
"Ref": "PrivateSubnetTwo"
|
| 355 |
+
}
|
| 356 |
+
}
|
| 357 |
+
},
|
| 358 |
+
"DynamoDBEndpoint": {
|
| 359 |
+
"Type": "AWS::EC2::VPCEndpoint",
|
| 360 |
+
"Properties": {
|
| 361 |
+
"PolicyDocument": {
|
| 362 |
+
"Version": "2012-10-17",
|
| 363 |
+
"Statement": [
|
| 364 |
+
{
|
| 365 |
+
"Effect": "Allow",
|
| 366 |
+
"Action": "*",
|
| 367 |
+
"Principal": "*",
|
| 368 |
+
"Resource": "*"
|
| 369 |
+
}
|
| 370 |
+
]
|
| 371 |
+
},
|
| 372 |
+
"RouteTableIds": [
|
| 373 |
+
{
|
| 374 |
+
"Ref": "PrivateRouteTableOne"
|
| 375 |
+
},
|
| 376 |
+
{
|
| 377 |
+
"Ref": "PrivateRouteTableTwo"
|
| 378 |
+
}
|
| 379 |
+
],
|
| 380 |
+
"ServiceName": {
|
| 381 |
+
"Fn::Join": [
|
| 382 |
+
"",
|
| 383 |
+
[
|
| 384 |
+
"com.amazonaws.",
|
| 385 |
+
{
|
| 386 |
+
"Ref": "AWS::Region"
|
| 387 |
+
},
|
| 388 |
+
".dynamodb"
|
| 389 |
+
]
|
| 390 |
+
]
|
| 391 |
+
},
|
| 392 |
+
"VpcId": {
|
| 393 |
+
"Ref": "VPC"
|
| 394 |
+
}
|
| 395 |
+
}
|
| 396 |
+
},
|
| 397 |
+
"ECSCluster": {
|
| 398 |
+
"Type": "AWS::ECS::Cluster"
|
| 399 |
+
},
|
| 400 |
+
"EcsHostSecurityGroup": {
|
| 401 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 402 |
+
"Properties": {
|
| 403 |
+
"GroupDescription": "Access to the ECS hosts that run containers",
|
| 404 |
+
"VpcId": {
|
| 405 |
+
"Ref": "VPC"
|
| 406 |
+
}
|
| 407 |
+
}
|
| 408 |
+
},
|
| 409 |
+
"EcsSecurityGroupIngressFromPublicALB": {
|
| 410 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 411 |
+
"Properties": {
|
| 412 |
+
"Description": "Ingress from the public ALB",
|
| 413 |
+
"GroupId": {
|
| 414 |
+
"Ref": "EcsHostSecurityGroup"
|
| 415 |
+
},
|
| 416 |
+
"IpProtocol": -1,
|
| 417 |
+
"SourceSecurityGroupId": {
|
| 418 |
+
"Ref": "PublicLoadBalancerSG"
|
| 419 |
+
}
|
| 420 |
+
}
|
| 421 |
+
},
|
| 422 |
+
"EcsSecurityGroupIngressFromPrivateALB": {
|
| 423 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 424 |
+
"Properties": {
|
| 425 |
+
"Description": "Ingress from the private ALB",
|
| 426 |
+
"GroupId": {
|
| 427 |
+
"Ref": "EcsHostSecurityGroup"
|
| 428 |
+
},
|
| 429 |
+
"IpProtocol": -1,
|
| 430 |
+
"SourceSecurityGroupId": {
|
| 431 |
+
"Ref": "PrivateLoadBalancerSG"
|
| 432 |
+
}
|
| 433 |
+
}
|
| 434 |
+
},
|
| 435 |
+
"EcsSecurityGroupIngressFromSelf": {
|
| 436 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 437 |
+
"Properties": {
|
| 438 |
+
"Description": "Ingress from other containers in the same security group",
|
| 439 |
+
"GroupId": {
|
| 440 |
+
"Ref": "EcsHostSecurityGroup"
|
| 441 |
+
},
|
| 442 |
+
"IpProtocol": -1,
|
| 443 |
+
"SourceSecurityGroupId": {
|
| 444 |
+
"Ref": "EcsHostSecurityGroup"
|
| 445 |
+
}
|
| 446 |
+
}
|
| 447 |
+
},
|
| 448 |
+
"ECSAutoScalingGroup": {
|
| 449 |
+
"CreationPolicy": {
|
| 450 |
+
"ResourceSignal": {
|
| 451 |
+
"Timeout": "PT15M"
|
| 452 |
+
}
|
| 453 |
+
},
|
| 454 |
+
"UpdatePolicy": {
|
| 455 |
+
"AutoScalingReplacingUpdate": {
|
| 456 |
+
"WillReplace": true
|
| 457 |
+
}
|
| 458 |
+
},
|
| 459 |
+
"Type": "AWS::AutoScaling::AutoScalingGroup",
|
| 460 |
+
"Properties": {
|
| 461 |
+
"VPCZoneIdentifier": [
|
| 462 |
+
{
|
| 463 |
+
"Ref": "PrivateSubnetOne"
|
| 464 |
+
},
|
| 465 |
+
{
|
| 466 |
+
"Ref": "PrivateSubnetTwo"
|
| 467 |
+
}
|
| 468 |
+
],
|
| 469 |
+
"LaunchConfigurationName": {
|
| 470 |
+
"Ref": "ContainerInstances"
|
| 471 |
+
},
|
| 472 |
+
"MinSize": 1,
|
| 473 |
+
"MaxSize": {
|
| 474 |
+
"Ref": "MaxSize"
|
| 475 |
+
},
|
| 476 |
+
"DesiredCapacity": {
|
| 477 |
+
"Ref": "DesiredCapacity"
|
| 478 |
+
}
|
| 479 |
+
}
|
| 480 |
+
},
|
| 481 |
+
"ContainerInstances": {
|
| 482 |
+
"Type": "AWS::AutoScaling::LaunchConfiguration",
|
| 483 |
+
"Properties": {
|
| 484 |
+
"ImageId": {
|
| 485 |
+
"Ref": "ECSAMI"
|
| 486 |
+
},
|
| 487 |
+
"SecurityGroups": [
|
| 488 |
+
{
|
| 489 |
+
"Ref": "EcsHostSecurityGroup"
|
| 490 |
+
}
|
| 491 |
+
],
|
| 492 |
+
"InstanceType": {
|
| 493 |
+
"Ref": "InstanceType"
|
| 494 |
+
},
|
| 495 |
+
"IamInstanceProfile": {
|
| 496 |
+
"Ref": "EC2InstanceProfile"
|
| 497 |
+
},
|
| 498 |
+
"UserData": {
|
| 499 |
+
"Fn::Base64": {
|
| 500 |
+
"Fn::Sub": "#!/bin/bash -xe\necho ECS_CLUSTER=${ECSCluster} >> /etc/ecs/ecs.config\nyum install -y aws-cfn-bootstrap\n/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource ECSAutoScalingGroup --region ${AWS::Region}\n"
|
| 501 |
+
}
|
| 502 |
+
}
|
| 503 |
+
}
|
| 504 |
+
},
|
| 505 |
+
"AutoscalingRole": {
|
| 506 |
+
"Type": "AWS::IAM::Role",
|
| 507 |
+
"Properties": {
|
| 508 |
+
"AssumeRolePolicyDocument": {
|
| 509 |
+
"Statement": [
|
| 510 |
+
{
|
| 511 |
+
"Effect": "Allow",
|
| 512 |
+
"Principal": {
|
| 513 |
+
"Service": [
|
| 514 |
+
"application-autoscaling.amazonaws.com"
|
| 515 |
+
]
|
| 516 |
+
},
|
| 517 |
+
"Action": [
|
| 518 |
+
"sts:AssumeRole"
|
| 519 |
+
]
|
| 520 |
+
}
|
| 521 |
+
]
|
| 522 |
+
},
|
| 523 |
+
"Path": "/",
|
| 524 |
+
"Policies": [
|
| 525 |
+
{
|
| 526 |
+
"PolicyName": "service-autoscaling",
|
| 527 |
+
"PolicyDocument": {
|
| 528 |
+
"Statement": [
|
| 529 |
+
{
|
| 530 |
+
"Effect": "Allow",
|
| 531 |
+
"Action": [
|
| 532 |
+
"application-autoscaling:*",
|
| 533 |
+
"cloudwatch:DescribeAlarms",
|
| 534 |
+
"cloudwatch:PutMetricAlarm",
|
| 535 |
+
"ecs:DescribeServices",
|
| 536 |
+
"ecs:UpdateService"
|
| 537 |
+
],
|
| 538 |
+
"Resource": "*"
|
| 539 |
+
}
|
| 540 |
+
]
|
| 541 |
+
}
|
| 542 |
+
}
|
| 543 |
+
]
|
| 544 |
+
}
|
| 545 |
+
},
|
| 546 |
+
"EC2InstanceProfile": {
|
| 547 |
+
"Type": "AWS::IAM::InstanceProfile",
|
| 548 |
+
"Properties": {
|
| 549 |
+
"Path": "/",
|
| 550 |
+
"Roles": [
|
| 551 |
+
{
|
| 552 |
+
"Ref": "EC2Role"
|
| 553 |
+
}
|
| 554 |
+
]
|
| 555 |
+
}
|
| 556 |
+
},
|
| 557 |
+
"EC2Role": {
|
| 558 |
+
"Type": "AWS::IAM::Role",
|
| 559 |
+
"Properties": {
|
| 560 |
+
"AssumeRolePolicyDocument": {
|
| 561 |
+
"Statement": [
|
| 562 |
+
{
|
| 563 |
+
"Effect": "Allow",
|
| 564 |
+
"Principal": {
|
| 565 |
+
"Service": [
|
| 566 |
+
"ec2.amazonaws.com"
|
| 567 |
+
]
|
| 568 |
+
},
|
| 569 |
+
"Action": [
|
| 570 |
+
"sts:AssumeRole"
|
| 571 |
+
]
|
| 572 |
+
}
|
| 573 |
+
]
|
| 574 |
+
},
|
| 575 |
+
"Path": "/",
|
| 576 |
+
"Policies": [
|
| 577 |
+
{
|
| 578 |
+
"PolicyName": "ecs-service",
|
| 579 |
+
"PolicyDocument": {
|
| 580 |
+
"Statement": [
|
| 581 |
+
{
|
| 582 |
+
"Effect": "Allow",
|
| 583 |
+
"Action": [
|
| 584 |
+
"ecs:CreateCluster",
|
| 585 |
+
"ecs:DeregisterContainerInstance",
|
| 586 |
+
"ecs:DiscoverPollEndpoint",
|
| 587 |
+
"ecs:Poll",
|
| 588 |
+
"ecs:RegisterContainerInstance",
|
| 589 |
+
"ecs:StartTelemetrySession",
|
| 590 |
+
"ecs:Submit*",
|
| 591 |
+
"logs:CreateLogStream",
|
| 592 |
+
"logs:PutLogEvents",
|
| 593 |
+
"ecr:GetAuthorizationToken",
|
| 594 |
+
"ecr:BatchGetImage",
|
| 595 |
+
"ecr:GetDownloadUrlForLayer"
|
| 596 |
+
],
|
| 597 |
+
"Resource": "*"
|
| 598 |
+
}
|
| 599 |
+
]
|
| 600 |
+
}
|
| 601 |
+
}
|
| 602 |
+
]
|
| 603 |
+
}
|
| 604 |
+
},
|
| 605 |
+
"PublicLoadBalancerSG": {
|
| 606 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 607 |
+
"Properties": {
|
| 608 |
+
"GroupDescription": "Access to the public facing load balancer",
|
| 609 |
+
"VpcId": {
|
| 610 |
+
"Ref": "VPC"
|
| 611 |
+
},
|
| 612 |
+
"SecurityGroupIngress": [
|
| 613 |
+
{
|
| 614 |
+
"CidrIp": "0.0.0.0/0",
|
| 615 |
+
"IpProtocol": -1
|
| 616 |
+
}
|
| 617 |
+
]
|
| 618 |
+
}
|
| 619 |
+
},
|
| 620 |
+
"PublicLoadBalancer": {
|
| 621 |
+
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
|
| 622 |
+
"Properties": {
|
| 623 |
+
"Scheme": "internet-facing",
|
| 624 |
+
"LoadBalancerAttributes": [
|
| 625 |
+
{
|
| 626 |
+
"Key": "idle_timeout.timeout_seconds",
|
| 627 |
+
"Value": "30"
|
| 628 |
+
}
|
| 629 |
+
],
|
| 630 |
+
"Subnets": [
|
| 631 |
+
{
|
| 632 |
+
"Ref": "PublicSubnetOne"
|
| 633 |
+
},
|
| 634 |
+
{
|
| 635 |
+
"Ref": "PublicSubnetTwo"
|
| 636 |
+
}
|
| 637 |
+
],
|
| 638 |
+
"SecurityGroups": [
|
| 639 |
+
{
|
| 640 |
+
"Ref": "PublicLoadBalancerSG"
|
| 641 |
+
}
|
| 642 |
+
]
|
| 643 |
+
}
|
| 644 |
+
},
|
| 645 |
+
"DummyTargetGroupPublic": {
|
| 646 |
+
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
|
| 647 |
+
"Properties": {
|
| 648 |
+
"HealthCheckIntervalSeconds": 6,
|
| 649 |
+
"HealthCheckPath": "/",
|
| 650 |
+
"HealthCheckProtocol": "HTTP",
|
| 651 |
+
"HealthCheckTimeoutSeconds": 5,
|
| 652 |
+
"HealthyThresholdCount": 2,
|
| 653 |
+
"Name": {
|
| 654 |
+
"Fn::Join": [
|
| 655 |
+
"-",
|
| 656 |
+
[
|
| 657 |
+
{
|
| 658 |
+
"Ref": "AWS::StackName"
|
| 659 |
+
},
|
| 660 |
+
"drop-1"
|
| 661 |
+
]
|
| 662 |
+
]
|
| 663 |
+
},
|
| 664 |
+
"Port": 80,
|
| 665 |
+
"Protocol": "HTTP",
|
| 666 |
+
"UnhealthyThresholdCount": 2,
|
| 667 |
+
"VpcId": {
|
| 668 |
+
"Ref": "VPC"
|
| 669 |
+
}
|
| 670 |
+
}
|
| 671 |
+
},
|
| 672 |
+
"PublicLoadBalancerListener": {
|
| 673 |
+
"Type": "AWS::ElasticLoadBalancingV2::Listener",
|
| 674 |
+
"DependsOn": [
|
| 675 |
+
"PublicLoadBalancer"
|
| 676 |
+
],
|
| 677 |
+
"Properties": {
|
| 678 |
+
"DefaultActions": [
|
| 679 |
+
{
|
| 680 |
+
"TargetGroupArn": {
|
| 681 |
+
"Ref": "DummyTargetGroupPublic"
|
| 682 |
+
},
|
| 683 |
+
"Type": "forward"
|
| 684 |
+
}
|
| 685 |
+
],
|
| 686 |
+
"LoadBalancerArn": {
|
| 687 |
+
"Ref": "PublicLoadBalancer"
|
| 688 |
+
},
|
| 689 |
+
"Port": 80,
|
| 690 |
+
"Protocol": "HTTP"
|
| 691 |
+
}
|
| 692 |
+
},
|
| 693 |
+
"PrivateLoadBalancerSG": {
|
| 694 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 695 |
+
"Properties": {
|
| 696 |
+
"GroupDescription": "Access to the internal load balancer",
|
| 697 |
+
"VpcId": {
|
| 698 |
+
"Ref": "VPC"
|
| 699 |
+
}
|
| 700 |
+
}
|
| 701 |
+
},
|
| 702 |
+
"PrivateLoadBalancerIngressFromECS": {
|
| 703 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 704 |
+
"Properties": {
|
| 705 |
+
"Description": "Only accept traffic from a container in the container host security group",
|
| 706 |
+
"GroupId": {
|
| 707 |
+
"Ref": "PrivateLoadBalancerSG"
|
| 708 |
+
},
|
| 709 |
+
"IpProtocol": -1,
|
| 710 |
+
"SourceSecurityGroupId": {
|
| 711 |
+
"Ref": "EcsHostSecurityGroup"
|
| 712 |
+
}
|
| 713 |
+
}
|
| 714 |
+
},
|
| 715 |
+
"PrivateLoadBalancer": {
|
| 716 |
+
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
|
| 717 |
+
"Properties": {
|
| 718 |
+
"Scheme": "internal",
|
| 719 |
+
"LoadBalancerAttributes": [
|
| 720 |
+
{
|
| 721 |
+
"Key": "idle_timeout.timeout_seconds",
|
| 722 |
+
"Value": "30"
|
| 723 |
+
}
|
| 724 |
+
],
|
| 725 |
+
"Subnets": [
|
| 726 |
+
{
|
| 727 |
+
"Ref": "PrivateSubnetOne"
|
| 728 |
+
},
|
| 729 |
+
{
|
| 730 |
+
"Ref": "PrivateSubnetTwo"
|
| 731 |
+
}
|
| 732 |
+
],
|
| 733 |
+
"SecurityGroups": [
|
| 734 |
+
{
|
| 735 |
+
"Ref": "PrivateLoadBalancerSG"
|
| 736 |
+
}
|
| 737 |
+
]
|
| 738 |
+
}
|
| 739 |
+
},
|
| 740 |
+
"DummyTargetGroupPrivate": {
|
| 741 |
+
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
|
| 742 |
+
"Properties": {
|
| 743 |
+
"HealthCheckIntervalSeconds": 6,
|
| 744 |
+
"HealthCheckPath": "/",
|
| 745 |
+
"HealthCheckProtocol": "HTTP",
|
| 746 |
+
"HealthCheckTimeoutSeconds": 5,
|
| 747 |
+
"HealthyThresholdCount": 2,
|
| 748 |
+
"Name": {
|
| 749 |
+
"Fn::Join": [
|
| 750 |
+
"-",
|
| 751 |
+
[
|
| 752 |
+
{
|
| 753 |
+
"Ref": "AWS::StackName"
|
| 754 |
+
},
|
| 755 |
+
"drop-2"
|
| 756 |
+
]
|
| 757 |
+
]
|
| 758 |
+
},
|
| 759 |
+
"Port": 80,
|
| 760 |
+
"Protocol": "HTTP",
|
| 761 |
+
"UnhealthyThresholdCount": 2,
|
| 762 |
+
"VpcId": {
|
| 763 |
+
"Ref": "VPC"
|
| 764 |
+
}
|
| 765 |
+
}
|
| 766 |
+
},
|
| 767 |
+
"PrivateLoadBalancerListener": {
|
| 768 |
+
"Type": "AWS::ElasticLoadBalancingV2::Listener",
|
| 769 |
+
"DependsOn": [
|
| 770 |
+
"PrivateLoadBalancer"
|
| 771 |
+
],
|
| 772 |
+
"Properties": {
|
| 773 |
+
"DefaultActions": [
|
| 774 |
+
{
|
| 775 |
+
"TargetGroupArn": {
|
| 776 |
+
"Ref": "DummyTargetGroupPrivate"
|
| 777 |
+
},
|
| 778 |
+
"Type": "forward"
|
| 779 |
+
}
|
| 780 |
+
],
|
| 781 |
+
"LoadBalancerArn": {
|
| 782 |
+
"Ref": "PrivateLoadBalancer"
|
| 783 |
+
},
|
| 784 |
+
"Port": 80,
|
| 785 |
+
"Protocol": "HTTP"
|
| 786 |
+
}
|
| 787 |
+
},
|
| 788 |
+
"ECSRole": {
|
| 789 |
+
"Type": "AWS::IAM::Role",
|
| 790 |
+
"Properties": {
|
| 791 |
+
"AssumeRolePolicyDocument": {
|
| 792 |
+
"Statement": [
|
| 793 |
+
{
|
| 794 |
+
"Effect": "Allow",
|
| 795 |
+
"Principal": {
|
| 796 |
+
"Service": [
|
| 797 |
+
"ecs.amazonaws.com"
|
| 798 |
+
]
|
| 799 |
+
},
|
| 800 |
+
"Action": [
|
| 801 |
+
"sts:AssumeRole"
|
| 802 |
+
]
|
| 803 |
+
}
|
| 804 |
+
]
|
| 805 |
+
},
|
| 806 |
+
"Path": "/",
|
| 807 |
+
"Policies": [
|
| 808 |
+
{
|
| 809 |
+
"PolicyName": "ecs-service",
|
| 810 |
+
"PolicyDocument": {
|
| 811 |
+
"Statement": [
|
| 812 |
+
{
|
| 813 |
+
"Effect": "Allow",
|
| 814 |
+
"Action": [
|
| 815 |
+
"ec2:AttachNetworkInterface",
|
| 816 |
+
"ec2:CreateNetworkInterface",
|
| 817 |
+
"ec2:CreateNetworkInterfacePermission",
|
| 818 |
+
"ec2:DeleteNetworkInterface",
|
| 819 |
+
"ec2:DeleteNetworkInterfacePermission",
|
| 820 |
+
"ec2:Describe*",
|
| 821 |
+
"ec2:DetachNetworkInterface",
|
| 822 |
+
"elasticloadbalancing:DeregisterInstancesFromLoadBalancer",
|
| 823 |
+
"elasticloadbalancing:DeregisterTargets",
|
| 824 |
+
"elasticloadbalancing:Describe*",
|
| 825 |
+
"elasticloadbalancing:RegisterInstancesWithLoadBalancer",
|
| 826 |
+
"elasticloadbalancing:RegisterTargets"
|
| 827 |
+
],
|
| 828 |
+
"Resource": "*"
|
| 829 |
+
}
|
| 830 |
+
]
|
| 831 |
+
}
|
| 832 |
+
}
|
| 833 |
+
]
|
| 834 |
+
}
|
| 835 |
+
}
|
| 836 |
+
},
|
| 837 |
+
"Outputs": {
|
| 838 |
+
"ClusterName": {
|
| 839 |
+
"Description": "The name of the ECS cluster",
|
| 840 |
+
"Value": {
|
| 841 |
+
"Ref": "ECSCluster"
|
| 842 |
+
},
|
| 843 |
+
"Export": {
|
| 844 |
+
"Name": {
|
| 845 |
+
"Fn::Join": [
|
| 846 |
+
":",
|
| 847 |
+
[
|
| 848 |
+
{
|
| 849 |
+
"Ref": "AWS::StackName"
|
| 850 |
+
},
|
| 851 |
+
"ClusterName"
|
| 852 |
+
]
|
| 853 |
+
]
|
| 854 |
+
}
|
| 855 |
+
}
|
| 856 |
+
},
|
| 857 |
+
"InternalUrl": {
|
| 858 |
+
"Description": "The url of the internal load balancer",
|
| 859 |
+
"Value": {
|
| 860 |
+
"Fn::Join": [
|
| 861 |
+
"",
|
| 862 |
+
[
|
| 863 |
+
"http://",
|
| 864 |
+
{
|
| 865 |
+
"Fn::GetAtt": [
|
| 866 |
+
"PrivateLoadBalancer",
|
| 867 |
+
"DNSName"
|
| 868 |
+
]
|
| 869 |
+
}
|
| 870 |
+
]
|
| 871 |
+
]
|
| 872 |
+
},
|
| 873 |
+
"Export": {
|
| 874 |
+
"Name": {
|
| 875 |
+
"Fn::Join": [
|
| 876 |
+
":",
|
| 877 |
+
[
|
| 878 |
+
{
|
| 879 |
+
"Ref": "AWS::StackName"
|
| 880 |
+
},
|
| 881 |
+
"InternalUrl"
|
| 882 |
+
]
|
| 883 |
+
]
|
| 884 |
+
}
|
| 885 |
+
}
|
| 886 |
+
},
|
| 887 |
+
"ExternalUrl": {
|
| 888 |
+
"Description": "The url of the external load balancer",
|
| 889 |
+
"Value": {
|
| 890 |
+
"Fn::Join": [
|
| 891 |
+
"",
|
| 892 |
+
[
|
| 893 |
+
"http://",
|
| 894 |
+
{
|
| 895 |
+
"Fn::GetAtt": [
|
| 896 |
+
"PublicLoadBalancer",
|
| 897 |
+
"DNSName"
|
| 898 |
+
]
|
| 899 |
+
}
|
| 900 |
+
]
|
| 901 |
+
]
|
| 902 |
+
},
|
| 903 |
+
"Export": {
|
| 904 |
+
"Name": {
|
| 905 |
+
"Fn::Join": [
|
| 906 |
+
":",
|
| 907 |
+
[
|
| 908 |
+
{
|
| 909 |
+
"Ref": "AWS::StackName"
|
| 910 |
+
},
|
| 911 |
+
"ExternalUrl"
|
| 912 |
+
]
|
| 913 |
+
]
|
| 914 |
+
}
|
| 915 |
+
}
|
| 916 |
+
},
|
| 917 |
+
"ECSRole": {
|
| 918 |
+
"Description": "The ARN of the ECS role",
|
| 919 |
+
"Value": {
|
| 920 |
+
"Fn::GetAtt": [
|
| 921 |
+
"ECSRole",
|
| 922 |
+
"Arn"
|
| 923 |
+
]
|
| 924 |
+
},
|
| 925 |
+
"Export": {
|
| 926 |
+
"Name": {
|
| 927 |
+
"Fn::Join": [
|
| 928 |
+
":",
|
| 929 |
+
[
|
| 930 |
+
{
|
| 931 |
+
"Ref": "AWS::StackName"
|
| 932 |
+
},
|
| 933 |
+
"ECSRole"
|
| 934 |
+
]
|
| 935 |
+
]
|
| 936 |
+
}
|
| 937 |
+
}
|
| 938 |
+
},
|
| 939 |
+
"PublicListener": {
|
| 940 |
+
"Description": "The ARN of the public load balancer's Listener",
|
| 941 |
+
"Value": {
|
| 942 |
+
"Ref": "PublicLoadBalancerListener"
|
| 943 |
+
},
|
| 944 |
+
"Export": {
|
| 945 |
+
"Name": {
|
| 946 |
+
"Fn::Join": [
|
| 947 |
+
":",
|
| 948 |
+
[
|
| 949 |
+
{
|
| 950 |
+
"Ref": "AWS::StackName"
|
| 951 |
+
},
|
| 952 |
+
"PublicListener"
|
| 953 |
+
]
|
| 954 |
+
]
|
| 955 |
+
}
|
| 956 |
+
}
|
| 957 |
+
},
|
| 958 |
+
"PrivateListener": {
|
| 959 |
+
"Description": "The ARN of the public load balancer's Listener",
|
| 960 |
+
"Value": {
|
| 961 |
+
"Ref": "PrivateLoadBalancerListener"
|
| 962 |
+
},
|
| 963 |
+
"Export": {
|
| 964 |
+
"Name": {
|
| 965 |
+
"Fn::Join": [
|
| 966 |
+
":",
|
| 967 |
+
[
|
| 968 |
+
{
|
| 969 |
+
"Ref": "AWS::StackName"
|
| 970 |
+
},
|
| 971 |
+
"PrivateListener"
|
| 972 |
+
]
|
| 973 |
+
]
|
| 974 |
+
}
|
| 975 |
+
}
|
| 976 |
+
},
|
| 977 |
+
"VPCId": {
|
| 978 |
+
"Description": "The ID of the VPC that this stack is deployed in",
|
| 979 |
+
"Value": {
|
| 980 |
+
"Ref": "VPC"
|
| 981 |
+
},
|
| 982 |
+
"Export": {
|
| 983 |
+
"Name": {
|
| 984 |
+
"Fn::Join": [
|
| 985 |
+
":",
|
| 986 |
+
[
|
| 987 |
+
{
|
| 988 |
+
"Ref": "AWS::StackName"
|
| 989 |
+
},
|
| 990 |
+
"VPCId"
|
| 991 |
+
]
|
| 992 |
+
]
|
| 993 |
+
}
|
| 994 |
+
}
|
| 995 |
+
},
|
| 996 |
+
"PublicSubnetOne": {
|
| 997 |
+
"Description": "Public subnet one",
|
| 998 |
+
"Value": {
|
| 999 |
+
"Ref": "PublicSubnetOne"
|
| 1000 |
+
},
|
| 1001 |
+
"Export": {
|
| 1002 |
+
"Name": {
|
| 1003 |
+
"Fn::Join": [
|
| 1004 |
+
":",
|
| 1005 |
+
[
|
| 1006 |
+
{
|
| 1007 |
+
"Ref": "AWS::StackName"
|
| 1008 |
+
},
|
| 1009 |
+
"PublicSubnetOne"
|
| 1010 |
+
]
|
| 1011 |
+
]
|
| 1012 |
+
}
|
| 1013 |
+
}
|
| 1014 |
+
},
|
| 1015 |
+
"PublicSubnetTwo": {
|
| 1016 |
+
"Description": "Public subnet two",
|
| 1017 |
+
"Value": {
|
| 1018 |
+
"Ref": "PublicSubnetTwo"
|
| 1019 |
+
},
|
| 1020 |
+
"Export": {
|
| 1021 |
+
"Name": {
|
| 1022 |
+
"Fn::Join": [
|
| 1023 |
+
":",
|
| 1024 |
+
[
|
| 1025 |
+
{
|
| 1026 |
+
"Ref": "AWS::StackName"
|
| 1027 |
+
},
|
| 1028 |
+
"PublicSubnetTwo"
|
| 1029 |
+
]
|
| 1030 |
+
]
|
| 1031 |
+
}
|
| 1032 |
+
}
|
| 1033 |
+
},
|
| 1034 |
+
"PrivateSubnetOne": {
|
| 1035 |
+
"Description": "Private subnet one",
|
| 1036 |
+
"Value": {
|
| 1037 |
+
"Ref": "PrivateSubnetOne"
|
| 1038 |
+
},
|
| 1039 |
+
"Export": {
|
| 1040 |
+
"Name": {
|
| 1041 |
+
"Fn::Join": [
|
| 1042 |
+
":",
|
| 1043 |
+
[
|
| 1044 |
+
{
|
| 1045 |
+
"Ref": "AWS::StackName"
|
| 1046 |
+
},
|
| 1047 |
+
"PrivateSubnetOne"
|
| 1048 |
+
]
|
| 1049 |
+
]
|
| 1050 |
+
}
|
| 1051 |
+
}
|
| 1052 |
+
},
|
| 1053 |
+
"PrivateSubnetTwo": {
|
| 1054 |
+
"Description": "Private subnet two",
|
| 1055 |
+
"Value": {
|
| 1056 |
+
"Ref": "PrivateSubnetTwo"
|
| 1057 |
+
},
|
| 1058 |
+
"Export": {
|
| 1059 |
+
"Name": {
|
| 1060 |
+
"Fn::Join": [
|
| 1061 |
+
":",
|
| 1062 |
+
[
|
| 1063 |
+
{
|
| 1064 |
+
"Ref": "AWS::StackName"
|
| 1065 |
+
},
|
| 1066 |
+
"PrivateSubnetTwo"
|
| 1067 |
+
]
|
| 1068 |
+
]
|
| 1069 |
+
}
|
| 1070 |
+
}
|
| 1071 |
+
},
|
| 1072 |
+
"EcsHostSecurityGroup": {
|
| 1073 |
+
"Description": "A security group used to allow containers to receive traffic",
|
| 1074 |
+
"Value": {
|
| 1075 |
+
"Ref": "EcsHostSecurityGroup"
|
| 1076 |
+
},
|
| 1077 |
+
"Export": {
|
| 1078 |
+
"Name": {
|
| 1079 |
+
"Fn::Join": [
|
| 1080 |
+
":",
|
| 1081 |
+
[
|
| 1082 |
+
{
|
| 1083 |
+
"Ref": "AWS::StackName"
|
| 1084 |
+
},
|
| 1085 |
+
"EcsHostSecurityGroup"
|
| 1086 |
+
]
|
| 1087 |
+
]
|
| 1088 |
+
}
|
| 1089 |
+
}
|
| 1090 |
+
}
|
| 1091 |
+
}
|
| 1092 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/ECS/EC2LaunchType/clusters/private-vpc.yaml
ADDED
|
@@ -0,0 +1,727 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: A stack for deploying containerized applications onto a cluster of EC2 hosts using Elastic Container Service. This stack runs containers on hosts that are in a private VPC subnet. Outbound network traffic from the hosts must go out through a NAT gateway. There are two load balancers, one inside the public subnet, which can be used to send traffic to the containers in the private subnet, and one in the private subnet, which can be used for private internal traffic between internal services.
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
DesiredCapacity:
|
| 7 |
+
Description: Number of EC2 instances to launch in your ECS cluster.
|
| 8 |
+
Type: Number
|
| 9 |
+
Default: "3"
|
| 10 |
+
|
| 11 |
+
MaxSize:
|
| 12 |
+
Description: Maximum number of EC2 instances that can be launched in your ECS cluster.
|
| 13 |
+
Type: Number
|
| 14 |
+
Default: "6"
|
| 15 |
+
|
| 16 |
+
ECSAMI:
|
| 17 |
+
Description: AMI ID
|
| 18 |
+
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
|
| 19 |
+
Default: /aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id
|
| 20 |
+
|
| 21 |
+
InstanceType:
|
| 22 |
+
Description: EC2 instance type
|
| 23 |
+
Type: String
|
| 24 |
+
AllowedValues:
|
| 25 |
+
- t2.micro
|
| 26 |
+
- t2.small
|
| 27 |
+
- t2.medium
|
| 28 |
+
- t2.large
|
| 29 |
+
- m3.medium
|
| 30 |
+
- m3.large
|
| 31 |
+
- m3.xlarge
|
| 32 |
+
- m3.2xlarge
|
| 33 |
+
- m4.large
|
| 34 |
+
- m4.xlarge
|
| 35 |
+
- m4.2xlarge
|
| 36 |
+
- m4.4xlarge
|
| 37 |
+
- m4.10xlarge
|
| 38 |
+
- c4.large
|
| 39 |
+
- c4.xlarge
|
| 40 |
+
- c4.2xlarge
|
| 41 |
+
- c4.4xlarge
|
| 42 |
+
- c4.8xlarge
|
| 43 |
+
- c3.large
|
| 44 |
+
- c3.xlarge
|
| 45 |
+
- c3.2xlarge
|
| 46 |
+
- c3.4xlarge
|
| 47 |
+
- c3.8xlarge
|
| 48 |
+
- r3.large
|
| 49 |
+
- r3.xlarge
|
| 50 |
+
- r3.2xlarge
|
| 51 |
+
- r3.4xlarge
|
| 52 |
+
- r3.8xlarge
|
| 53 |
+
- i2.xlarge
|
| 54 |
+
- i2.2xlarge
|
| 55 |
+
- i2.4xlarge
|
| 56 |
+
- i2.8xlarge
|
| 57 |
+
Default: c4.xlarge
|
| 58 |
+
ConstraintDescription: Please choose a valid instance type.
|
| 59 |
+
|
| 60 |
+
Mappings:
|
| 61 |
+
|
| 62 |
+
# Hard values for the subnet masks. These masks define
|
| 63 |
+
# the range of internal IP addresses that can be assigned.
|
| 64 |
+
# The VPC can have all IP's from 10.0.0.0 to 10.0.255.255
|
| 65 |
+
# There are four subnets which cover the ranges:
|
| 66 |
+
#
|
| 67 |
+
# 10.0.0.0 - 10.0.0.255
|
| 68 |
+
# 10.0.1.0 - 10.0.1.255
|
| 69 |
+
# 10.0.2.0 - 10.0.2.255
|
| 70 |
+
# 10.0.3.0 - 10.0.3.255
|
| 71 |
+
#
|
| 72 |
+
# If you need more IP addresses (perhaps you have so many
|
| 73 |
+
# instances that you run out) then you can customize these
|
| 74 |
+
# ranges to add more
|
| 75 |
+
SubnetConfig:
|
| 76 |
+
VPC:
|
| 77 |
+
CIDR: 10.0.0.0/16
|
| 78 |
+
PublicOne:
|
| 79 |
+
CIDR: 10.0.0.0/24
|
| 80 |
+
PublicTwo:
|
| 81 |
+
CIDR: 10.0.1.0/24
|
| 82 |
+
PrivateOne:
|
| 83 |
+
CIDR: 10.0.2.0/24
|
| 84 |
+
PrivateTwo:
|
| 85 |
+
CIDR: 10.0.3.0/24
|
| 86 |
+
|
| 87 |
+
Resources:
|
| 88 |
+
|
| 89 |
+
# VPC in which containers will be networked.
|
| 90 |
+
# It has two public subnets, and two private subnets.
|
| 91 |
+
# We distribute the subnets across the first two available subnets
|
| 92 |
+
# for the region, for high availability.
|
| 93 |
+
VPC:
|
| 94 |
+
Type: AWS::EC2::VPC
|
| 95 |
+
Properties:
|
| 96 |
+
EnableDnsSupport: true
|
| 97 |
+
EnableDnsHostnames: true
|
| 98 |
+
CidrBlock: !FindInMap
|
| 99 |
+
- SubnetConfig
|
| 100 |
+
- VPC
|
| 101 |
+
- CIDR
|
| 102 |
+
|
| 103 |
+
# Two public subnets, where containers can have public IP addresses
|
| 104 |
+
PublicSubnetOne:
|
| 105 |
+
Type: AWS::EC2::Subnet
|
| 106 |
+
Properties:
|
| 107 |
+
AvailabilityZone: !Select
|
| 108 |
+
- 0
|
| 109 |
+
- !GetAZs
|
| 110 |
+
Ref: AWS::Region
|
| 111 |
+
VpcId: !Ref VPC
|
| 112 |
+
CidrBlock: !FindInMap
|
| 113 |
+
- SubnetConfig
|
| 114 |
+
- PublicOne
|
| 115 |
+
- CIDR
|
| 116 |
+
MapPublicIpOnLaunch: true
|
| 117 |
+
|
| 118 |
+
PublicSubnetTwo:
|
| 119 |
+
Type: AWS::EC2::Subnet
|
| 120 |
+
Properties:
|
| 121 |
+
AvailabilityZone: !Select
|
| 122 |
+
- 1
|
| 123 |
+
- !GetAZs
|
| 124 |
+
Ref: AWS::Region
|
| 125 |
+
VpcId: !Ref VPC
|
| 126 |
+
CidrBlock: !FindInMap
|
| 127 |
+
- SubnetConfig
|
| 128 |
+
- PublicTwo
|
| 129 |
+
- CIDR
|
| 130 |
+
MapPublicIpOnLaunch: true
|
| 131 |
+
|
| 132 |
+
# Two private subnets where containers will only have private
|
| 133 |
+
# IP addresses, and will only be reachable by other members of the
|
| 134 |
+
# VPC
|
| 135 |
+
PrivateSubnetOne:
|
| 136 |
+
Type: AWS::EC2::Subnet
|
| 137 |
+
Properties:
|
| 138 |
+
AvailabilityZone: !Select
|
| 139 |
+
- 0
|
| 140 |
+
- !GetAZs
|
| 141 |
+
Ref: AWS::Region
|
| 142 |
+
VpcId: !Ref VPC
|
| 143 |
+
CidrBlock: !FindInMap
|
| 144 |
+
- SubnetConfig
|
| 145 |
+
- PrivateOne
|
| 146 |
+
- CIDR
|
| 147 |
+
|
| 148 |
+
PrivateSubnetTwo:
|
| 149 |
+
Type: AWS::EC2::Subnet
|
| 150 |
+
Properties:
|
| 151 |
+
AvailabilityZone: !Select
|
| 152 |
+
- 1
|
| 153 |
+
- !GetAZs
|
| 154 |
+
Ref: AWS::Region
|
| 155 |
+
VpcId: !Ref VPC
|
| 156 |
+
CidrBlock: !FindInMap
|
| 157 |
+
- SubnetConfig
|
| 158 |
+
- PrivateTwo
|
| 159 |
+
- CIDR
|
| 160 |
+
|
| 161 |
+
# Setup networking resources for the public subnets. Containers
|
| 162 |
+
# in the public subnets have public IP addresses and the routing table
|
| 163 |
+
# sends network traffic via the internet gateway.
|
| 164 |
+
InternetGateway:
|
| 165 |
+
Type: AWS::EC2::InternetGateway
|
| 166 |
+
|
| 167 |
+
GatewayAttachement:
|
| 168 |
+
Type: AWS::EC2::VPCGatewayAttachment
|
| 169 |
+
Properties:
|
| 170 |
+
VpcId: !Ref VPC
|
| 171 |
+
InternetGatewayId: !Ref InternetGateway
|
| 172 |
+
|
| 173 |
+
PublicRouteTable:
|
| 174 |
+
Type: AWS::EC2::RouteTable
|
| 175 |
+
Properties:
|
| 176 |
+
VpcId: !Ref VPC
|
| 177 |
+
|
| 178 |
+
PublicRoute:
|
| 179 |
+
Type: AWS::EC2::Route
|
| 180 |
+
DependsOn: GatewayAttachement
|
| 181 |
+
Properties:
|
| 182 |
+
RouteTableId: !Ref PublicRouteTable
|
| 183 |
+
DestinationCidrBlock: 0.0.0.0/0
|
| 184 |
+
GatewayId: !Ref InternetGateway
|
| 185 |
+
|
| 186 |
+
PublicSubnetOneRouteTableAssociation:
|
| 187 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 188 |
+
Properties:
|
| 189 |
+
SubnetId: !Ref PublicSubnetOne
|
| 190 |
+
RouteTableId: !Ref PublicRouteTable
|
| 191 |
+
|
| 192 |
+
PublicSubnetTwoRouteTableAssociation:
|
| 193 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 194 |
+
Properties:
|
| 195 |
+
SubnetId: !Ref PublicSubnetTwo
|
| 196 |
+
RouteTableId: !Ref PublicRouteTable
|
| 197 |
+
|
| 198 |
+
# Setup networking resources for the private subnets. Containers
|
| 199 |
+
# in these subnets have only private IP addresses, and must use a NAT
|
| 200 |
+
# gateway to talk to the internet. We launch two NAT gateways, one for
|
| 201 |
+
# each private subnet.
|
| 202 |
+
NatGatewayOneAttachment:
|
| 203 |
+
Type: AWS::EC2::EIP
|
| 204 |
+
DependsOn: GatewayAttachement
|
| 205 |
+
Properties:
|
| 206 |
+
Domain: vpc
|
| 207 |
+
|
| 208 |
+
NatGatewayTwoAttachment:
|
| 209 |
+
Type: AWS::EC2::EIP
|
| 210 |
+
DependsOn: GatewayAttachement
|
| 211 |
+
Properties:
|
| 212 |
+
Domain: vpc
|
| 213 |
+
|
| 214 |
+
NatGatewayOne:
|
| 215 |
+
Type: AWS::EC2::NatGateway
|
| 216 |
+
Properties:
|
| 217 |
+
AllocationId: !GetAtt NatGatewayOneAttachment.AllocationId
|
| 218 |
+
SubnetId: !Ref PublicSubnetOne
|
| 219 |
+
|
| 220 |
+
NatGatewayTwo:
|
| 221 |
+
Type: AWS::EC2::NatGateway
|
| 222 |
+
Properties:
|
| 223 |
+
AllocationId: !GetAtt NatGatewayTwoAttachment.AllocationId
|
| 224 |
+
SubnetId: !Ref PublicSubnetTwo
|
| 225 |
+
|
| 226 |
+
PrivateRouteTableOne:
|
| 227 |
+
Type: AWS::EC2::RouteTable
|
| 228 |
+
Properties:
|
| 229 |
+
VpcId: !Ref VPC
|
| 230 |
+
|
| 231 |
+
PrivateRouteOne:
|
| 232 |
+
Type: AWS::EC2::Route
|
| 233 |
+
Properties:
|
| 234 |
+
RouteTableId: !Ref PrivateRouteTableOne
|
| 235 |
+
DestinationCidrBlock: 0.0.0.0/0
|
| 236 |
+
NatGatewayId: !Ref NatGatewayOne
|
| 237 |
+
|
| 238 |
+
PrivateRouteTableOneAssociation:
|
| 239 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 240 |
+
Properties:
|
| 241 |
+
RouteTableId: !Ref PrivateRouteTableOne
|
| 242 |
+
SubnetId: !Ref PrivateSubnetOne
|
| 243 |
+
|
| 244 |
+
PrivateRouteTableTwo:
|
| 245 |
+
Type: AWS::EC2::RouteTable
|
| 246 |
+
Properties:
|
| 247 |
+
VpcId: !Ref VPC
|
| 248 |
+
|
| 249 |
+
PrivateRouteTwo:
|
| 250 |
+
Type: AWS::EC2::Route
|
| 251 |
+
Properties:
|
| 252 |
+
RouteTableId: !Ref PrivateRouteTableTwo
|
| 253 |
+
DestinationCidrBlock: 0.0.0.0/0
|
| 254 |
+
NatGatewayId: !Ref NatGatewayTwo
|
| 255 |
+
|
| 256 |
+
PrivateRouteTableTwoAssociation:
|
| 257 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 258 |
+
Properties:
|
| 259 |
+
RouteTableId: !Ref PrivateRouteTableTwo
|
| 260 |
+
SubnetId: !Ref PrivateSubnetTwo
|
| 261 |
+
|
| 262 |
+
# OPTIONAL: VPC Endpoint for DynamoDB
|
| 263 |
+
# If a container needs to access DynamoDB this allows a container in the private subnet
|
| 264 |
+
# to talk to DynamoDB directly without needing to go via the NAT gateway. This reduces
|
| 265 |
+
# the amount of bandwidth through the gateway, meaning that the gateway is free to serve
|
| 266 |
+
# your other traffic.
|
| 267 |
+
DynamoDBEndpoint:
|
| 268 |
+
Type: AWS::EC2::VPCEndpoint
|
| 269 |
+
Properties:
|
| 270 |
+
PolicyDocument:
|
| 271 |
+
Version: "2012-10-17"
|
| 272 |
+
Statement:
|
| 273 |
+
- Effect: Allow
|
| 274 |
+
Action: '*'
|
| 275 |
+
Principal: '*'
|
| 276 |
+
Resource: '*'
|
| 277 |
+
RouteTableIds:
|
| 278 |
+
- !Ref PrivateRouteTableOne
|
| 279 |
+
- !Ref PrivateRouteTableTwo
|
| 280 |
+
ServiceName: !Join
|
| 281 |
+
- ""
|
| 282 |
+
- - com.amazonaws.
|
| 283 |
+
- !Ref AWS::Region
|
| 284 |
+
- .dynamodb
|
| 285 |
+
VpcId: !Ref VPC
|
| 286 |
+
|
| 287 |
+
# ECS Resources
|
| 288 |
+
ECSCluster:
|
| 289 |
+
Type: AWS::ECS::Cluster
|
| 290 |
+
|
| 291 |
+
# A security group for the EC2 hosts that will run the containers.
|
| 292 |
+
# Two rules, allowing network traffic from a public facing load
|
| 293 |
+
# balancer and from other hosts in the security group.
|
| 294 |
+
#
|
| 295 |
+
# Remove any of the following ingress rules that are not needed.
|
| 296 |
+
# If you want to make direct requests to a container using its
|
| 297 |
+
# public IP address you'll need to add a security group rule
|
| 298 |
+
# to allow traffic from all IP addresses.
|
| 299 |
+
EcsHostSecurityGroup:
|
| 300 |
+
Type: AWS::EC2::SecurityGroup
|
| 301 |
+
Properties:
|
| 302 |
+
GroupDescription: Access to the ECS hosts that run containers
|
| 303 |
+
VpcId: !Ref VPC
|
| 304 |
+
|
| 305 |
+
EcsSecurityGroupIngressFromPublicALB:
|
| 306 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 307 |
+
Properties:
|
| 308 |
+
Description: Ingress from the public ALB
|
| 309 |
+
GroupId: !Ref EcsHostSecurityGroup
|
| 310 |
+
IpProtocol: -1
|
| 311 |
+
SourceSecurityGroupId: !Ref PublicLoadBalancerSG
|
| 312 |
+
|
| 313 |
+
EcsSecurityGroupIngressFromPrivateALB:
|
| 314 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 315 |
+
Properties:
|
| 316 |
+
Description: Ingress from the private ALB
|
| 317 |
+
GroupId: !Ref EcsHostSecurityGroup
|
| 318 |
+
IpProtocol: -1
|
| 319 |
+
SourceSecurityGroupId: !Ref PrivateLoadBalancerSG
|
| 320 |
+
|
| 321 |
+
EcsSecurityGroupIngressFromSelf:
|
| 322 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 323 |
+
Properties:
|
| 324 |
+
Description: Ingress from other containers in the same security group
|
| 325 |
+
GroupId: !Ref EcsHostSecurityGroup
|
| 326 |
+
IpProtocol: -1
|
| 327 |
+
SourceSecurityGroupId: !Ref EcsHostSecurityGroup
|
| 328 |
+
|
| 329 |
+
# Autoscaling group. This launches the actual EC2 instances that will register
|
| 330 |
+
# themselves as members of the cluster, and run the docker containers.
|
| 331 |
+
ECSAutoScalingGroup:
|
| 332 |
+
CreationPolicy:
|
| 333 |
+
ResourceSignal:
|
| 334 |
+
Timeout: PT15M
|
| 335 |
+
UpdatePolicy:
|
| 336 |
+
AutoScalingReplacingUpdate:
|
| 337 |
+
WillReplace: true
|
| 338 |
+
Type: AWS::AutoScaling::AutoScalingGroup
|
| 339 |
+
Properties:
|
| 340 |
+
VPCZoneIdentifier:
|
| 341 |
+
- !Ref PrivateSubnetOne
|
| 342 |
+
- !Ref PrivateSubnetTwo
|
| 343 |
+
LaunchTemplate:
|
| 344 |
+
LaunchTemplateId: !Ref ContainerInstances
|
| 345 |
+
Version: !GetAtt ContainerInstances.LatestVersionNumber
|
| 346 |
+
MinSize: 1
|
| 347 |
+
MaxSize: !Ref MaxSize
|
| 348 |
+
DesiredCapacity: !Ref DesiredCapacity
|
| 349 |
+
|
| 350 |
+
ContainerInstances:
|
| 351 |
+
Type: AWS::EC2::LaunchTemplate
|
| 352 |
+
Properties:
|
| 353 |
+
LaunchTemplateData:
|
| 354 |
+
ImageId: !Ref ECSAMI
|
| 355 |
+
SecurityGroupIds:
|
| 356 |
+
- !Ref EcsHostSecurityGroup
|
| 357 |
+
InstanceType: !Ref InstanceType
|
| 358 |
+
IamInstanceProfile:
|
| 359 |
+
Arn: !GetAtt EC2InstanceProfile.Arn
|
| 360 |
+
UserData: !Base64
|
| 361 |
+
Fn::Sub: |
|
| 362 |
+
#!/bin/bash -xe
|
| 363 |
+
echo ECS_CLUSTER=${ECSCluster} >> /etc/ecs/ecs.config
|
| 364 |
+
yum install -y aws-cfn-bootstrap
|
| 365 |
+
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource ECSAutoScalingGroup --region ${AWS::Region}
|
| 366 |
+
|
| 367 |
+
AutoscalingRole:
|
| 368 |
+
Type: AWS::IAM::Role
|
| 369 |
+
Properties:
|
| 370 |
+
AssumeRolePolicyDocument:
|
| 371 |
+
Statement:
|
| 372 |
+
- Effect: Allow
|
| 373 |
+
Principal:
|
| 374 |
+
Service:
|
| 375 |
+
- application-autoscaling.amazonaws.com
|
| 376 |
+
Action:
|
| 377 |
+
- sts:AssumeRole
|
| 378 |
+
Path: /
|
| 379 |
+
Policies:
|
| 380 |
+
- PolicyName: service-autoscaling
|
| 381 |
+
PolicyDocument:
|
| 382 |
+
Statement:
|
| 383 |
+
- Effect: Allow
|
| 384 |
+
Action:
|
| 385 |
+
- application-autoscaling:*
|
| 386 |
+
- cloudwatch:DescribeAlarms
|
| 387 |
+
- cloudwatch:PutMetricAlarm
|
| 388 |
+
- ecs:DescribeServices
|
| 389 |
+
- ecs:UpdateService
|
| 390 |
+
Resource: '*'
|
| 391 |
+
|
| 392 |
+
EC2InstanceProfile:
|
| 393 |
+
Type: AWS::IAM::InstanceProfile
|
| 394 |
+
Properties:
|
| 395 |
+
Path: /
|
| 396 |
+
Roles:
|
| 397 |
+
- !Ref EC2Role
|
| 398 |
+
|
| 399 |
+
# Role for the EC2 hosts. This allows the ECS agent on the EC2 hosts
|
| 400 |
+
# to communciate with the ECS control plane, as well as download the docker
|
| 401 |
+
# images from ECR to run on your host.
|
| 402 |
+
EC2Role:
|
| 403 |
+
Type: AWS::IAM::Role
|
| 404 |
+
Properties:
|
| 405 |
+
AssumeRolePolicyDocument:
|
| 406 |
+
Statement:
|
| 407 |
+
- Effect: Allow
|
| 408 |
+
Principal:
|
| 409 |
+
Service:
|
| 410 |
+
- ec2.amazonaws.com
|
| 411 |
+
Action:
|
| 412 |
+
- sts:AssumeRole
|
| 413 |
+
Path: /
|
| 414 |
+
Policies:
|
| 415 |
+
- PolicyName: ecs-service
|
| 416 |
+
PolicyDocument:
|
| 417 |
+
Statement:
|
| 418 |
+
- Effect: Allow
|
| 419 |
+
Action:
|
| 420 |
+
- ecs:CreateCluster
|
| 421 |
+
- ecs:DeregisterContainerInstance
|
| 422 |
+
- ecs:DiscoverPollEndpoint
|
| 423 |
+
- ecs:Poll
|
| 424 |
+
- ecs:RegisterContainerInstance
|
| 425 |
+
- ecs:StartTelemetrySession
|
| 426 |
+
- ecs:Submit*
|
| 427 |
+
- logs:CreateLogStream
|
| 428 |
+
- logs:PutLogEvents
|
| 429 |
+
- ecr:GetAuthorizationToken
|
| 430 |
+
- ecr:BatchGetImage
|
| 431 |
+
- ecr:GetDownloadUrlForLayer
|
| 432 |
+
Resource: '*'
|
| 433 |
+
|
| 434 |
+
# Load balancers for getting traffic to containers.
|
| 435 |
+
# This sample template creates two load balancers:
|
| 436 |
+
#
|
| 437 |
+
# - One public load balancer, hosted in public subnets that is accessible
|
| 438 |
+
# to the public, and is intended to route traffic to one or more public
|
| 439 |
+
# facing services.
|
| 440 |
+
# - One private load balancer, hosted in private subnets, that only
|
| 441 |
+
# accepts traffic from other containers in the cluster, and is
|
| 442 |
+
# intended for private services that should not be accessed directly
|
| 443 |
+
# by the public.
|
| 444 |
+
|
| 445 |
+
# A public facing load balancer, this is used for accepting traffic from the public
|
| 446 |
+
# internet and directing it to public facing microservices
|
| 447 |
+
PublicLoadBalancerSG:
|
| 448 |
+
Type: AWS::EC2::SecurityGroup
|
| 449 |
+
Properties:
|
| 450 |
+
GroupDescription: Access to the public facing load balancer
|
| 451 |
+
VpcId: !Ref VPC
|
| 452 |
+
SecurityGroupIngress:
|
| 453 |
+
|
| 454 |
+
# Allow access to ALB from anywhere on the internet
|
| 455 |
+
- CidrIp: 0.0.0.0/0
|
| 456 |
+
IpProtocol: -1
|
| 457 |
+
|
| 458 |
+
PublicLoadBalancer:
|
| 459 |
+
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
|
| 460 |
+
Properties:
|
| 461 |
+
Scheme: internet-facing
|
| 462 |
+
LoadBalancerAttributes:
|
| 463 |
+
- Key: idle_timeout.timeout_seconds
|
| 464 |
+
Value: "30"
|
| 465 |
+
Subnets:
|
| 466 |
+
|
| 467 |
+
# The load balancer is placed into the public subnets, so that traffic
|
| 468 |
+
# from the internet can reach the load balancer directly via the internet gateway
|
| 469 |
+
- !Ref PublicSubnetOne
|
| 470 |
+
- !Ref PublicSubnetTwo
|
| 471 |
+
SecurityGroups:
|
| 472 |
+
- !Ref PublicLoadBalancerSG
|
| 473 |
+
|
| 474 |
+
# A dummy target group is used to setup the ALB to just drop traffic
|
| 475 |
+
# initially, before any real service target groups have been added.
|
| 476 |
+
DummyTargetGroupPublic:
|
| 477 |
+
Type: AWS::ElasticLoadBalancingV2::TargetGroup
|
| 478 |
+
Properties:
|
| 479 |
+
HealthCheckIntervalSeconds: 6
|
| 480 |
+
HealthCheckPath: /
|
| 481 |
+
HealthCheckProtocol: HTTP
|
| 482 |
+
HealthCheckTimeoutSeconds: 5
|
| 483 |
+
HealthyThresholdCount: 2
|
| 484 |
+
Name: !Join
|
| 485 |
+
- '-'
|
| 486 |
+
- - !Ref AWS::StackName
|
| 487 |
+
- drop-1
|
| 488 |
+
Port: 80
|
| 489 |
+
Protocol: HTTP
|
| 490 |
+
UnhealthyThresholdCount: 2
|
| 491 |
+
VpcId: !Ref VPC
|
| 492 |
+
|
| 493 |
+
PublicLoadBalancerListener:
|
| 494 |
+
Type: AWS::ElasticLoadBalancingV2::Listener
|
| 495 |
+
DependsOn:
|
| 496 |
+
- PublicLoadBalancer
|
| 497 |
+
Properties:
|
| 498 |
+
DefaultActions:
|
| 499 |
+
- TargetGroupArn: !Ref DummyTargetGroupPublic
|
| 500 |
+
Type: forward
|
| 501 |
+
LoadBalancerArn: !Ref PublicLoadBalancer
|
| 502 |
+
Port: 80
|
| 503 |
+
Protocol: HTTP
|
| 504 |
+
|
| 505 |
+
# An internal load balancer, this would be used for a service that is not
|
| 506 |
+
# directly accessible to the public, but instead should only receive traffic
|
| 507 |
+
# from your other services.
|
| 508 |
+
PrivateLoadBalancerSG:
|
| 509 |
+
Type: AWS::EC2::SecurityGroup
|
| 510 |
+
Properties:
|
| 511 |
+
GroupDescription: Access to the internal load balancer
|
| 512 |
+
VpcId: !Ref VPC
|
| 513 |
+
|
| 514 |
+
PrivateLoadBalancerIngressFromECS:
|
| 515 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 516 |
+
Properties:
|
| 517 |
+
Description: Only accept traffic from a container in the container host security group
|
| 518 |
+
GroupId: !Ref PrivateLoadBalancerSG
|
| 519 |
+
IpProtocol: -1
|
| 520 |
+
SourceSecurityGroupId: !Ref EcsHostSecurityGroup
|
| 521 |
+
|
| 522 |
+
PrivateLoadBalancer:
|
| 523 |
+
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
|
| 524 |
+
Properties:
|
| 525 |
+
Scheme: internal
|
| 526 |
+
LoadBalancerAttributes:
|
| 527 |
+
- Key: idle_timeout.timeout_seconds
|
| 528 |
+
Value: "30"
|
| 529 |
+
Subnets:
|
| 530 |
+
|
| 531 |
+
# This load balancer is put into the private subnet, so that there is no
|
| 532 |
+
# route for the public to even be able to access the private load balancer.
|
| 533 |
+
- !Ref PrivateSubnetOne
|
| 534 |
+
- !Ref PrivateSubnetTwo
|
| 535 |
+
SecurityGroups:
|
| 536 |
+
- !Ref PrivateLoadBalancerSG
|
| 537 |
+
|
| 538 |
+
# This dummy target group is used to setup the ALB to just drop traffic
|
| 539 |
+
# initially, before any real service target groups have been added.
|
| 540 |
+
DummyTargetGroupPrivate:
|
| 541 |
+
Type: AWS::ElasticLoadBalancingV2::TargetGroup
|
| 542 |
+
Properties:
|
| 543 |
+
HealthCheckIntervalSeconds: 6
|
| 544 |
+
HealthCheckPath: /
|
| 545 |
+
HealthCheckProtocol: HTTP
|
| 546 |
+
HealthCheckTimeoutSeconds: 5
|
| 547 |
+
HealthyThresholdCount: 2
|
| 548 |
+
Name: !Join
|
| 549 |
+
- '-'
|
| 550 |
+
- - !Ref AWS::StackName
|
| 551 |
+
- drop-2
|
| 552 |
+
Port: 80
|
| 553 |
+
Protocol: HTTP
|
| 554 |
+
UnhealthyThresholdCount: 2
|
| 555 |
+
VpcId: !Ref VPC
|
| 556 |
+
|
| 557 |
+
PrivateLoadBalancerListener:
|
| 558 |
+
Type: AWS::ElasticLoadBalancingV2::Listener
|
| 559 |
+
DependsOn:
|
| 560 |
+
- PrivateLoadBalancer
|
| 561 |
+
Properties:
|
| 562 |
+
DefaultActions:
|
| 563 |
+
- TargetGroupArn: !Ref DummyTargetGroupPrivate
|
| 564 |
+
Type: forward
|
| 565 |
+
LoadBalancerArn: !Ref PrivateLoadBalancer
|
| 566 |
+
Port: 80
|
| 567 |
+
Protocol: HTTP
|
| 568 |
+
|
| 569 |
+
# This is an IAM role which authorizes ECS to manage resources on your
|
| 570 |
+
# account on your behalf, such as updating your load balancer with the
|
| 571 |
+
# details of where your containers are, so that traffic can reach your
|
| 572 |
+
# containers.
|
| 573 |
+
ECSRole:
|
| 574 |
+
Type: AWS::IAM::Role
|
| 575 |
+
Properties:
|
| 576 |
+
AssumeRolePolicyDocument:
|
| 577 |
+
Statement:
|
| 578 |
+
- Effect: Allow
|
| 579 |
+
Principal:
|
| 580 |
+
Service:
|
| 581 |
+
- ecs.amazonaws.com
|
| 582 |
+
Action:
|
| 583 |
+
- sts:AssumeRole
|
| 584 |
+
Path: /
|
| 585 |
+
Policies:
|
| 586 |
+
- PolicyName: ecs-service
|
| 587 |
+
PolicyDocument:
|
| 588 |
+
Statement:
|
| 589 |
+
- Effect: Allow
|
| 590 |
+
Action:
|
| 591 |
+
|
| 592 |
+
# Rules which allow ECS to attach network interfaces to instances
|
| 593 |
+
# on your behalf in order for awsvpc networking mode to work right
|
| 594 |
+
- ec2:AttachNetworkInterface
|
| 595 |
+
- ec2:CreateNetworkInterface
|
| 596 |
+
- ec2:CreateNetworkInterfacePermission
|
| 597 |
+
- ec2:DeleteNetworkInterface
|
| 598 |
+
- ec2:DeleteNetworkInterfacePermission
|
| 599 |
+
- ec2:Describe*
|
| 600 |
+
- ec2:DetachNetworkInterface
|
| 601 |
+
|
| 602 |
+
# Rules which allow ECS to update load balancers on your behalf
|
| 603 |
+
# with the information sabout how to send traffic to your containers
|
| 604 |
+
- elasticloadbalancing:DeregisterInstancesFromLoadBalancer
|
| 605 |
+
- elasticloadbalancing:DeregisterTargets
|
| 606 |
+
- elasticloadbalancing:Describe*
|
| 607 |
+
- elasticloadbalancing:RegisterInstancesWithLoadBalancer
|
| 608 |
+
- elasticloadbalancing:RegisterTargets
|
| 609 |
+
Resource: '*'
|
| 610 |
+
|
| 611 |
+
# These are the values output by the CloudFormation template. Be careful
|
| 612 |
+
# about changing any of them, because of them are exported with specific
|
| 613 |
+
# names so that the other task related CF templates can use them.
|
| 614 |
+
Outputs:
|
| 615 |
+
ClusterName:
|
| 616 |
+
Description: The name of the ECS cluster
|
| 617 |
+
Value: !Ref ECSCluster
|
| 618 |
+
Export:
|
| 619 |
+
Name: !Join
|
| 620 |
+
- ':'
|
| 621 |
+
- - !Ref AWS::StackName
|
| 622 |
+
- ClusterName
|
| 623 |
+
|
| 624 |
+
InternalUrl:
|
| 625 |
+
Description: The url of the internal load balancer
|
| 626 |
+
Value: !Join
|
| 627 |
+
- ""
|
| 628 |
+
- - http://
|
| 629 |
+
- !GetAtt PrivateLoadBalancer.DNSName
|
| 630 |
+
Export:
|
| 631 |
+
Name: !Join
|
| 632 |
+
- ':'
|
| 633 |
+
- - !Ref AWS::StackName
|
| 634 |
+
- InternalUrl
|
| 635 |
+
|
| 636 |
+
ExternalUrl:
|
| 637 |
+
Description: The url of the external load balancer
|
| 638 |
+
Value: !Join
|
| 639 |
+
- ""
|
| 640 |
+
- - http://
|
| 641 |
+
- !GetAtt PublicLoadBalancer.DNSName
|
| 642 |
+
Export:
|
| 643 |
+
Name: !Join
|
| 644 |
+
- ':'
|
| 645 |
+
- - !Ref AWS::StackName
|
| 646 |
+
- ExternalUrl
|
| 647 |
+
|
| 648 |
+
ECSRole:
|
| 649 |
+
Description: The ARN of the ECS role
|
| 650 |
+
Value: !GetAtt ECSRole.Arn
|
| 651 |
+
Export:
|
| 652 |
+
Name: !Join
|
| 653 |
+
- ':'
|
| 654 |
+
- - !Ref AWS::StackName
|
| 655 |
+
- ECSRole
|
| 656 |
+
|
| 657 |
+
PublicListener:
|
| 658 |
+
Description: The ARN of the public load balancer's Listener
|
| 659 |
+
Value: !Ref PublicLoadBalancerListener
|
| 660 |
+
Export:
|
| 661 |
+
Name: !Join
|
| 662 |
+
- ':'
|
| 663 |
+
- - !Ref AWS::StackName
|
| 664 |
+
- PublicListener
|
| 665 |
+
|
| 666 |
+
PrivateListener:
|
| 667 |
+
Description: The ARN of the public load balancer's Listener
|
| 668 |
+
Value: !Ref PrivateLoadBalancerListener
|
| 669 |
+
Export:
|
| 670 |
+
Name: !Join
|
| 671 |
+
- ':'
|
| 672 |
+
- - !Ref AWS::StackName
|
| 673 |
+
- PrivateListener
|
| 674 |
+
|
| 675 |
+
VPCId:
|
| 676 |
+
Description: The ID of the VPC that this stack is deployed in
|
| 677 |
+
Value: !Ref VPC
|
| 678 |
+
Export:
|
| 679 |
+
Name: !Join
|
| 680 |
+
- ':'
|
| 681 |
+
- - !Ref AWS::StackName
|
| 682 |
+
- VPCId
|
| 683 |
+
|
| 684 |
+
PublicSubnetOne:
|
| 685 |
+
Description: Public subnet one
|
| 686 |
+
Value: !Ref PublicSubnetOne
|
| 687 |
+
Export:
|
| 688 |
+
Name: !Join
|
| 689 |
+
- ':'
|
| 690 |
+
- - !Ref AWS::StackName
|
| 691 |
+
- PublicSubnetOne
|
| 692 |
+
|
| 693 |
+
PublicSubnetTwo:
|
| 694 |
+
Description: Public subnet two
|
| 695 |
+
Value: !Ref PublicSubnetTwo
|
| 696 |
+
Export:
|
| 697 |
+
Name: !Join
|
| 698 |
+
- ':'
|
| 699 |
+
- - !Ref AWS::StackName
|
| 700 |
+
- PublicSubnetTwo
|
| 701 |
+
|
| 702 |
+
PrivateSubnetOne:
|
| 703 |
+
Description: Private subnet one
|
| 704 |
+
Value: !Ref PrivateSubnetOne
|
| 705 |
+
Export:
|
| 706 |
+
Name: !Join
|
| 707 |
+
- ':'
|
| 708 |
+
- - !Ref AWS::StackName
|
| 709 |
+
- PrivateSubnetOne
|
| 710 |
+
|
| 711 |
+
PrivateSubnetTwo:
|
| 712 |
+
Description: Private subnet two
|
| 713 |
+
Value: !Ref PrivateSubnetTwo
|
| 714 |
+
Export:
|
| 715 |
+
Name: !Join
|
| 716 |
+
- ':'
|
| 717 |
+
- - !Ref AWS::StackName
|
| 718 |
+
- PrivateSubnetTwo
|
| 719 |
+
|
| 720 |
+
EcsHostSecurityGroup:
|
| 721 |
+
Description: A security group used to allow containers to receive traffic
|
| 722 |
+
Value: !Ref EcsHostSecurityGroup
|
| 723 |
+
Export:
|
| 724 |
+
Name: !Join
|
| 725 |
+
- ':'
|
| 726 |
+
- - !Ref AWS::StackName
|
| 727 |
+
- EcsHostSecurityGroup
|
human_reference_dataset/aws-cloudformation-templates/ECS/EC2LaunchType/clusters/public-vpc.json
ADDED
|
@@ -0,0 +1,702 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "A stack for deploying containerized applications onto a cluster of EC2 hosts using Elastic Container Service. This stack runs containers on hosts that are in a public VPC subnet, and includes a public facing load balancer to register the services in.",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"DesiredCapacity": {
|
| 6 |
+
"Description": "Number of EC2 instances to launch in your ECS cluster.",
|
| 7 |
+
"Type": "Number",
|
| 8 |
+
"Default": "3"
|
| 9 |
+
},
|
| 10 |
+
"MaxSize": {
|
| 11 |
+
"Description": "Maximum number of EC2 instances that can be launched in your ECS cluster.",
|
| 12 |
+
"Type": "Number",
|
| 13 |
+
"Default": "6"
|
| 14 |
+
},
|
| 15 |
+
"ECSAMI": {
|
| 16 |
+
"Description": "AMI ID",
|
| 17 |
+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
|
| 18 |
+
"Default": "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id"
|
| 19 |
+
},
|
| 20 |
+
"InstanceType": {
|
| 21 |
+
"Description": "EC2 instance type",
|
| 22 |
+
"Type": "String",
|
| 23 |
+
"AllowedValues": [
|
| 24 |
+
"t3.micro",
|
| 25 |
+
"t3.small",
|
| 26 |
+
"t3.medium",
|
| 27 |
+
"t3.large",
|
| 28 |
+
"t2.micro",
|
| 29 |
+
"t2.small",
|
| 30 |
+
"t2.medium",
|
| 31 |
+
"t2.large",
|
| 32 |
+
"m3.medium",
|
| 33 |
+
"m3.large",
|
| 34 |
+
"m3.xlarge",
|
| 35 |
+
"m3.2xlarge",
|
| 36 |
+
"m4.large",
|
| 37 |
+
"m4.xlarge",
|
| 38 |
+
"m4.2xlarge",
|
| 39 |
+
"m4.4xlarge",
|
| 40 |
+
"m4.10xlarge",
|
| 41 |
+
"c4.large",
|
| 42 |
+
"c4.xlarge",
|
| 43 |
+
"c4.2xlarge",
|
| 44 |
+
"c4.4xlarge",
|
| 45 |
+
"c4.8xlarge",
|
| 46 |
+
"c3.large",
|
| 47 |
+
"c3.xlarge",
|
| 48 |
+
"c3.2xlarge",
|
| 49 |
+
"c3.4xlarge",
|
| 50 |
+
"c3.8xlarge",
|
| 51 |
+
"r3.large",
|
| 52 |
+
"r3.xlarge",
|
| 53 |
+
"r3.2xlarge",
|
| 54 |
+
"r3.4xlarge",
|
| 55 |
+
"r3.8xlarge",
|
| 56 |
+
"i2.xlarge",
|
| 57 |
+
"i2.2xlarge",
|
| 58 |
+
"i2.4xlarge",
|
| 59 |
+
"i2.8xlarge"
|
| 60 |
+
],
|
| 61 |
+
"Default": "c4.xlarge",
|
| 62 |
+
"ConstraintDescription": "Please choose a valid instance type."
|
| 63 |
+
}
|
| 64 |
+
},
|
| 65 |
+
"Mappings": {
|
| 66 |
+
"SubnetConfig": {
|
| 67 |
+
"VPC": {
|
| 68 |
+
"CIDR": "10.0.0.0/16"
|
| 69 |
+
},
|
| 70 |
+
"PublicOne": {
|
| 71 |
+
"CIDR": "10.0.0.0/24"
|
| 72 |
+
},
|
| 73 |
+
"PublicTwo": {
|
| 74 |
+
"CIDR": "10.0.1.0/24"
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
},
|
| 78 |
+
"Resources": {
|
| 79 |
+
"VPC": {
|
| 80 |
+
"Type": "AWS::EC2::VPC",
|
| 81 |
+
"Properties": {
|
| 82 |
+
"EnableDnsSupport": true,
|
| 83 |
+
"EnableDnsHostnames": true,
|
| 84 |
+
"CidrBlock": {
|
| 85 |
+
"Fn::FindInMap": [
|
| 86 |
+
"SubnetConfig",
|
| 87 |
+
"VPC",
|
| 88 |
+
"CIDR"
|
| 89 |
+
]
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
},
|
| 93 |
+
"PublicSubnetOne": {
|
| 94 |
+
"Type": "AWS::EC2::Subnet",
|
| 95 |
+
"Properties": {
|
| 96 |
+
"AvailabilityZone": {
|
| 97 |
+
"Fn::Select": [
|
| 98 |
+
0,
|
| 99 |
+
{
|
| 100 |
+
"Fn::GetAZs": {
|
| 101 |
+
"Ref": "AWS::Region"
|
| 102 |
+
}
|
| 103 |
+
}
|
| 104 |
+
]
|
| 105 |
+
},
|
| 106 |
+
"VpcId": {
|
| 107 |
+
"Ref": "VPC"
|
| 108 |
+
},
|
| 109 |
+
"CidrBlock": {
|
| 110 |
+
"Fn::FindInMap": [
|
| 111 |
+
"SubnetConfig",
|
| 112 |
+
"PublicOne",
|
| 113 |
+
"CIDR"
|
| 114 |
+
]
|
| 115 |
+
},
|
| 116 |
+
"MapPublicIpOnLaunch": true
|
| 117 |
+
}
|
| 118 |
+
},
|
| 119 |
+
"PublicSubnetTwo": {
|
| 120 |
+
"Type": "AWS::EC2::Subnet",
|
| 121 |
+
"Properties": {
|
| 122 |
+
"AvailabilityZone": {
|
| 123 |
+
"Fn::Select": [
|
| 124 |
+
1,
|
| 125 |
+
{
|
| 126 |
+
"Fn::GetAZs": {
|
| 127 |
+
"Ref": "AWS::Region"
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
]
|
| 131 |
+
},
|
| 132 |
+
"VpcId": {
|
| 133 |
+
"Ref": "VPC"
|
| 134 |
+
},
|
| 135 |
+
"CidrBlock": {
|
| 136 |
+
"Fn::FindInMap": [
|
| 137 |
+
"SubnetConfig",
|
| 138 |
+
"PublicTwo",
|
| 139 |
+
"CIDR"
|
| 140 |
+
]
|
| 141 |
+
},
|
| 142 |
+
"MapPublicIpOnLaunch": true
|
| 143 |
+
}
|
| 144 |
+
},
|
| 145 |
+
"InternetGateway": {
|
| 146 |
+
"Type": "AWS::EC2::InternetGateway"
|
| 147 |
+
},
|
| 148 |
+
"GatewayAttachement": {
|
| 149 |
+
"Type": "AWS::EC2::VPCGatewayAttachment",
|
| 150 |
+
"Properties": {
|
| 151 |
+
"VpcId": {
|
| 152 |
+
"Ref": "VPC"
|
| 153 |
+
},
|
| 154 |
+
"InternetGatewayId": {
|
| 155 |
+
"Ref": "InternetGateway"
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
},
|
| 159 |
+
"PublicRouteTable": {
|
| 160 |
+
"Type": "AWS::EC2::RouteTable",
|
| 161 |
+
"Properties": {
|
| 162 |
+
"VpcId": {
|
| 163 |
+
"Ref": "VPC"
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
},
|
| 167 |
+
"PublicRoute": {
|
| 168 |
+
"Type": "AWS::EC2::Route",
|
| 169 |
+
"DependsOn": "GatewayAttachement",
|
| 170 |
+
"Properties": {
|
| 171 |
+
"RouteTableId": {
|
| 172 |
+
"Ref": "PublicRouteTable"
|
| 173 |
+
},
|
| 174 |
+
"DestinationCidrBlock": "0.0.0.0/0",
|
| 175 |
+
"GatewayId": {
|
| 176 |
+
"Ref": "InternetGateway"
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
},
|
| 180 |
+
"PublicSubnetOneRouteTableAssociation": {
|
| 181 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 182 |
+
"Properties": {
|
| 183 |
+
"SubnetId": {
|
| 184 |
+
"Ref": "PublicSubnetOne"
|
| 185 |
+
},
|
| 186 |
+
"RouteTableId": {
|
| 187 |
+
"Ref": "PublicRouteTable"
|
| 188 |
+
}
|
| 189 |
+
}
|
| 190 |
+
},
|
| 191 |
+
"PublicSubnetTwoRouteTableAssociation": {
|
| 192 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 193 |
+
"Properties": {
|
| 194 |
+
"SubnetId": {
|
| 195 |
+
"Ref": "PublicSubnetTwo"
|
| 196 |
+
},
|
| 197 |
+
"RouteTableId": {
|
| 198 |
+
"Ref": "PublicRouteTable"
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
},
|
| 202 |
+
"ECSCluster": {
|
| 203 |
+
"Type": "AWS::ECS::Cluster"
|
| 204 |
+
},
|
| 205 |
+
"EcsHostSecurityGroup": {
|
| 206 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 207 |
+
"Properties": {
|
| 208 |
+
"GroupDescription": "Access to the ECS hosts that run containers",
|
| 209 |
+
"VpcId": {
|
| 210 |
+
"Ref": "VPC"
|
| 211 |
+
}
|
| 212 |
+
}
|
| 213 |
+
},
|
| 214 |
+
"EcsSecurityGroupIngressFromPublicALB": {
|
| 215 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 216 |
+
"Properties": {
|
| 217 |
+
"Description": "Ingress from the public ALB",
|
| 218 |
+
"GroupId": {
|
| 219 |
+
"Ref": "EcsHostSecurityGroup"
|
| 220 |
+
},
|
| 221 |
+
"IpProtocol": -1,
|
| 222 |
+
"SourceSecurityGroupId": {
|
| 223 |
+
"Ref": "PublicLoadBalancerSG"
|
| 224 |
+
}
|
| 225 |
+
}
|
| 226 |
+
},
|
| 227 |
+
"EcsSecurityGroupIngressFromSelf": {
|
| 228 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 229 |
+
"Properties": {
|
| 230 |
+
"Description": "Ingress from other hosts in the same security group",
|
| 231 |
+
"GroupId": {
|
| 232 |
+
"Ref": "EcsHostSecurityGroup"
|
| 233 |
+
},
|
| 234 |
+
"IpProtocol": -1,
|
| 235 |
+
"SourceSecurityGroupId": {
|
| 236 |
+
"Ref": "EcsHostSecurityGroup"
|
| 237 |
+
}
|
| 238 |
+
}
|
| 239 |
+
},
|
| 240 |
+
"ECSAutoScalingGroup": {
|
| 241 |
+
"CreationPolicy": {
|
| 242 |
+
"ResourceSignal": {
|
| 243 |
+
"Timeout": "PT15M"
|
| 244 |
+
}
|
| 245 |
+
},
|
| 246 |
+
"UpdatePolicy": {
|
| 247 |
+
"AutoScalingReplacingUpdate": {
|
| 248 |
+
"WillReplace": true
|
| 249 |
+
}
|
| 250 |
+
},
|
| 251 |
+
"Type": "AWS::AutoScaling::AutoScalingGroup",
|
| 252 |
+
"Properties": {
|
| 253 |
+
"VPCZoneIdentifier": [
|
| 254 |
+
{
|
| 255 |
+
"Ref": "PublicSubnetOne"
|
| 256 |
+
},
|
| 257 |
+
{
|
| 258 |
+
"Ref": "PublicSubnetTwo"
|
| 259 |
+
}
|
| 260 |
+
],
|
| 261 |
+
"LaunchConfigurationName": {
|
| 262 |
+
"Ref": "ContainerInstances"
|
| 263 |
+
},
|
| 264 |
+
"MinSize": "1",
|
| 265 |
+
"MaxSize": {
|
| 266 |
+
"Ref": "MaxSize"
|
| 267 |
+
},
|
| 268 |
+
"DesiredCapacity": {
|
| 269 |
+
"Ref": "DesiredCapacity"
|
| 270 |
+
}
|
| 271 |
+
}
|
| 272 |
+
},
|
| 273 |
+
"ContainerInstances": {
|
| 274 |
+
"Type": "AWS::AutoScaling::LaunchConfiguration",
|
| 275 |
+
"Properties": {
|
| 276 |
+
"ImageId": {
|
| 277 |
+
"Ref": "ECSAMI"
|
| 278 |
+
},
|
| 279 |
+
"SecurityGroups": [
|
| 280 |
+
{
|
| 281 |
+
"Ref": "EcsHostSecurityGroup"
|
| 282 |
+
}
|
| 283 |
+
],
|
| 284 |
+
"InstanceType": {
|
| 285 |
+
"Ref": "InstanceType"
|
| 286 |
+
},
|
| 287 |
+
"IamInstanceProfile": {
|
| 288 |
+
"Ref": "EC2InstanceProfile"
|
| 289 |
+
},
|
| 290 |
+
"UserData": {
|
| 291 |
+
"Fn::Base64": {
|
| 292 |
+
"Fn::Sub": "#!/bin/bash -xe\necho ECS_CLUSTER=${ECSCluster} >> /etc/ecs/ecs.config\nyum install -y aws-cfn-bootstrap\n/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource ECSAutoScalingGroup --region ${AWS::Region}\n"
|
| 293 |
+
}
|
| 294 |
+
}
|
| 295 |
+
}
|
| 296 |
+
},
|
| 297 |
+
"AutoscalingRole": {
|
| 298 |
+
"Type": "AWS::IAM::Role",
|
| 299 |
+
"Properties": {
|
| 300 |
+
"AssumeRolePolicyDocument": {
|
| 301 |
+
"Statement": [
|
| 302 |
+
{
|
| 303 |
+
"Effect": "Allow",
|
| 304 |
+
"Principal": {
|
| 305 |
+
"Service": [
|
| 306 |
+
"application-autoscaling.amazonaws.com"
|
| 307 |
+
]
|
| 308 |
+
},
|
| 309 |
+
"Action": [
|
| 310 |
+
"sts:AssumeRole"
|
| 311 |
+
]
|
| 312 |
+
}
|
| 313 |
+
]
|
| 314 |
+
},
|
| 315 |
+
"Path": "/",
|
| 316 |
+
"Policies": [
|
| 317 |
+
{
|
| 318 |
+
"PolicyName": "service-autoscaling",
|
| 319 |
+
"PolicyDocument": {
|
| 320 |
+
"Statement": [
|
| 321 |
+
{
|
| 322 |
+
"Effect": "Allow",
|
| 323 |
+
"Action": [
|
| 324 |
+
"application-autoscaling:*",
|
| 325 |
+
"cloudwatch:DescribeAlarms",
|
| 326 |
+
"cloudwatch:PutMetricAlarm",
|
| 327 |
+
"ecs:DescribeServices",
|
| 328 |
+
"ecs:UpdateService"
|
| 329 |
+
],
|
| 330 |
+
"Resource": "*"
|
| 331 |
+
}
|
| 332 |
+
]
|
| 333 |
+
}
|
| 334 |
+
}
|
| 335 |
+
]
|
| 336 |
+
}
|
| 337 |
+
},
|
| 338 |
+
"EC2InstanceProfile": {
|
| 339 |
+
"Type": "AWS::IAM::InstanceProfile",
|
| 340 |
+
"Properties": {
|
| 341 |
+
"Path": "/",
|
| 342 |
+
"Roles": [
|
| 343 |
+
{
|
| 344 |
+
"Ref": "EC2Role"
|
| 345 |
+
}
|
| 346 |
+
]
|
| 347 |
+
}
|
| 348 |
+
},
|
| 349 |
+
"EC2Role": {
|
| 350 |
+
"Type": "AWS::IAM::Role",
|
| 351 |
+
"Properties": {
|
| 352 |
+
"AssumeRolePolicyDocument": {
|
| 353 |
+
"Statement": [
|
| 354 |
+
{
|
| 355 |
+
"Effect": "Allow",
|
| 356 |
+
"Principal": {
|
| 357 |
+
"Service": [
|
| 358 |
+
"ec2.amazonaws.com"
|
| 359 |
+
]
|
| 360 |
+
},
|
| 361 |
+
"Action": [
|
| 362 |
+
"sts:AssumeRole"
|
| 363 |
+
]
|
| 364 |
+
}
|
| 365 |
+
]
|
| 366 |
+
},
|
| 367 |
+
"Path": "/",
|
| 368 |
+
"Policies": [
|
| 369 |
+
{
|
| 370 |
+
"PolicyName": "ecs-service",
|
| 371 |
+
"PolicyDocument": {
|
| 372 |
+
"Statement": [
|
| 373 |
+
{
|
| 374 |
+
"Effect": "Allow",
|
| 375 |
+
"Action": [
|
| 376 |
+
"ecs:CreateCluster",
|
| 377 |
+
"ecs:DeregisterContainerInstance",
|
| 378 |
+
"ecs:DiscoverPollEndpoint",
|
| 379 |
+
"ecs:Poll",
|
| 380 |
+
"ecs:RegisterContainerInstance",
|
| 381 |
+
"ecs:StartTelemetrySession",
|
| 382 |
+
"ecs:Submit*",
|
| 383 |
+
"logs:CreateLogStream",
|
| 384 |
+
"logs:PutLogEvents",
|
| 385 |
+
"ecr:GetAuthorizationToken",
|
| 386 |
+
"ecr:BatchGetImage",
|
| 387 |
+
"ecr:GetDownloadUrlForLayer"
|
| 388 |
+
],
|
| 389 |
+
"Resource": "*"
|
| 390 |
+
}
|
| 391 |
+
]
|
| 392 |
+
}
|
| 393 |
+
}
|
| 394 |
+
]
|
| 395 |
+
}
|
| 396 |
+
},
|
| 397 |
+
"PublicLoadBalancerSG": {
|
| 398 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 399 |
+
"Properties": {
|
| 400 |
+
"GroupDescription": "Access to the public facing load balancer",
|
| 401 |
+
"VpcId": {
|
| 402 |
+
"Ref": "VPC"
|
| 403 |
+
},
|
| 404 |
+
"SecurityGroupIngress": [
|
| 405 |
+
{
|
| 406 |
+
"CidrIp": "0.0.0.0/0",
|
| 407 |
+
"IpProtocol": -1
|
| 408 |
+
}
|
| 409 |
+
]
|
| 410 |
+
}
|
| 411 |
+
},
|
| 412 |
+
"PublicLoadBalancer": {
|
| 413 |
+
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
|
| 414 |
+
"Properties": {
|
| 415 |
+
"Scheme": "internet-facing",
|
| 416 |
+
"LoadBalancerAttributes": [
|
| 417 |
+
{
|
| 418 |
+
"Key": "idle_timeout.timeout_seconds",
|
| 419 |
+
"Value": "30"
|
| 420 |
+
}
|
| 421 |
+
],
|
| 422 |
+
"Subnets": [
|
| 423 |
+
{
|
| 424 |
+
"Ref": "PublicSubnetOne"
|
| 425 |
+
},
|
| 426 |
+
{
|
| 427 |
+
"Ref": "PublicSubnetTwo"
|
| 428 |
+
}
|
| 429 |
+
],
|
| 430 |
+
"SecurityGroups": [
|
| 431 |
+
{
|
| 432 |
+
"Ref": "PublicLoadBalancerSG"
|
| 433 |
+
}
|
| 434 |
+
]
|
| 435 |
+
}
|
| 436 |
+
},
|
| 437 |
+
"DummyTargetGroupPublic": {
|
| 438 |
+
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
|
| 439 |
+
"Properties": {
|
| 440 |
+
"HealthCheckIntervalSeconds": 6,
|
| 441 |
+
"HealthCheckPath": "/",
|
| 442 |
+
"HealthCheckProtocol": "HTTP",
|
| 443 |
+
"HealthCheckTimeoutSeconds": 5,
|
| 444 |
+
"HealthyThresholdCount": 2,
|
| 445 |
+
"Name": {
|
| 446 |
+
"Fn::Join": [
|
| 447 |
+
"-",
|
| 448 |
+
[
|
| 449 |
+
{
|
| 450 |
+
"Ref": "AWS::StackName"
|
| 451 |
+
},
|
| 452 |
+
"drop-1"
|
| 453 |
+
]
|
| 454 |
+
]
|
| 455 |
+
},
|
| 456 |
+
"Port": 80,
|
| 457 |
+
"Protocol": "HTTP",
|
| 458 |
+
"UnhealthyThresholdCount": 2,
|
| 459 |
+
"VpcId": {
|
| 460 |
+
"Ref": "VPC"
|
| 461 |
+
}
|
| 462 |
+
}
|
| 463 |
+
},
|
| 464 |
+
"PublicLoadBalancerListener": {
|
| 465 |
+
"Type": "AWS::ElasticLoadBalancingV2::Listener",
|
| 466 |
+
"DependsOn": [
|
| 467 |
+
"PublicLoadBalancer"
|
| 468 |
+
],
|
| 469 |
+
"Properties": {
|
| 470 |
+
"DefaultActions": [
|
| 471 |
+
{
|
| 472 |
+
"TargetGroupArn": {
|
| 473 |
+
"Ref": "DummyTargetGroupPublic"
|
| 474 |
+
},
|
| 475 |
+
"Type": "forward"
|
| 476 |
+
}
|
| 477 |
+
],
|
| 478 |
+
"LoadBalancerArn": {
|
| 479 |
+
"Ref": "PublicLoadBalancer"
|
| 480 |
+
},
|
| 481 |
+
"Port": 80,
|
| 482 |
+
"Protocol": "HTTP"
|
| 483 |
+
}
|
| 484 |
+
},
|
| 485 |
+
"ECSRole": {
|
| 486 |
+
"Type": "AWS::IAM::Role",
|
| 487 |
+
"Properties": {
|
| 488 |
+
"AssumeRolePolicyDocument": {
|
| 489 |
+
"Statement": [
|
| 490 |
+
{
|
| 491 |
+
"Effect": "Allow",
|
| 492 |
+
"Principal": {
|
| 493 |
+
"Service": [
|
| 494 |
+
"ecs.amazonaws.com"
|
| 495 |
+
]
|
| 496 |
+
},
|
| 497 |
+
"Action": [
|
| 498 |
+
"sts:AssumeRole"
|
| 499 |
+
]
|
| 500 |
+
}
|
| 501 |
+
]
|
| 502 |
+
},
|
| 503 |
+
"Path": "/",
|
| 504 |
+
"Policies": [
|
| 505 |
+
{
|
| 506 |
+
"PolicyName": "ecs-service",
|
| 507 |
+
"PolicyDocument": {
|
| 508 |
+
"Statement": [
|
| 509 |
+
{
|
| 510 |
+
"Effect": "Allow",
|
| 511 |
+
"Action": [
|
| 512 |
+
"ec2:AttachNetworkInterface",
|
| 513 |
+
"ec2:CreateNetworkInterface",
|
| 514 |
+
"ec2:CreateNetworkInterfacePermission",
|
| 515 |
+
"ec2:DeleteNetworkInterface",
|
| 516 |
+
"ec2:DeleteNetworkInterfacePermission",
|
| 517 |
+
"ec2:Describe*",
|
| 518 |
+
"ec2:DetachNetworkInterface",
|
| 519 |
+
"elasticloadbalancing:DeregisterInstancesFromLoadBalancer",
|
| 520 |
+
"elasticloadbalancing:DeregisterTargets",
|
| 521 |
+
"elasticloadbalancing:Describe*",
|
| 522 |
+
"elasticloadbalancing:RegisterInstancesWithLoadBalancer",
|
| 523 |
+
"elasticloadbalancing:RegisterTargets"
|
| 524 |
+
],
|
| 525 |
+
"Resource": "*"
|
| 526 |
+
}
|
| 527 |
+
]
|
| 528 |
+
}
|
| 529 |
+
}
|
| 530 |
+
]
|
| 531 |
+
}
|
| 532 |
+
}
|
| 533 |
+
},
|
| 534 |
+
"Outputs": {
|
| 535 |
+
"ClusterName": {
|
| 536 |
+
"Description": "The name of the ECS cluster",
|
| 537 |
+
"Value": {
|
| 538 |
+
"Ref": "ECSCluster"
|
| 539 |
+
},
|
| 540 |
+
"Export": {
|
| 541 |
+
"Name": {
|
| 542 |
+
"Fn::Join": [
|
| 543 |
+
":",
|
| 544 |
+
[
|
| 545 |
+
{
|
| 546 |
+
"Ref": "AWS::StackName"
|
| 547 |
+
},
|
| 548 |
+
"ClusterName"
|
| 549 |
+
]
|
| 550 |
+
]
|
| 551 |
+
}
|
| 552 |
+
}
|
| 553 |
+
},
|
| 554 |
+
"ExternalUrl": {
|
| 555 |
+
"Description": "The url of the external load balancer",
|
| 556 |
+
"Value": {
|
| 557 |
+
"Fn::Join": [
|
| 558 |
+
"",
|
| 559 |
+
[
|
| 560 |
+
"http://",
|
| 561 |
+
{
|
| 562 |
+
"Fn::GetAtt": [
|
| 563 |
+
"PublicLoadBalancer",
|
| 564 |
+
"DNSName"
|
| 565 |
+
]
|
| 566 |
+
}
|
| 567 |
+
]
|
| 568 |
+
]
|
| 569 |
+
},
|
| 570 |
+
"Export": {
|
| 571 |
+
"Name": {
|
| 572 |
+
"Fn::Join": [
|
| 573 |
+
":",
|
| 574 |
+
[
|
| 575 |
+
{
|
| 576 |
+
"Ref": "AWS::StackName"
|
| 577 |
+
},
|
| 578 |
+
"ExternalUrl"
|
| 579 |
+
]
|
| 580 |
+
]
|
| 581 |
+
}
|
| 582 |
+
}
|
| 583 |
+
},
|
| 584 |
+
"ECSRole": {
|
| 585 |
+
"Description": "The ARN of the ECS role",
|
| 586 |
+
"Value": {
|
| 587 |
+
"Fn::GetAtt": [
|
| 588 |
+
"ECSRole",
|
| 589 |
+
"Arn"
|
| 590 |
+
]
|
| 591 |
+
},
|
| 592 |
+
"Export": {
|
| 593 |
+
"Name": {
|
| 594 |
+
"Fn::Join": [
|
| 595 |
+
":",
|
| 596 |
+
[
|
| 597 |
+
{
|
| 598 |
+
"Ref": "AWS::StackName"
|
| 599 |
+
},
|
| 600 |
+
"ECSRole"
|
| 601 |
+
]
|
| 602 |
+
]
|
| 603 |
+
}
|
| 604 |
+
}
|
| 605 |
+
},
|
| 606 |
+
"PublicListener": {
|
| 607 |
+
"Description": "The ARN of the public load balancer's Listener",
|
| 608 |
+
"Value": {
|
| 609 |
+
"Ref": "PublicLoadBalancerListener"
|
| 610 |
+
},
|
| 611 |
+
"Export": {
|
| 612 |
+
"Name": {
|
| 613 |
+
"Fn::Join": [
|
| 614 |
+
":",
|
| 615 |
+
[
|
| 616 |
+
{
|
| 617 |
+
"Ref": "AWS::StackName"
|
| 618 |
+
},
|
| 619 |
+
"PublicListener"
|
| 620 |
+
]
|
| 621 |
+
]
|
| 622 |
+
}
|
| 623 |
+
}
|
| 624 |
+
},
|
| 625 |
+
"VPCId": {
|
| 626 |
+
"Description": "The ID of the VPC that this stack is deployed in",
|
| 627 |
+
"Value": {
|
| 628 |
+
"Ref": "VPC"
|
| 629 |
+
},
|
| 630 |
+
"Export": {
|
| 631 |
+
"Name": {
|
| 632 |
+
"Fn::Join": [
|
| 633 |
+
":",
|
| 634 |
+
[
|
| 635 |
+
{
|
| 636 |
+
"Ref": "AWS::StackName"
|
| 637 |
+
},
|
| 638 |
+
"VPCId"
|
| 639 |
+
]
|
| 640 |
+
]
|
| 641 |
+
}
|
| 642 |
+
}
|
| 643 |
+
},
|
| 644 |
+
"PublicSubnetOne": {
|
| 645 |
+
"Description": "Public subnet one",
|
| 646 |
+
"Value": {
|
| 647 |
+
"Ref": "PublicSubnetOne"
|
| 648 |
+
},
|
| 649 |
+
"Export": {
|
| 650 |
+
"Name": {
|
| 651 |
+
"Fn::Join": [
|
| 652 |
+
":",
|
| 653 |
+
[
|
| 654 |
+
{
|
| 655 |
+
"Ref": "AWS::StackName"
|
| 656 |
+
},
|
| 657 |
+
"PublicSubnetOne"
|
| 658 |
+
]
|
| 659 |
+
]
|
| 660 |
+
}
|
| 661 |
+
}
|
| 662 |
+
},
|
| 663 |
+
"PublicSubnetTwo": {
|
| 664 |
+
"Description": "Public subnet two",
|
| 665 |
+
"Value": {
|
| 666 |
+
"Ref": "PublicSubnetTwo"
|
| 667 |
+
},
|
| 668 |
+
"Export": {
|
| 669 |
+
"Name": {
|
| 670 |
+
"Fn::Join": [
|
| 671 |
+
":",
|
| 672 |
+
[
|
| 673 |
+
{
|
| 674 |
+
"Ref": "AWS::StackName"
|
| 675 |
+
},
|
| 676 |
+
"PublicSubnetTwo"
|
| 677 |
+
]
|
| 678 |
+
]
|
| 679 |
+
}
|
| 680 |
+
}
|
| 681 |
+
},
|
| 682 |
+
"EcsHostSecurityGroup": {
|
| 683 |
+
"Description": "A security group used to allow containers to receive traffic",
|
| 684 |
+
"Value": {
|
| 685 |
+
"Ref": "EcsHostSecurityGroup"
|
| 686 |
+
},
|
| 687 |
+
"Export": {
|
| 688 |
+
"Name": {
|
| 689 |
+
"Fn::Join": [
|
| 690 |
+
":",
|
| 691 |
+
[
|
| 692 |
+
{
|
| 693 |
+
"Ref": "AWS::StackName"
|
| 694 |
+
},
|
| 695 |
+
"EcsHostSecurityGroup"
|
| 696 |
+
]
|
| 697 |
+
]
|
| 698 |
+
}
|
| 699 |
+
}
|
| 700 |
+
}
|
| 701 |
+
}
|
| 702 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/ECS/EC2LaunchType/clusters/public-vpc.yaml
ADDED
|
@@ -0,0 +1,492 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: A stack for deploying containerized applications onto a cluster of EC2 hosts using Elastic Container Service. This stack runs containers on hosts that are in a public VPC subnet, and includes a public facing load balancer to register the services in.
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
DesiredCapacity:
|
| 7 |
+
Description: Number of EC2 instances to launch in your ECS cluster.
|
| 8 |
+
Type: Number
|
| 9 |
+
Default: "3"
|
| 10 |
+
|
| 11 |
+
MaxSize:
|
| 12 |
+
Description: Maximum number of EC2 instances that can be launched in your ECS cluster.
|
| 13 |
+
Type: Number
|
| 14 |
+
Default: "6"
|
| 15 |
+
|
| 16 |
+
ECSAMI:
|
| 17 |
+
Description: AMI ID
|
| 18 |
+
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
|
| 19 |
+
Default: /aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id
|
| 20 |
+
|
| 21 |
+
InstanceType:
|
| 22 |
+
Description: EC2 instance type
|
| 23 |
+
Type: String
|
| 24 |
+
AllowedValues:
|
| 25 |
+
- t3.micro
|
| 26 |
+
- t3.small
|
| 27 |
+
- t3.medium
|
| 28 |
+
- t3.large
|
| 29 |
+
- t2.micro
|
| 30 |
+
- t2.small
|
| 31 |
+
- t2.medium
|
| 32 |
+
- t2.large
|
| 33 |
+
- m3.medium
|
| 34 |
+
- m3.large
|
| 35 |
+
- m3.xlarge
|
| 36 |
+
- m3.2xlarge
|
| 37 |
+
- m4.large
|
| 38 |
+
- m4.xlarge
|
| 39 |
+
- m4.2xlarge
|
| 40 |
+
- m4.4xlarge
|
| 41 |
+
- m4.10xlarge
|
| 42 |
+
- c4.large
|
| 43 |
+
- c4.xlarge
|
| 44 |
+
- c4.2xlarge
|
| 45 |
+
- c4.4xlarge
|
| 46 |
+
- c4.8xlarge
|
| 47 |
+
- c3.large
|
| 48 |
+
- c3.xlarge
|
| 49 |
+
- c3.2xlarge
|
| 50 |
+
- c3.4xlarge
|
| 51 |
+
- c3.8xlarge
|
| 52 |
+
- r3.large
|
| 53 |
+
- r3.xlarge
|
| 54 |
+
- r3.2xlarge
|
| 55 |
+
- r3.4xlarge
|
| 56 |
+
- r3.8xlarge
|
| 57 |
+
- i2.xlarge
|
| 58 |
+
- i2.2xlarge
|
| 59 |
+
- i2.4xlarge
|
| 60 |
+
- i2.8xlarge
|
| 61 |
+
Default: c4.xlarge
|
| 62 |
+
ConstraintDescription: Please choose a valid instance type.
|
| 63 |
+
|
| 64 |
+
Mappings:
|
| 65 |
+
|
| 66 |
+
# Hard values for the subnet masks. These masks define
|
| 67 |
+
# the range of internal IP addresses that can be assigned.
|
| 68 |
+
# The VPC can have all IP's from 10.0.0.0 to 10.0.255.255
|
| 69 |
+
# There are two subnets which cover the ranges:
|
| 70 |
+
#
|
| 71 |
+
# 10.0.0.0 - 10.0.0.255
|
| 72 |
+
# 10.0.1.0 - 10.0.1.255
|
| 73 |
+
#
|
| 74 |
+
# If you need more IP addresses (perhaps you have so many
|
| 75 |
+
# instances that you run out) then you can customize these
|
| 76 |
+
# ranges to add more
|
| 77 |
+
SubnetConfig:
|
| 78 |
+
VPC:
|
| 79 |
+
CIDR: 10.0.0.0/16
|
| 80 |
+
PublicOne:
|
| 81 |
+
CIDR: 10.0.0.0/24
|
| 82 |
+
PublicTwo:
|
| 83 |
+
CIDR: 10.0.1.0/24
|
| 84 |
+
|
| 85 |
+
Resources:
|
| 86 |
+
|
| 87 |
+
# VPC in which containers will be networked.
|
| 88 |
+
# It has two public subnets
|
| 89 |
+
# We distribute the subnets across the first two available subnets
|
| 90 |
+
# for the region, for high availability.
|
| 91 |
+
VPC:
|
| 92 |
+
Type: AWS::EC2::VPC
|
| 93 |
+
Properties:
|
| 94 |
+
EnableDnsSupport: true
|
| 95 |
+
EnableDnsHostnames: true
|
| 96 |
+
CidrBlock: !FindInMap
|
| 97 |
+
- SubnetConfig
|
| 98 |
+
- VPC
|
| 99 |
+
- CIDR
|
| 100 |
+
|
| 101 |
+
# Two public subnets, where containers can have public IP addresses
|
| 102 |
+
PublicSubnetOne:
|
| 103 |
+
Type: AWS::EC2::Subnet
|
| 104 |
+
Properties:
|
| 105 |
+
AvailabilityZone: !Select
|
| 106 |
+
- 0
|
| 107 |
+
- !GetAZs
|
| 108 |
+
Ref: AWS::Region
|
| 109 |
+
VpcId: !Ref VPC
|
| 110 |
+
CidrBlock: !FindInMap
|
| 111 |
+
- SubnetConfig
|
| 112 |
+
- PublicOne
|
| 113 |
+
- CIDR
|
| 114 |
+
MapPublicIpOnLaunch: true
|
| 115 |
+
|
| 116 |
+
PublicSubnetTwo:
|
| 117 |
+
Type: AWS::EC2::Subnet
|
| 118 |
+
Properties:
|
| 119 |
+
AvailabilityZone: !Select
|
| 120 |
+
- 1
|
| 121 |
+
- !GetAZs
|
| 122 |
+
Ref: AWS::Region
|
| 123 |
+
VpcId: !Ref VPC
|
| 124 |
+
CidrBlock: !FindInMap
|
| 125 |
+
- SubnetConfig
|
| 126 |
+
- PublicTwo
|
| 127 |
+
- CIDR
|
| 128 |
+
MapPublicIpOnLaunch: true
|
| 129 |
+
|
| 130 |
+
# Setup networking resources for the public subnets. Containers
|
| 131 |
+
# in the public subnets have public IP addresses and the routing table
|
| 132 |
+
# sends network traffic via the internet gateway.
|
| 133 |
+
InternetGateway:
|
| 134 |
+
Type: AWS::EC2::InternetGateway
|
| 135 |
+
|
| 136 |
+
GatewayAttachement:
|
| 137 |
+
Type: AWS::EC2::VPCGatewayAttachment
|
| 138 |
+
Properties:
|
| 139 |
+
VpcId: !Ref VPC
|
| 140 |
+
InternetGatewayId: !Ref InternetGateway
|
| 141 |
+
|
| 142 |
+
PublicRouteTable:
|
| 143 |
+
Type: AWS::EC2::RouteTable
|
| 144 |
+
Properties:
|
| 145 |
+
VpcId: !Ref VPC
|
| 146 |
+
|
| 147 |
+
PublicRoute:
|
| 148 |
+
Type: AWS::EC2::Route
|
| 149 |
+
DependsOn: GatewayAttachement
|
| 150 |
+
Properties:
|
| 151 |
+
RouteTableId: !Ref PublicRouteTable
|
| 152 |
+
DestinationCidrBlock: 0.0.0.0/0
|
| 153 |
+
GatewayId: !Ref InternetGateway
|
| 154 |
+
|
| 155 |
+
PublicSubnetOneRouteTableAssociation:
|
| 156 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 157 |
+
Properties:
|
| 158 |
+
SubnetId: !Ref PublicSubnetOne
|
| 159 |
+
RouteTableId: !Ref PublicRouteTable
|
| 160 |
+
|
| 161 |
+
PublicSubnetTwoRouteTableAssociation:
|
| 162 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 163 |
+
Properties:
|
| 164 |
+
SubnetId: !Ref PublicSubnetTwo
|
| 165 |
+
RouteTableId: !Ref PublicRouteTable
|
| 166 |
+
|
| 167 |
+
# ECS Resources
|
| 168 |
+
ECSCluster:
|
| 169 |
+
Type: AWS::ECS::Cluster
|
| 170 |
+
|
| 171 |
+
# A security group for the EC2 hosts that will run the containers.
|
| 172 |
+
# Two rules, allowing network traffic from a public facing load
|
| 173 |
+
# balancer and from other hosts in the security group.
|
| 174 |
+
#
|
| 175 |
+
# Remove any of the following ingress rules that are not needed.
|
| 176 |
+
# If you want to make direct requests to a container using its
|
| 177 |
+
# public IP address you'll need to add a security group rule
|
| 178 |
+
# to allow traffic from all IP addresses.
|
| 179 |
+
EcsHostSecurityGroup:
|
| 180 |
+
Type: AWS::EC2::SecurityGroup
|
| 181 |
+
Properties:
|
| 182 |
+
GroupDescription: Access to the ECS hosts that run containers
|
| 183 |
+
VpcId: !Ref VPC
|
| 184 |
+
|
| 185 |
+
EcsSecurityGroupIngressFromPublicALB:
|
| 186 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 187 |
+
Properties:
|
| 188 |
+
Description: Ingress from the public ALB
|
| 189 |
+
GroupId: !Ref EcsHostSecurityGroup
|
| 190 |
+
IpProtocol: -1
|
| 191 |
+
SourceSecurityGroupId: !Ref PublicLoadBalancerSG
|
| 192 |
+
|
| 193 |
+
EcsSecurityGroupIngressFromSelf:
|
| 194 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 195 |
+
Properties:
|
| 196 |
+
Description: Ingress from other hosts in the same security group
|
| 197 |
+
GroupId: !Ref EcsHostSecurityGroup
|
| 198 |
+
IpProtocol: -1
|
| 199 |
+
SourceSecurityGroupId: !Ref EcsHostSecurityGroup
|
| 200 |
+
|
| 201 |
+
# Autoscaling group. This launches the actual EC2 instances that will register
|
| 202 |
+
# themselves as members of the cluster, and run the docker containers.
|
| 203 |
+
ECSAutoScalingGroup:
|
| 204 |
+
CreationPolicy:
|
| 205 |
+
ResourceSignal:
|
| 206 |
+
Timeout: PT15M
|
| 207 |
+
UpdatePolicy:
|
| 208 |
+
AutoScalingReplacingUpdate:
|
| 209 |
+
WillReplace: true
|
| 210 |
+
Type: AWS::AutoScaling::AutoScalingGroup
|
| 211 |
+
Properties:
|
| 212 |
+
VPCZoneIdentifier:
|
| 213 |
+
- !Ref PublicSubnetOne
|
| 214 |
+
- !Ref PublicSubnetTwo
|
| 215 |
+
LaunchTemplate:
|
| 216 |
+
LaunchTemplateId: !Ref ContainerInstances
|
| 217 |
+
Version: !GetAtt ContainerInstances.LatestVersionNumber
|
| 218 |
+
MinSize: "1"
|
| 219 |
+
MaxSize: !Ref MaxSize
|
| 220 |
+
DesiredCapacity: !Ref DesiredCapacity
|
| 221 |
+
|
| 222 |
+
ContainerInstances:
|
| 223 |
+
Type: AWS::EC2::LaunchTemplate
|
| 224 |
+
Properties:
|
| 225 |
+
LaunchTemplateData:
|
| 226 |
+
ImageId: !Ref ECSAMI
|
| 227 |
+
SecurityGroupIds:
|
| 228 |
+
- !Ref EcsHostSecurityGroup
|
| 229 |
+
InstanceType: !Ref InstanceType
|
| 230 |
+
IamInstanceProfile:
|
| 231 |
+
Arn: !GetAtt EC2InstanceProfile.Arn
|
| 232 |
+
UserData: !Base64
|
| 233 |
+
Fn::Sub: |
|
| 234 |
+
#!/bin/bash -xe
|
| 235 |
+
echo ECS_CLUSTER=${ECSCluster} >> /etc/ecs/ecs.config
|
| 236 |
+
yum install -y aws-cfn-bootstrap
|
| 237 |
+
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource ECSAutoScalingGroup --region ${AWS::Region}
|
| 238 |
+
|
| 239 |
+
AutoscalingRole:
|
| 240 |
+
Type: AWS::IAM::Role
|
| 241 |
+
Properties:
|
| 242 |
+
AssumeRolePolicyDocument:
|
| 243 |
+
Statement:
|
| 244 |
+
- Effect: Allow
|
| 245 |
+
Principal:
|
| 246 |
+
Service:
|
| 247 |
+
- application-autoscaling.amazonaws.com
|
| 248 |
+
Action:
|
| 249 |
+
- sts:AssumeRole
|
| 250 |
+
Path: /
|
| 251 |
+
Policies:
|
| 252 |
+
- PolicyName: service-autoscaling
|
| 253 |
+
PolicyDocument:
|
| 254 |
+
Statement:
|
| 255 |
+
- Effect: Allow
|
| 256 |
+
Action:
|
| 257 |
+
- application-autoscaling:*
|
| 258 |
+
- cloudwatch:DescribeAlarms
|
| 259 |
+
- cloudwatch:PutMetricAlarm
|
| 260 |
+
- ecs:DescribeServices
|
| 261 |
+
- ecs:UpdateService
|
| 262 |
+
Resource: '*'
|
| 263 |
+
|
| 264 |
+
EC2InstanceProfile:
|
| 265 |
+
Type: AWS::IAM::InstanceProfile
|
| 266 |
+
Properties:
|
| 267 |
+
Path: /
|
| 268 |
+
Roles:
|
| 269 |
+
- !Ref EC2Role
|
| 270 |
+
|
| 271 |
+
# Role for the EC2 hosts. This allows the ECS agent on the EC2 hosts
|
| 272 |
+
# to communciate with the ECS control plane, as well as download the docker
|
| 273 |
+
# images from ECR to run on your host.
|
| 274 |
+
EC2Role:
|
| 275 |
+
Type: AWS::IAM::Role
|
| 276 |
+
Properties:
|
| 277 |
+
AssumeRolePolicyDocument:
|
| 278 |
+
Statement:
|
| 279 |
+
- Effect: Allow
|
| 280 |
+
Principal:
|
| 281 |
+
Service:
|
| 282 |
+
- ec2.amazonaws.com
|
| 283 |
+
Action:
|
| 284 |
+
- sts:AssumeRole
|
| 285 |
+
Path: /
|
| 286 |
+
Policies:
|
| 287 |
+
- PolicyName: ecs-service
|
| 288 |
+
PolicyDocument:
|
| 289 |
+
Statement:
|
| 290 |
+
- Effect: Allow
|
| 291 |
+
Action:
|
| 292 |
+
- ecs:CreateCluster
|
| 293 |
+
- ecs:DeregisterContainerInstance
|
| 294 |
+
- ecs:DiscoverPollEndpoint
|
| 295 |
+
- ecs:Poll
|
| 296 |
+
- ecs:RegisterContainerInstance
|
| 297 |
+
- ecs:StartTelemetrySession
|
| 298 |
+
- ecs:Submit*
|
| 299 |
+
- logs:CreateLogStream
|
| 300 |
+
- logs:PutLogEvents
|
| 301 |
+
- ecr:GetAuthorizationToken
|
| 302 |
+
- ecr:BatchGetImage
|
| 303 |
+
- ecr:GetDownloadUrlForLayer
|
| 304 |
+
Resource: '*'
|
| 305 |
+
|
| 306 |
+
# Load balancers for getting traffic to containers.
|
| 307 |
+
# This sample template creates one load balancer:
|
| 308 |
+
#
|
| 309 |
+
# - One public load balancer, hosted in public subnets that is accessible
|
| 310 |
+
# to the public, and is intended to route traffic to one or more public
|
| 311 |
+
# facing services.
|
| 312 |
+
|
| 313 |
+
# A public facing load balancer, this is used for accepting traffic from the public
|
| 314 |
+
# internet and directing it to public facing microservices
|
| 315 |
+
PublicLoadBalancerSG:
|
| 316 |
+
Type: AWS::EC2::SecurityGroup
|
| 317 |
+
Properties:
|
| 318 |
+
GroupDescription: Access to the public facing load balancer
|
| 319 |
+
VpcId: !Ref VPC
|
| 320 |
+
SecurityGroupIngress:
|
| 321 |
+
|
| 322 |
+
# Allow access to ALB from anywhere on the internet
|
| 323 |
+
- CidrIp: 0.0.0.0/0
|
| 324 |
+
IpProtocol: -1
|
| 325 |
+
|
| 326 |
+
PublicLoadBalancer:
|
| 327 |
+
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
|
| 328 |
+
Properties:
|
| 329 |
+
Scheme: internet-facing
|
| 330 |
+
LoadBalancerAttributes:
|
| 331 |
+
- Key: idle_timeout.timeout_seconds
|
| 332 |
+
Value: "30"
|
| 333 |
+
Subnets:
|
| 334 |
+
|
| 335 |
+
# The load balancer is placed into the public subnets, so that traffic
|
| 336 |
+
# from the internet can reach the load balancer directly via the internet gateway
|
| 337 |
+
- !Ref PublicSubnetOne
|
| 338 |
+
- !Ref PublicSubnetTwo
|
| 339 |
+
SecurityGroups:
|
| 340 |
+
- !Ref PublicLoadBalancerSG
|
| 341 |
+
|
| 342 |
+
# A dummy target group is used to setup the ALB to just drop traffic
|
| 343 |
+
# initially, before any real service target groups have been added.
|
| 344 |
+
DummyTargetGroupPublic:
|
| 345 |
+
Type: AWS::ElasticLoadBalancingV2::TargetGroup
|
| 346 |
+
Properties:
|
| 347 |
+
HealthCheckIntervalSeconds: 6
|
| 348 |
+
HealthCheckPath: /
|
| 349 |
+
HealthCheckProtocol: HTTP
|
| 350 |
+
HealthCheckTimeoutSeconds: 5
|
| 351 |
+
HealthyThresholdCount: 2
|
| 352 |
+
Name: !Join
|
| 353 |
+
- '-'
|
| 354 |
+
- - !Ref AWS::StackName
|
| 355 |
+
- drop-1
|
| 356 |
+
Port: 80
|
| 357 |
+
Protocol: HTTP
|
| 358 |
+
UnhealthyThresholdCount: 2
|
| 359 |
+
VpcId: !Ref VPC
|
| 360 |
+
|
| 361 |
+
PublicLoadBalancerListener:
|
| 362 |
+
Type: AWS::ElasticLoadBalancingV2::Listener
|
| 363 |
+
DependsOn:
|
| 364 |
+
- PublicLoadBalancer
|
| 365 |
+
Properties:
|
| 366 |
+
DefaultActions:
|
| 367 |
+
- TargetGroupArn: !Ref DummyTargetGroupPublic
|
| 368 |
+
Type: forward
|
| 369 |
+
LoadBalancerArn: !Ref PublicLoadBalancer
|
| 370 |
+
Port: 80
|
| 371 |
+
Protocol: HTTP
|
| 372 |
+
|
| 373 |
+
# This is an IAM role which authorizes ECS to manage resources on your
|
| 374 |
+
# account on your behalf, such as updating your load balancer with the
|
| 375 |
+
# details of where your containers are, so that traffic can reach your
|
| 376 |
+
# containers.
|
| 377 |
+
ECSRole:
|
| 378 |
+
Type: AWS::IAM::Role
|
| 379 |
+
Properties:
|
| 380 |
+
AssumeRolePolicyDocument:
|
| 381 |
+
Statement:
|
| 382 |
+
- Effect: Allow
|
| 383 |
+
Principal:
|
| 384 |
+
Service:
|
| 385 |
+
- ecs.amazonaws.com
|
| 386 |
+
Action:
|
| 387 |
+
- sts:AssumeRole
|
| 388 |
+
Path: /
|
| 389 |
+
Policies:
|
| 390 |
+
- PolicyName: ecs-service
|
| 391 |
+
PolicyDocument:
|
| 392 |
+
Statement:
|
| 393 |
+
- Effect: Allow
|
| 394 |
+
Action:
|
| 395 |
+
|
| 396 |
+
# Rules which allow ECS to attach network interfaces to instances
|
| 397 |
+
# on your behalf in order for awsvpc networking mode to work right
|
| 398 |
+
- ec2:AttachNetworkInterface
|
| 399 |
+
- ec2:CreateNetworkInterface
|
| 400 |
+
- ec2:CreateNetworkInterfacePermission
|
| 401 |
+
- ec2:DeleteNetworkInterface
|
| 402 |
+
- ec2:DeleteNetworkInterfacePermission
|
| 403 |
+
- ec2:Describe*
|
| 404 |
+
- ec2:DetachNetworkInterface
|
| 405 |
+
|
| 406 |
+
# Rules which allow ECS to update load balancers on your behalf
|
| 407 |
+
# with the information sabout how to send traffic to your containers
|
| 408 |
+
- elasticloadbalancing:DeregisterInstancesFromLoadBalancer
|
| 409 |
+
- elasticloadbalancing:DeregisterTargets
|
| 410 |
+
- elasticloadbalancing:Describe*
|
| 411 |
+
- elasticloadbalancing:RegisterInstancesWithLoadBalancer
|
| 412 |
+
- elasticloadbalancing:RegisterTargets
|
| 413 |
+
Resource: '*'
|
| 414 |
+
|
| 415 |
+
# These are the values output by the CloudFormation template. Be careful
|
| 416 |
+
# about changing any of them, because of them are exported with specific
|
| 417 |
+
# names so that the other task related CF templates can use them.
|
| 418 |
+
Outputs:
|
| 419 |
+
ClusterName:
|
| 420 |
+
Description: The name of the ECS cluster
|
| 421 |
+
Value: !Ref ECSCluster
|
| 422 |
+
Export:
|
| 423 |
+
Name: !Join
|
| 424 |
+
- ':'
|
| 425 |
+
- - !Ref AWS::StackName
|
| 426 |
+
- ClusterName
|
| 427 |
+
|
| 428 |
+
ExternalUrl:
|
| 429 |
+
Description: The url of the external load balancer
|
| 430 |
+
Value: !Join
|
| 431 |
+
- ""
|
| 432 |
+
- - http://
|
| 433 |
+
- !GetAtt PublicLoadBalancer.DNSName
|
| 434 |
+
Export:
|
| 435 |
+
Name: !Join
|
| 436 |
+
- ':'
|
| 437 |
+
- - !Ref AWS::StackName
|
| 438 |
+
- ExternalUrl
|
| 439 |
+
|
| 440 |
+
ECSRole:
|
| 441 |
+
Description: The ARN of the ECS role
|
| 442 |
+
Value: !GetAtt ECSRole.Arn
|
| 443 |
+
Export:
|
| 444 |
+
Name: !Join
|
| 445 |
+
- ':'
|
| 446 |
+
- - !Ref AWS::StackName
|
| 447 |
+
- ECSRole
|
| 448 |
+
|
| 449 |
+
PublicListener:
|
| 450 |
+
Description: The ARN of the public load balancer's Listener
|
| 451 |
+
Value: !Ref PublicLoadBalancerListener
|
| 452 |
+
Export:
|
| 453 |
+
Name: !Join
|
| 454 |
+
- ':'
|
| 455 |
+
- - !Ref AWS::StackName
|
| 456 |
+
- PublicListener
|
| 457 |
+
|
| 458 |
+
VPCId:
|
| 459 |
+
Description: The ID of the VPC that this stack is deployed in
|
| 460 |
+
Value: !Ref VPC
|
| 461 |
+
Export:
|
| 462 |
+
Name: !Join
|
| 463 |
+
- ':'
|
| 464 |
+
- - !Ref AWS::StackName
|
| 465 |
+
- VPCId
|
| 466 |
+
|
| 467 |
+
PublicSubnetOne:
|
| 468 |
+
Description: Public subnet one
|
| 469 |
+
Value: !Ref PublicSubnetOne
|
| 470 |
+
Export:
|
| 471 |
+
Name: !Join
|
| 472 |
+
- ':'
|
| 473 |
+
- - !Ref AWS::StackName
|
| 474 |
+
- PublicSubnetOne
|
| 475 |
+
|
| 476 |
+
PublicSubnetTwo:
|
| 477 |
+
Description: Public subnet two
|
| 478 |
+
Value: !Ref PublicSubnetTwo
|
| 479 |
+
Export:
|
| 480 |
+
Name: !Join
|
| 481 |
+
- ':'
|
| 482 |
+
- - !Ref AWS::StackName
|
| 483 |
+
- PublicSubnetTwo
|
| 484 |
+
|
| 485 |
+
EcsHostSecurityGroup:
|
| 486 |
+
Description: A security group used to allow containers to receive traffic
|
| 487 |
+
Value: !Ref EcsHostSecurityGroup
|
| 488 |
+
Export:
|
| 489 |
+
Name: !Join
|
| 490 |
+
- ':'
|
| 491 |
+
- - !Ref AWS::StackName
|
| 492 |
+
- EcsHostSecurityGroup
|
human_reference_dataset/aws-cloudformation-templates/ECS/EC2LaunchType/services/private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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Deploy a service into an ECS cluster behind a private load balancer.",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"StackName": {
|
| 6 |
+
"Description": "The name of the parent cluster stack that you created. Necessary to locate and reference resources created by that stack.",
|
| 7 |
+
"Type": "String",
|
| 8 |
+
"Default": "production"
|
| 9 |
+
},
|
| 10 |
+
"ServiceName": {
|
| 11 |
+
"Description": "A name for the service",
|
| 12 |
+
"Type": "String",
|
| 13 |
+
"Default": "nginx"
|
| 14 |
+
},
|
| 15 |
+
"ImageUrl": {
|
| 16 |
+
"Description": "The url of a docker image that contains the application process that will handle the traffic for this service",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"Default": "nginx"
|
| 19 |
+
},
|
| 20 |
+
"ContainerPort": {
|
| 21 |
+
"Description": "What port number the application inside the docker container is binding to",
|
| 22 |
+
"Type": "Number",
|
| 23 |
+
"Default": 80
|
| 24 |
+
},
|
| 25 |
+
"ContainerCpu": {
|
| 26 |
+
"Description": "How much CPU to give the container. 1024 is 1 CPU",
|
| 27 |
+
"Type": "Number",
|
| 28 |
+
"Default": 256
|
| 29 |
+
},
|
| 30 |
+
"ContainerMemory": {
|
| 31 |
+
"Description": "How much memory in megabytes to give the container",
|
| 32 |
+
"Type": "Number",
|
| 33 |
+
"Default": 512
|
| 34 |
+
},
|
| 35 |
+
"Path": {
|
| 36 |
+
"Description": "A path on the public load balancer that this service should be connected to. Use * to send all load balancer traffic to this service.",
|
| 37 |
+
"Type": "String",
|
| 38 |
+
"Default": "*"
|
| 39 |
+
},
|
| 40 |
+
"Priority": {
|
| 41 |
+
"Description": "The priority for the routing rule added to the load balancer. This only applies if your have multiple services which have been assigned to different paths on the load balancer.",
|
| 42 |
+
"Type": "Number",
|
| 43 |
+
"Default": 1
|
| 44 |
+
},
|
| 45 |
+
"DesiredCount": {
|
| 46 |
+
"Description": "How many copies of the service task to run",
|
| 47 |
+
"Type": "Number",
|
| 48 |
+
"Default": 2
|
| 49 |
+
},
|
| 50 |
+
"Role": {
|
| 51 |
+
"Description": "(Optional) An IAM role to give the service's containers if the code within needs to access other AWS resources like S3 buckets, DynamoDB tables, etc",
|
| 52 |
+
"Type": "String",
|
| 53 |
+
"Default": ""
|
| 54 |
+
}
|
| 55 |
+
},
|
| 56 |
+
"Conditions": {
|
| 57 |
+
"HasCustomRole": {
|
| 58 |
+
"Fn::Not": [
|
| 59 |
+
{
|
| 60 |
+
"Fn::Equals": [
|
| 61 |
+
{
|
| 62 |
+
"Ref": "Role"
|
| 63 |
+
},
|
| 64 |
+
""
|
| 65 |
+
]
|
| 66 |
+
}
|
| 67 |
+
]
|
| 68 |
+
}
|
| 69 |
+
},
|
| 70 |
+
"Resources": {
|
| 71 |
+
"TaskDefinition": {
|
| 72 |
+
"Type": "AWS::ECS::TaskDefinition",
|
| 73 |
+
"Properties": {
|
| 74 |
+
"Family": {
|
| 75 |
+
"Ref": "ServiceName"
|
| 76 |
+
},
|
| 77 |
+
"Cpu": {
|
| 78 |
+
"Ref": "ContainerCpu"
|
| 79 |
+
},
|
| 80 |
+
"Memory": {
|
| 81 |
+
"Ref": "ContainerMemory"
|
| 82 |
+
},
|
| 83 |
+
"TaskRoleArn": {
|
| 84 |
+
"Fn::If": [
|
| 85 |
+
"HasCustomRole",
|
| 86 |
+
{
|
| 87 |
+
"Ref": "Role"
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
"Ref": "AWS::NoValue"
|
| 91 |
+
}
|
| 92 |
+
]
|
| 93 |
+
},
|
| 94 |
+
"ContainerDefinitions": [
|
| 95 |
+
{
|
| 96 |
+
"Name": {
|
| 97 |
+
"Ref": "ServiceName"
|
| 98 |
+
},
|
| 99 |
+
"Essential": true,
|
| 100 |
+
"Cpu": {
|
| 101 |
+
"Ref": "ContainerCpu"
|
| 102 |
+
},
|
| 103 |
+
"Memory": {
|
| 104 |
+
"Ref": "ContainerMemory"
|
| 105 |
+
},
|
| 106 |
+
"Image": {
|
| 107 |
+
"Ref": "ImageUrl"
|
| 108 |
+
},
|
| 109 |
+
"PortMappings": [
|
| 110 |
+
{
|
| 111 |
+
"ContainerPort": {
|
| 112 |
+
"Ref": "ContainerPort"
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
]
|
| 116 |
+
}
|
| 117 |
+
]
|
| 118 |
+
}
|
| 119 |
+
},
|
| 120 |
+
"Service": {
|
| 121 |
+
"Type": "AWS::ECS::Service",
|
| 122 |
+
"DependsOn": "LoadBalancerRule",
|
| 123 |
+
"Properties": {
|
| 124 |
+
"ServiceName": {
|
| 125 |
+
"Ref": "ServiceName"
|
| 126 |
+
},
|
| 127 |
+
"Cluster": {
|
| 128 |
+
"Fn::ImportValue": {
|
| 129 |
+
"Fn::Join": [
|
| 130 |
+
":",
|
| 131 |
+
[
|
| 132 |
+
{
|
| 133 |
+
"Ref": "StackName"
|
| 134 |
+
},
|
| 135 |
+
"ClusterName"
|
| 136 |
+
]
|
| 137 |
+
]
|
| 138 |
+
}
|
| 139 |
+
},
|
| 140 |
+
"DeploymentConfiguration": {
|
| 141 |
+
"MaximumPercent": 200,
|
| 142 |
+
"MinimumHealthyPercent": 75
|
| 143 |
+
},
|
| 144 |
+
"DesiredCount": {
|
| 145 |
+
"Ref": "DesiredCount"
|
| 146 |
+
},
|
| 147 |
+
"TaskDefinition": {
|
| 148 |
+
"Ref": "TaskDefinition"
|
| 149 |
+
},
|
| 150 |
+
"LoadBalancers": [
|
| 151 |
+
{
|
| 152 |
+
"ContainerName": {
|
| 153 |
+
"Ref": "ServiceName"
|
| 154 |
+
},
|
| 155 |
+
"ContainerPort": {
|
| 156 |
+
"Ref": "ContainerPort"
|
| 157 |
+
},
|
| 158 |
+
"TargetGroupArn": {
|
| 159 |
+
"Ref": "TargetGroup"
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
]
|
| 163 |
+
}
|
| 164 |
+
},
|
| 165 |
+
"TargetGroup": {
|
| 166 |
+
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
|
| 167 |
+
"Properties": {
|
| 168 |
+
"HealthCheckIntervalSeconds": 6,
|
| 169 |
+
"HealthCheckPath": "/",
|
| 170 |
+
"HealthCheckProtocol": "HTTP",
|
| 171 |
+
"HealthCheckTimeoutSeconds": 5,
|
| 172 |
+
"HealthyThresholdCount": 2,
|
| 173 |
+
"Name": {
|
| 174 |
+
"Ref": "ServiceName"
|
| 175 |
+
},
|
| 176 |
+
"Port": 80,
|
| 177 |
+
"Protocol": "HTTP",
|
| 178 |
+
"UnhealthyThresholdCount": 2,
|
| 179 |
+
"VpcId": {
|
| 180 |
+
"Fn::ImportValue": {
|
| 181 |
+
"Fn::Join": [
|
| 182 |
+
":",
|
| 183 |
+
[
|
| 184 |
+
{
|
| 185 |
+
"Ref": "StackName"
|
| 186 |
+
},
|
| 187 |
+
"VPCId"
|
| 188 |
+
]
|
| 189 |
+
]
|
| 190 |
+
}
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
},
|
| 194 |
+
"LoadBalancerRule": {
|
| 195 |
+
"Type": "AWS::ElasticLoadBalancingV2::ListenerRule",
|
| 196 |
+
"Properties": {
|
| 197 |
+
"Actions": [
|
| 198 |
+
{
|
| 199 |
+
"TargetGroupArn": {
|
| 200 |
+
"Ref": "TargetGroup"
|
| 201 |
+
},
|
| 202 |
+
"Type": "forward"
|
| 203 |
+
}
|
| 204 |
+
],
|
| 205 |
+
"Conditions": [
|
| 206 |
+
{
|
| 207 |
+
"Field": "path-pattern",
|
| 208 |
+
"Values": [
|
| 209 |
+
{
|
| 210 |
+
"Ref": "Path"
|
| 211 |
+
}
|
| 212 |
+
]
|
| 213 |
+
}
|
| 214 |
+
],
|
| 215 |
+
"ListenerArn": {
|
| 216 |
+
"Fn::ImportValue": {
|
| 217 |
+
"Fn::Join": [
|
| 218 |
+
":",
|
| 219 |
+
[
|
| 220 |
+
{
|
| 221 |
+
"Ref": "StackName"
|
| 222 |
+
},
|
| 223 |
+
"PrivateListener"
|
| 224 |
+
]
|
| 225 |
+
]
|
| 226 |
+
}
|
| 227 |
+
},
|
| 228 |
+
"Priority": {
|
| 229 |
+
"Ref": "Priority"
|
| 230 |
+
}
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
}
|
| 234 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/ECS/EC2LaunchType/services/private-service.yaml
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Deploy a service into an ECS cluster behind a private load balancer.
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
StackName:
|
| 7 |
+
Description: The name of the parent cluster stack that you created. Necessary to locate and reference resources created by that stack.
|
| 8 |
+
Type: String
|
| 9 |
+
Default: production
|
| 10 |
+
|
| 11 |
+
ServiceName:
|
| 12 |
+
Description: A name for the service
|
| 13 |
+
Type: String
|
| 14 |
+
Default: nginx
|
| 15 |
+
|
| 16 |
+
ImageUrl:
|
| 17 |
+
Description: The url of a docker image that contains the application process that will handle the traffic for this service
|
| 18 |
+
Type: String
|
| 19 |
+
Default: nginx
|
| 20 |
+
|
| 21 |
+
ContainerPort:
|
| 22 |
+
Description: What port number the application inside the docker container is binding to
|
| 23 |
+
Type: Number
|
| 24 |
+
Default: 80
|
| 25 |
+
|
| 26 |
+
ContainerCpu:
|
| 27 |
+
Description: How much CPU to give the container. 1024 is 1 CPU
|
| 28 |
+
Type: Number
|
| 29 |
+
Default: 256
|
| 30 |
+
|
| 31 |
+
ContainerMemory:
|
| 32 |
+
Description: How much memory in megabytes to give the container
|
| 33 |
+
Type: Number
|
| 34 |
+
Default: 512
|
| 35 |
+
|
| 36 |
+
Path:
|
| 37 |
+
Description: A path on the public load balancer that this service should be connected to. Use * to send all load balancer traffic to this service.
|
| 38 |
+
Type: String
|
| 39 |
+
Default: '*'
|
| 40 |
+
|
| 41 |
+
Priority:
|
| 42 |
+
Description: The priority for the routing rule added to the load balancer. This only applies if your have multiple services which have been assigned to different paths on the load balancer.
|
| 43 |
+
Type: Number
|
| 44 |
+
Default: 1
|
| 45 |
+
|
| 46 |
+
DesiredCount:
|
| 47 |
+
Description: How many copies of the service task to run
|
| 48 |
+
Type: Number
|
| 49 |
+
Default: 2
|
| 50 |
+
|
| 51 |
+
Role:
|
| 52 |
+
Description: (Optional) An IAM role to give the service's containers if the code within needs to access other AWS resources like S3 buckets, DynamoDB tables, etc
|
| 53 |
+
Type: String
|
| 54 |
+
Default: ""
|
| 55 |
+
|
| 56 |
+
Conditions:
|
| 57 |
+
HasCustomRole: !Not
|
| 58 |
+
- !Equals
|
| 59 |
+
- !Ref Role
|
| 60 |
+
- ""
|
| 61 |
+
|
| 62 |
+
Resources:
|
| 63 |
+
|
| 64 |
+
# The task definition. This is a simple metadata description of what
|
| 65 |
+
# container to run, and what resource requirements it has.
|
| 66 |
+
TaskDefinition:
|
| 67 |
+
Type: AWS::ECS::TaskDefinition
|
| 68 |
+
Properties:
|
| 69 |
+
Family: !Ref ServiceName
|
| 70 |
+
Cpu: !Ref ContainerCpu
|
| 71 |
+
Memory: !Ref ContainerMemory
|
| 72 |
+
TaskRoleArn: !If
|
| 73 |
+
- HasCustomRole
|
| 74 |
+
- !Ref Role
|
| 75 |
+
- !Ref AWS::NoValue
|
| 76 |
+
ContainerDefinitions:
|
| 77 |
+
- Name: !Ref ServiceName
|
| 78 |
+
Essential: true
|
| 79 |
+
Cpu: !Ref ContainerCpu
|
| 80 |
+
Memory: !Ref ContainerMemory
|
| 81 |
+
Image: !Ref ImageUrl
|
| 82 |
+
PortMappings:
|
| 83 |
+
- ContainerPort: !Ref ContainerPort
|
| 84 |
+
|
| 85 |
+
# The service. The service is a resource which allows you to run multiple
|
| 86 |
+
# copies of a type of task, and gather up their logs and metrics, as well
|
| 87 |
+
# as monitor the number of running tasks and replace any that have crashed
|
| 88 |
+
Service:
|
| 89 |
+
Type: AWS::ECS::Service
|
| 90 |
+
DependsOn: LoadBalancerRule
|
| 91 |
+
Properties:
|
| 92 |
+
ServiceName: !Ref ServiceName
|
| 93 |
+
Cluster: !ImportValue
|
| 94 |
+
Fn::Join:
|
| 95 |
+
- ':'
|
| 96 |
+
- - !Ref StackName
|
| 97 |
+
- ClusterName
|
| 98 |
+
DeploymentConfiguration:
|
| 99 |
+
MaximumPercent: 200
|
| 100 |
+
MinimumHealthyPercent: 75
|
| 101 |
+
DesiredCount: !Ref DesiredCount
|
| 102 |
+
TaskDefinition: !Ref TaskDefinition
|
| 103 |
+
LoadBalancers:
|
| 104 |
+
- ContainerName: !Ref ServiceName
|
| 105 |
+
ContainerPort: !Ref ContainerPort
|
| 106 |
+
TargetGroupArn: !Ref TargetGroup
|
| 107 |
+
|
| 108 |
+
# A target group. This is used for keeping track of all the tasks, and
|
| 109 |
+
# what IP addresses / port numbers they have. You can query it yourself,
|
| 110 |
+
# to use the addresses yourself, but most often this target group is just
|
| 111 |
+
# connected to an application load balancer, or network load balancer, so
|
| 112 |
+
# it can automatically distribute traffic across all the targets.
|
| 113 |
+
TargetGroup:
|
| 114 |
+
Type: AWS::ElasticLoadBalancingV2::TargetGroup
|
| 115 |
+
Properties:
|
| 116 |
+
HealthCheckIntervalSeconds: 6
|
| 117 |
+
HealthCheckPath: /
|
| 118 |
+
HealthCheckProtocol: HTTP
|
| 119 |
+
HealthCheckTimeoutSeconds: 5
|
| 120 |
+
HealthyThresholdCount: 2
|
| 121 |
+
Name: !Ref ServiceName
|
| 122 |
+
Port: 80
|
| 123 |
+
Protocol: HTTP
|
| 124 |
+
UnhealthyThresholdCount: 2
|
| 125 |
+
VpcId: !ImportValue
|
| 126 |
+
Fn::Join:
|
| 127 |
+
- ':'
|
| 128 |
+
- - !Ref StackName
|
| 129 |
+
- VPCId
|
| 130 |
+
|
| 131 |
+
# Create a rule on the load balancer for routing traffic to the target group
|
| 132 |
+
LoadBalancerRule:
|
| 133 |
+
Type: AWS::ElasticLoadBalancingV2::ListenerRule
|
| 134 |
+
Properties:
|
| 135 |
+
Actions:
|
| 136 |
+
- TargetGroupArn: !Ref TargetGroup
|
| 137 |
+
Type: forward
|
| 138 |
+
Conditions:
|
| 139 |
+
- Field: path-pattern
|
| 140 |
+
Values:
|
| 141 |
+
- !Ref Path
|
| 142 |
+
ListenerArn: !ImportValue
|
| 143 |
+
Fn::Join:
|
| 144 |
+
- ':'
|
| 145 |
+
- - !Ref StackName
|
| 146 |
+
- PrivateListener
|
| 147 |
+
Priority: !Ref Priority
|
human_reference_dataset/aws-cloudformation-templates/ECS/EC2LaunchType/services/public-service.json
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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STemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Deploy a service into an ECS cluster behind a public load balancer.",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"StackName": {
|
| 6 |
+
"Description": "The name of the parent cluster stack that you created. Necessary to locate and reference resources created by that stack.",
|
| 7 |
+
"Type": "String",
|
| 8 |
+
"Default": "production"
|
| 9 |
+
},
|
| 10 |
+
"ServiceName": {
|
| 11 |
+
"Description": "A name for the service",
|
| 12 |
+
"Type": "String",
|
| 13 |
+
"Default": "nginx"
|
| 14 |
+
},
|
| 15 |
+
"ImageUrl": {
|
| 16 |
+
"Description": "The url of a docker image that contains the application process that will handle the traffic for this service",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"Default": "nginx"
|
| 19 |
+
},
|
| 20 |
+
"ContainerPort": {
|
| 21 |
+
"Description": "What port number the application inside the docker container is binding to",
|
| 22 |
+
"Type": "Number",
|
| 23 |
+
"Default": 80
|
| 24 |
+
},
|
| 25 |
+
"ContainerCpu": {
|
| 26 |
+
"Description": "How much CPU to give the container. 1024 is 1 CPU",
|
| 27 |
+
"Type": "Number",
|
| 28 |
+
"Default": 256
|
| 29 |
+
},
|
| 30 |
+
"ContainerMemory": {
|
| 31 |
+
"Description": "How much memory in megabytes to give the container",
|
| 32 |
+
"Type": "Number",
|
| 33 |
+
"Default": 512
|
| 34 |
+
},
|
| 35 |
+
"Path": {
|
| 36 |
+
"Description": "A path on the public load balancer that this service should be connected to. Use * to send all load balancer traffic to this service.",
|
| 37 |
+
"Type": "String",
|
| 38 |
+
"Default": "*"
|
| 39 |
+
},
|
| 40 |
+
"Priority": {
|
| 41 |
+
"Description": "The priority for the routing rule added to the load balancer. This only applies if your have multiple services which have been assigned to different paths on the load balancer.",
|
| 42 |
+
"Type": "Number",
|
| 43 |
+
"Default": 1
|
| 44 |
+
},
|
| 45 |
+
"DesiredCount": {
|
| 46 |
+
"Description": "How many copies of the service task to run",
|
| 47 |
+
"Type": "Number",
|
| 48 |
+
"Default": 2
|
| 49 |
+
},
|
| 50 |
+
"Role": {
|
| 51 |
+
"Description": "(Optional) An IAM role to give the service's containers if the code within needs to access other AWS resources like S3 buckets, DynamoDB tables, etc",
|
| 52 |
+
"Type": "String",
|
| 53 |
+
"Default": ""
|
| 54 |
+
}
|
| 55 |
+
},
|
| 56 |
+
"Conditions": {
|
| 57 |
+
"HasCustomRole": {
|
| 58 |
+
"Fn::Not": [
|
| 59 |
+
{
|
| 60 |
+
"Fn::Equals": [
|
| 61 |
+
{
|
| 62 |
+
"Ref": "Role"
|
| 63 |
+
},
|
| 64 |
+
""
|
| 65 |
+
]
|
| 66 |
+
}
|
| 67 |
+
]
|
| 68 |
+
}
|
| 69 |
+
},
|
| 70 |
+
"Resources": {
|
| 71 |
+
"TaskDefinition": {
|
| 72 |
+
"Type": "AWS::ECS::TaskDefinition",
|
| 73 |
+
"Properties": {
|
| 74 |
+
"Family": {
|
| 75 |
+
"Ref": "ServiceName"
|
| 76 |
+
},
|
| 77 |
+
"Cpu": {
|
| 78 |
+
"Ref": "ContainerCpu"
|
| 79 |
+
},
|
| 80 |
+
"Memory": {
|
| 81 |
+
"Ref": "ContainerMemory"
|
| 82 |
+
},
|
| 83 |
+
"TaskRoleArn": {
|
| 84 |
+
"Fn::If": [
|
| 85 |
+
"HasCustomRole",
|
| 86 |
+
{
|
| 87 |
+
"Ref": "Role"
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
"Ref": "AWS::NoValue"
|
| 91 |
+
}
|
| 92 |
+
]
|
| 93 |
+
},
|
| 94 |
+
"ContainerDefinitions": [
|
| 95 |
+
{
|
| 96 |
+
"Name": {
|
| 97 |
+
"Ref": "ServiceName"
|
| 98 |
+
},
|
| 99 |
+
"Essential": true,
|
| 100 |
+
"Cpu": {
|
| 101 |
+
"Ref": "ContainerCpu"
|
| 102 |
+
},
|
| 103 |
+
"Memory": {
|
| 104 |
+
"Ref": "ContainerMemory"
|
| 105 |
+
},
|
| 106 |
+
"Image": {
|
| 107 |
+
"Ref": "ImageUrl"
|
| 108 |
+
},
|
| 109 |
+
"PortMappings": [
|
| 110 |
+
{
|
| 111 |
+
"ContainerPort": {
|
| 112 |
+
"Ref": "ContainerPort"
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
]
|
| 116 |
+
}
|
| 117 |
+
]
|
| 118 |
+
}
|
| 119 |
+
},
|
| 120 |
+
"Service": {
|
| 121 |
+
"Type": "AWS::ECS::Service",
|
| 122 |
+
"DependsOn": "LoadBalancerRule",
|
| 123 |
+
"Properties": {
|
| 124 |
+
"ServiceName": {
|
| 125 |
+
"Ref": "ServiceName"
|
| 126 |
+
},
|
| 127 |
+
"Cluster": {
|
| 128 |
+
"Fn::ImportValue": {
|
| 129 |
+
"Fn::Join": [
|
| 130 |
+
":",
|
| 131 |
+
[
|
| 132 |
+
{
|
| 133 |
+
"Ref": "StackName"
|
| 134 |
+
},
|
| 135 |
+
"ClusterName"
|
| 136 |
+
]
|
| 137 |
+
]
|
| 138 |
+
}
|
| 139 |
+
},
|
| 140 |
+
"DeploymentConfiguration": {
|
| 141 |
+
"MaximumPercent": 200,
|
| 142 |
+
"MinimumHealthyPercent": 75
|
| 143 |
+
},
|
| 144 |
+
"DesiredCount": {
|
| 145 |
+
"Ref": "DesiredCount"
|
| 146 |
+
},
|
| 147 |
+
"TaskDefinition": {
|
| 148 |
+
"Ref": "TaskDefinition"
|
| 149 |
+
},
|
| 150 |
+
"LoadBalancers": [
|
| 151 |
+
{
|
| 152 |
+
"ContainerName": {
|
| 153 |
+
"Ref": "ServiceName"
|
| 154 |
+
},
|
| 155 |
+
"ContainerPort": {
|
| 156 |
+
"Ref": "ContainerPort"
|
| 157 |
+
},
|
| 158 |
+
"TargetGroupArn": {
|
| 159 |
+
"Ref": "TargetGroup"
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
]
|
| 163 |
+
}
|
| 164 |
+
},
|
| 165 |
+
"TargetGroup": {
|
| 166 |
+
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
|
| 167 |
+
"Properties": {
|
| 168 |
+
"HealthCheckIntervalSeconds": 6,
|
| 169 |
+
"HealthCheckPath": "/",
|
| 170 |
+
"HealthCheckProtocol": "HTTP",
|
| 171 |
+
"HealthCheckTimeoutSeconds": 5,
|
| 172 |
+
"HealthyThresholdCount": 2,
|
| 173 |
+
"Name": {
|
| 174 |
+
"Ref": "ServiceName"
|
| 175 |
+
},
|
| 176 |
+
"Port": 80,
|
| 177 |
+
"Protocol": "HTTP",
|
| 178 |
+
"UnhealthyThresholdCount": 2,
|
| 179 |
+
"VpcId": {
|
| 180 |
+
"Fn::ImportValue": {
|
| 181 |
+
"Fn::Join": [
|
| 182 |
+
":",
|
| 183 |
+
[
|
| 184 |
+
{
|
| 185 |
+
"Ref": "StackName"
|
| 186 |
+
},
|
| 187 |
+
"VPCId"
|
| 188 |
+
]
|
| 189 |
+
]
|
| 190 |
+
}
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
},
|
| 194 |
+
"LoadBalancerRule": {
|
| 195 |
+
"Type": "AWS::ElasticLoadBalancingV2::ListenerRule",
|
| 196 |
+
"Properties": {
|
| 197 |
+
"Actions": [
|
| 198 |
+
{
|
| 199 |
+
"TargetGroupArn": {
|
| 200 |
+
"Ref": "TargetGroup"
|
| 201 |
+
},
|
| 202 |
+
"Type": "forward"
|
| 203 |
+
}
|
| 204 |
+
],
|
| 205 |
+
"Conditions": [
|
| 206 |
+
{
|
| 207 |
+
"Field": "path-pattern",
|
| 208 |
+
"Values": [
|
| 209 |
+
{
|
| 210 |
+
"Ref": "Path"
|
| 211 |
+
}
|
| 212 |
+
]
|
| 213 |
+
}
|
| 214 |
+
],
|
| 215 |
+
"ListenerArn": {
|
| 216 |
+
"Fn::ImportValue": {
|
| 217 |
+
"Fn::Join": [
|
| 218 |
+
":",
|
| 219 |
+
[
|
| 220 |
+
{
|
| 221 |
+
"Ref": "StackName"
|
| 222 |
+
},
|
| 223 |
+
"PublicListener"
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Deploy a service into an ECS cluster behind a public load balancer.
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
StackName:
|
| 7 |
+
Description: The name of the parent cluster stack that you created. Necessary to locate and reference resources created by that stack.
|
| 8 |
+
Type: String
|
| 9 |
+
Default: production
|
| 10 |
+
|
| 11 |
+
ServiceName:
|
| 12 |
+
Description: A name for the service
|
| 13 |
+
Type: String
|
| 14 |
+
Default: nginx
|
| 15 |
+
|
| 16 |
+
ImageUrl:
|
| 17 |
+
Description: The url of a docker image that contains the application process that will handle the traffic for this service
|
| 18 |
+
Type: String
|
| 19 |
+
Default: nginx
|
| 20 |
+
|
| 21 |
+
ContainerPort:
|
| 22 |
+
Description: What port number the application inside the docker container is binding to
|
| 23 |
+
Type: Number
|
| 24 |
+
Default: 80
|
| 25 |
+
|
| 26 |
+
ContainerCpu:
|
| 27 |
+
Description: How much CPU to give the container. 1024 is 1 CPU
|
| 28 |
+
Type: Number
|
| 29 |
+
Default: 256
|
| 30 |
+
|
| 31 |
+
ContainerMemory:
|
| 32 |
+
Description: How much memory in megabytes to give the container
|
| 33 |
+
Type: Number
|
| 34 |
+
Default: 512
|
| 35 |
+
|
| 36 |
+
Path:
|
| 37 |
+
Description: A path on the public load balancer that this service should be connected to. Use * to send all load balancer traffic to this service.
|
| 38 |
+
Type: String
|
| 39 |
+
Default: '*'
|
| 40 |
+
|
| 41 |
+
Priority:
|
| 42 |
+
Description: The priority for the routing rule added to the load balancer. This only applies if your have multiple services which have been assigned to different paths on the load balancer.
|
| 43 |
+
Type: Number
|
| 44 |
+
Default: 1
|
| 45 |
+
|
| 46 |
+
DesiredCount:
|
| 47 |
+
Description: How many copies of the service task to run
|
| 48 |
+
Type: Number
|
| 49 |
+
Default: 2
|
| 50 |
+
|
| 51 |
+
Role:
|
| 52 |
+
Description: (Optional) An IAM role to give the service's containers if the code within needs to access other AWS resources like S3 buckets, DynamoDB tables, etc
|
| 53 |
+
Type: String
|
| 54 |
+
Default: ""
|
| 55 |
+
|
| 56 |
+
Conditions:
|
| 57 |
+
HasCustomRole: !Not
|
| 58 |
+
- !Equals
|
| 59 |
+
- !Ref Role
|
| 60 |
+
- ""
|
| 61 |
+
|
| 62 |
+
Resources:
|
| 63 |
+
|
| 64 |
+
# The task definition. This is a simple metadata description of what
|
| 65 |
+
# container to run, and what resource requirements it has.
|
| 66 |
+
TaskDefinition:
|
| 67 |
+
Type: AWS::ECS::TaskDefinition
|
| 68 |
+
Properties:
|
| 69 |
+
Family: !Ref ServiceName
|
| 70 |
+
Cpu: !Ref ContainerCpu
|
| 71 |
+
Memory: !Ref ContainerMemory
|
| 72 |
+
TaskRoleArn: !If
|
| 73 |
+
- HasCustomRole
|
| 74 |
+
- !Ref Role
|
| 75 |
+
- !Ref AWS::NoValue
|
| 76 |
+
ContainerDefinitions:
|
| 77 |
+
- Name: !Ref ServiceName
|
| 78 |
+
Essential: true
|
| 79 |
+
Cpu: !Ref ContainerCpu
|
| 80 |
+
Memory: !Ref ContainerMemory
|
| 81 |
+
Image: !Ref ImageUrl
|
| 82 |
+
PortMappings:
|
| 83 |
+
- ContainerPort: !Ref ContainerPort
|
| 84 |
+
|
| 85 |
+
# The service. The service is a resource which allows you to run multiple
|
| 86 |
+
# copies of a type of task, and gather up their logs and metrics, as well
|
| 87 |
+
# as monitor the number of running tasks and replace any that have crashed
|
| 88 |
+
Service:
|
| 89 |
+
Type: AWS::ECS::Service
|
| 90 |
+
DependsOn: LoadBalancerRule
|
| 91 |
+
Properties:
|
| 92 |
+
ServiceName: !Ref ServiceName
|
| 93 |
+
Cluster: !ImportValue
|
| 94 |
+
Fn::Join:
|
| 95 |
+
- ':'
|
| 96 |
+
- - !Ref StackName
|
| 97 |
+
- ClusterName
|
| 98 |
+
DeploymentConfiguration:
|
| 99 |
+
MaximumPercent: 200
|
| 100 |
+
MinimumHealthyPercent: 75
|
| 101 |
+
DesiredCount: !Ref DesiredCount
|
| 102 |
+
TaskDefinition: !Ref TaskDefinition
|
| 103 |
+
LoadBalancers:
|
| 104 |
+
- ContainerName: !Ref ServiceName
|
| 105 |
+
ContainerPort: !Ref ContainerPort
|
| 106 |
+
TargetGroupArn: !Ref TargetGroup
|
| 107 |
+
|
| 108 |
+
# A target group. This is used for keeping track of all the tasks, and
|
| 109 |
+
# what IP addresses / port numbers they have. You can query it yourself,
|
| 110 |
+
# to use the addresses yourself, but most often this target group is just
|
| 111 |
+
# connected to an application load balancer, or network load balancer, so
|
| 112 |
+
# it can automatically distribute traffic across all the targets.
|
| 113 |
+
TargetGroup:
|
| 114 |
+
Type: AWS::ElasticLoadBalancingV2::TargetGroup
|
| 115 |
+
Properties:
|
| 116 |
+
HealthCheckIntervalSeconds: 6
|
| 117 |
+
HealthCheckPath: /
|
| 118 |
+
HealthCheckProtocol: HTTP
|
| 119 |
+
HealthCheckTimeoutSeconds: 5
|
| 120 |
+
HealthyThresholdCount: 2
|
| 121 |
+
Name: !Ref ServiceName
|
| 122 |
+
Port: 80
|
| 123 |
+
Protocol: HTTP
|
| 124 |
+
UnhealthyThresholdCount: 2
|
| 125 |
+
VpcId: !ImportValue
|
| 126 |
+
Fn::Join:
|
| 127 |
+
- ':'
|
| 128 |
+
- - !Ref StackName
|
| 129 |
+
- VPCId
|
| 130 |
+
|
| 131 |
+
# Create a rule on the load balancer for routing traffic to the target group
|
| 132 |
+
LoadBalancerRule:
|
| 133 |
+
Type: AWS::ElasticLoadBalancingV2::ListenerRule
|
| 134 |
+
Properties:
|
| 135 |
+
Actions:
|
| 136 |
+
- TargetGroupArn: !Ref TargetGroup
|
| 137 |
+
Type: forward
|
| 138 |
+
Conditions:
|
| 139 |
+
- Field: path-pattern
|
| 140 |
+
Values:
|
| 141 |
+
- !Ref Path
|
| 142 |
+
ListenerArn: !ImportValue
|
| 143 |
+
Fn::Join:
|
| 144 |
+
- ':'
|
| 145 |
+
- - !Ref StackName
|
| 146 |
+
- PublicListener
|
| 147 |
+
Priority: !Ref Priority
|
human_reference_dataset/aws-cloudformation-templates/ECS/ECS_Schedule_Example.json
ADDED
|
@@ -0,0 +1,768 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Amazon ECS Time and Event-Based Task Scheduling with CloudFormation. This will let you run tasks on a regular, scheduled basis and in response to CloudWatch Events. It easier to launch and stop container services that you need to run only at certain times. For example a backup/cleanup task.",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"KeyName": {
|
| 6 |
+
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the ECS instances.",
|
| 7 |
+
"Type": "AWS::EC2::KeyPair::KeyName"
|
| 8 |
+
},
|
| 9 |
+
"VpcId": {
|
| 10 |
+
"Description": "Select a VPC that allows instances to access the Internet.",
|
| 11 |
+
"Type": "AWS::EC2::VPC::Id"
|
| 12 |
+
},
|
| 13 |
+
"SubnetId": {
|
| 14 |
+
"Description": "Select at two subnets in your selected VPC.",
|
| 15 |
+
"Type": "List<AWS::EC2::Subnet::Id>"
|
| 16 |
+
},
|
| 17 |
+
"DesiredCapacity": {
|
| 18 |
+
"Description": "Number of instances to launch in your ECS cluster.",
|
| 19 |
+
"Type": "Number",
|
| 20 |
+
"Default": 1
|
| 21 |
+
},
|
| 22 |
+
"MaxSize": {
|
| 23 |
+
"Description": "Maximum number of instances that can be launched in your ECS cluster.",
|
| 24 |
+
"Type": "Number",
|
| 25 |
+
"Default": 1
|
| 26 |
+
},
|
| 27 |
+
"SchedulerTasksCount": {
|
| 28 |
+
"Description": "Maximum number of Tasks that you want to the Scheduler to run",
|
| 29 |
+
"Type": "Number",
|
| 30 |
+
"Default": 1
|
| 31 |
+
},
|
| 32 |
+
"CronOrRate": {
|
| 33 |
+
"Description": "Choose to use a cron expression or a rate expression you want to use.",
|
| 34 |
+
"Type": "String",
|
| 35 |
+
"AllowedValues": [
|
| 36 |
+
"cron",
|
| 37 |
+
"rate"
|
| 38 |
+
],
|
| 39 |
+
"Default": "cron"
|
| 40 |
+
},
|
| 41 |
+
"CronSchedule": {
|
| 42 |
+
"Description": "This defines the Schedule at which to run the. Cron Expressions - http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html#CronExpressions",
|
| 43 |
+
"Type": "String",
|
| 44 |
+
"Default": "cron(00 11 ? * * *)"
|
| 45 |
+
},
|
| 46 |
+
"RateSchedule": {
|
| 47 |
+
"Description": "This defines the Schedule at which to run the. Rate Expressions - http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html#RateExpressions",
|
| 48 |
+
"Type": "String",
|
| 49 |
+
"Default": "rate(1 day)"
|
| 50 |
+
},
|
| 51 |
+
"InstanceType": {
|
| 52 |
+
"Description": "EC2 instance type",
|
| 53 |
+
"Type": "String",
|
| 54 |
+
"AllowedValues": [
|
| 55 |
+
"t2.micro",
|
| 56 |
+
"t2.small",
|
| 57 |
+
"t2.medium",
|
| 58 |
+
"t2.large",
|
| 59 |
+
"m3.medium",
|
| 60 |
+
"m3.large",
|
| 61 |
+
"m3.xlarge",
|
| 62 |
+
"m3.2xlarge",
|
| 63 |
+
"m4.large",
|
| 64 |
+
"m4.xlarge",
|
| 65 |
+
"m4.2xlarge",
|
| 66 |
+
"m4.4xlarge",
|
| 67 |
+
"m4.10xlarge",
|
| 68 |
+
"c4.large",
|
| 69 |
+
"c4.xlarge",
|
| 70 |
+
"c4.2xlarge",
|
| 71 |
+
"c4.4xlarge",
|
| 72 |
+
"c4.8xlarge",
|
| 73 |
+
"c3.large",
|
| 74 |
+
"c3.xlarge",
|
| 75 |
+
"c3.2xlarge",
|
| 76 |
+
"c3.4xlarge",
|
| 77 |
+
"c3.8xlarge",
|
| 78 |
+
"r3.large",
|
| 79 |
+
"r3.xlarge",
|
| 80 |
+
"r3.2xlarge",
|
| 81 |
+
"r3.4xlarge",
|
| 82 |
+
"r3.8xlarge",
|
| 83 |
+
"i2.xlarge",
|
| 84 |
+
"i2.2xlarge",
|
| 85 |
+
"i2.4xlarge",
|
| 86 |
+
"i2.8xlarge"
|
| 87 |
+
],
|
| 88 |
+
"Default": "t2.micro",
|
| 89 |
+
"ConstraintDescription": "Please choose a valid instance type."
|
| 90 |
+
},
|
| 91 |
+
"LatestAmiId": {
|
| 92 |
+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
|
| 93 |
+
"Default": "/aws/service/ecs/optimized-ami/amazon-linux-2023/recommended/image_id"
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
"Conditions": {
|
| 97 |
+
"CronRate": {
|
| 98 |
+
"Fn::Equals": [
|
| 99 |
+
{
|
| 100 |
+
"Ref": "CronOrRate"
|
| 101 |
+
},
|
| 102 |
+
"cron"
|
| 103 |
+
]
|
| 104 |
+
}
|
| 105 |
+
},
|
| 106 |
+
"Resources": {
|
| 107 |
+
"ECSCluster": {
|
| 108 |
+
"Type": "AWS::ECS::Cluster"
|
| 109 |
+
},
|
| 110 |
+
"EcsSecurityGroup": {
|
| 111 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 112 |
+
"Properties": {
|
| 113 |
+
"GroupDescription": "ECS Security Group",
|
| 114 |
+
"VpcId": {
|
| 115 |
+
"Ref": "VpcId"
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
},
|
| 119 |
+
"EcsSecurityGroupHTTPinbound": {
|
| 120 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 121 |
+
"Properties": {
|
| 122 |
+
"GroupId": {
|
| 123 |
+
"Ref": "EcsSecurityGroup"
|
| 124 |
+
},
|
| 125 |
+
"IpProtocol": "tcp",
|
| 126 |
+
"FromPort": "80",
|
| 127 |
+
"ToPort": "80",
|
| 128 |
+
"CidrIp": "0.0.0.0/0"
|
| 129 |
+
}
|
| 130 |
+
},
|
| 131 |
+
"EcsSecurityGroupSSHinbound": {
|
| 132 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 133 |
+
"Properties": {
|
| 134 |
+
"GroupId": {
|
| 135 |
+
"Ref": "EcsSecurityGroup"
|
| 136 |
+
},
|
| 137 |
+
"IpProtocol": "tcp",
|
| 138 |
+
"FromPort": "22",
|
| 139 |
+
"ToPort": "22",
|
| 140 |
+
"CidrIp": "192.168.1.0/0"
|
| 141 |
+
}
|
| 142 |
+
},
|
| 143 |
+
"EcsSecurityGroupALBports": {
|
| 144 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 145 |
+
"Properties": {
|
| 146 |
+
"GroupId": {
|
| 147 |
+
"Ref": "EcsSecurityGroup"
|
| 148 |
+
},
|
| 149 |
+
"IpProtocol": "tcp",
|
| 150 |
+
"FromPort": "31000",
|
| 151 |
+
"ToPort": "61000",
|
| 152 |
+
"SourceSecurityGroupId": {
|
| 153 |
+
"Ref": "EcsSecurityGroup"
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
},
|
| 157 |
+
"LogsKmsKey": {
|
| 158 |
+
"Type": "AWS::KMS::Key",
|
| 159 |
+
"Properties": {
|
| 160 |
+
"Description": "ECS Logs Encryption Key",
|
| 161 |
+
"EnableKeyRotation": true
|
| 162 |
+
}
|
| 163 |
+
},
|
| 164 |
+
"CloudwatchLogsGroup": {
|
| 165 |
+
"Type": "AWS::Logs::LogGroup",
|
| 166 |
+
"Properties": {
|
| 167 |
+
"LogGroupName": {
|
| 168 |
+
"Fn::Join": [
|
| 169 |
+
"-",
|
| 170 |
+
[
|
| 171 |
+
"ECSLogGroup",
|
| 172 |
+
{
|
| 173 |
+
"Ref": "AWS::StackName"
|
| 174 |
+
}
|
| 175 |
+
]
|
| 176 |
+
]
|
| 177 |
+
},
|
| 178 |
+
"RetentionInDays": 14,
|
| 179 |
+
"KmsKeyId": {
|
| 180 |
+
"Ref": "LogsKmsKey"
|
| 181 |
+
}
|
| 182 |
+
}
|
| 183 |
+
},
|
| 184 |
+
"TaskDefinition": {
|
| 185 |
+
"Type": "AWS::ECS::TaskDefinition",
|
| 186 |
+
"Properties": {
|
| 187 |
+
"Family": {
|
| 188 |
+
"Fn::Join": [
|
| 189 |
+
"",
|
| 190 |
+
[
|
| 191 |
+
{
|
| 192 |
+
"Ref": "AWS::StackName"
|
| 193 |
+
},
|
| 194 |
+
"-ecs-demo-app"
|
| 195 |
+
]
|
| 196 |
+
]
|
| 197 |
+
},
|
| 198 |
+
"ContainerDefinitions": [
|
| 199 |
+
{
|
| 200 |
+
"Name": "simple-app",
|
| 201 |
+
"Cpu": "10",
|
| 202 |
+
"Essential": "true",
|
| 203 |
+
"Image": "httpd:2.4",
|
| 204 |
+
"Memory": "300",
|
| 205 |
+
"LogConfiguration": {
|
| 206 |
+
"LogDriver": "awslogs",
|
| 207 |
+
"Options": {
|
| 208 |
+
"awslogs-group": {
|
| 209 |
+
"Ref": "CloudwatchLogsGroup"
|
| 210 |
+
},
|
| 211 |
+
"awslogs-region": {
|
| 212 |
+
"Ref": "AWS::Region"
|
| 213 |
+
},
|
| 214 |
+
"awslogs-stream-prefix": "ecs-demo-app"
|
| 215 |
+
}
|
| 216 |
+
},
|
| 217 |
+
"MountPoints": [
|
| 218 |
+
{
|
| 219 |
+
"ContainerPath": "/usr/local/apache2/htdocs",
|
| 220 |
+
"SourceVolume": "my-vol"
|
| 221 |
+
}
|
| 222 |
+
],
|
| 223 |
+
"PortMappings": [
|
| 224 |
+
{
|
| 225 |
+
"ContainerPort": 80
|
| 226 |
+
}
|
| 227 |
+
]
|
| 228 |
+
},
|
| 229 |
+
{
|
| 230 |
+
"Name": "busybox",
|
| 231 |
+
"Cpu": 10,
|
| 232 |
+
"Command": [
|
| 233 |
+
"/bin/sh -c \"while true; do echo '<html> <head> <title>Amazon ECS Sample App</title> <style>body {margin-top: 40px; background-color: #333;} </style> </head><body> <div style=color:white;text-align:center> <h1>Amazon ECS Sample App</h1> <h2>Congratulations!</h2> <p>Your application is now running on a container in Amazon ECS.</p>' > top; /bin/date > date ; echo '</div></body></html>' > bottom; cat top date bottom > /usr/local/apache2/htdocs/index.html ; sleep 1; done\""
|
| 234 |
+
],
|
| 235 |
+
"EntryPoint": [
|
| 236 |
+
"sh",
|
| 237 |
+
"-c"
|
| 238 |
+
],
|
| 239 |
+
"Essential": false,
|
| 240 |
+
"Image": "busybox",
|
| 241 |
+
"Memory": 200,
|
| 242 |
+
"LogConfiguration": {
|
| 243 |
+
"LogDriver": "awslogs",
|
| 244 |
+
"Options": {
|
| 245 |
+
"awslogs-group": {
|
| 246 |
+
"Ref": "CloudwatchLogsGroup"
|
| 247 |
+
},
|
| 248 |
+
"awslogs-region": {
|
| 249 |
+
"Ref": "AWS::Region"
|
| 250 |
+
},
|
| 251 |
+
"awslogs-stream-prefix": "ecs-demo-app"
|
| 252 |
+
}
|
| 253 |
+
},
|
| 254 |
+
"VolumesFrom": [
|
| 255 |
+
{
|
| 256 |
+
"SourceContainer": "simple-app"
|
| 257 |
+
}
|
| 258 |
+
]
|
| 259 |
+
}
|
| 260 |
+
],
|
| 261 |
+
"Volumes": [
|
| 262 |
+
{
|
| 263 |
+
"Name": "my-vol"
|
| 264 |
+
}
|
| 265 |
+
]
|
| 266 |
+
}
|
| 267 |
+
},
|
| 268 |
+
"ECSALB": {
|
| 269 |
+
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
|
| 270 |
+
"Properties": {
|
| 271 |
+
"Name": "ECSALB",
|
| 272 |
+
"Scheme": "internet-facing",
|
| 273 |
+
"LoadBalancerAttributes": [
|
| 274 |
+
{
|
| 275 |
+
"Key": "idle_timeout.timeout_seconds",
|
| 276 |
+
"Value": "30"
|
| 277 |
+
}
|
| 278 |
+
],
|
| 279 |
+
"Subnets": {
|
| 280 |
+
"Ref": "SubnetId"
|
| 281 |
+
},
|
| 282 |
+
"SecurityGroups": [
|
| 283 |
+
{
|
| 284 |
+
"Ref": "EcsSecurityGroup"
|
| 285 |
+
}
|
| 286 |
+
]
|
| 287 |
+
}
|
| 288 |
+
},
|
| 289 |
+
"ALBListener": {
|
| 290 |
+
"Type": "AWS::ElasticLoadBalancingV2::Listener",
|
| 291 |
+
"DependsOn": "ECSServiceRole",
|
| 292 |
+
"Properties": {
|
| 293 |
+
"DefaultActions": [
|
| 294 |
+
{
|
| 295 |
+
"Type": "forward",
|
| 296 |
+
"TargetGroupArn": {
|
| 297 |
+
"Ref": "ECSTG"
|
| 298 |
+
}
|
| 299 |
+
}
|
| 300 |
+
],
|
| 301 |
+
"LoadBalancerArn": {
|
| 302 |
+
"Ref": "ECSALB"
|
| 303 |
+
},
|
| 304 |
+
"Port": "80",
|
| 305 |
+
"Protocol": "HTTP"
|
| 306 |
+
}
|
| 307 |
+
},
|
| 308 |
+
"ECSALBListenerRule": {
|
| 309 |
+
"Type": "AWS::ElasticLoadBalancingV2::ListenerRule",
|
| 310 |
+
"DependsOn": "ALBListener",
|
| 311 |
+
"Properties": {
|
| 312 |
+
"Actions": [
|
| 313 |
+
{
|
| 314 |
+
"Type": "forward",
|
| 315 |
+
"TargetGroupArn": {
|
| 316 |
+
"Ref": "ECSTG"
|
| 317 |
+
}
|
| 318 |
+
}
|
| 319 |
+
],
|
| 320 |
+
"Conditions": [
|
| 321 |
+
{
|
| 322 |
+
"Field": "path-pattern",
|
| 323 |
+
"Values": [
|
| 324 |
+
"/"
|
| 325 |
+
]
|
| 326 |
+
}
|
| 327 |
+
],
|
| 328 |
+
"ListenerArn": {
|
| 329 |
+
"Ref": "ALBListener"
|
| 330 |
+
},
|
| 331 |
+
"Priority": 1
|
| 332 |
+
}
|
| 333 |
+
},
|
| 334 |
+
"ECSTG": {
|
| 335 |
+
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
|
| 336 |
+
"DependsOn": "ECSALB",
|
| 337 |
+
"Properties": {
|
| 338 |
+
"HealthCheckIntervalSeconds": 10,
|
| 339 |
+
"HealthCheckPath": "/",
|
| 340 |
+
"HealthCheckProtocol": "HTTP",
|
| 341 |
+
"HealthCheckTimeoutSeconds": 5,
|
| 342 |
+
"HealthyThresholdCount": 2,
|
| 343 |
+
"Name": "ECSTG",
|
| 344 |
+
"Port": 80,
|
| 345 |
+
"Protocol": "HTTP",
|
| 346 |
+
"UnhealthyThresholdCount": 2,
|
| 347 |
+
"VpcId": {
|
| 348 |
+
"Ref": "VpcId"
|
| 349 |
+
}
|
| 350 |
+
}
|
| 351 |
+
},
|
| 352 |
+
"ECSAutoScalingGroup": {
|
| 353 |
+
"CreationPolicy": {
|
| 354 |
+
"ResourceSignal": {
|
| 355 |
+
"Timeout": "PT15M"
|
| 356 |
+
}
|
| 357 |
+
},
|
| 358 |
+
"UpdatePolicy": {
|
| 359 |
+
"AutoScalingReplacingUpdate": {
|
| 360 |
+
"WillReplace": true
|
| 361 |
+
}
|
| 362 |
+
},
|
| 363 |
+
"Type": "AWS::AutoScaling::AutoScalingGroup",
|
| 364 |
+
"Properties": {
|
| 365 |
+
"VPCZoneIdentifier": {
|
| 366 |
+
"Ref": "SubnetId"
|
| 367 |
+
},
|
| 368 |
+
"LaunchConfigurationName": {
|
| 369 |
+
"Ref": "ContainerInstances"
|
| 370 |
+
},
|
| 371 |
+
"MinSize": "1",
|
| 372 |
+
"MaxSize": {
|
| 373 |
+
"Ref": "MaxSize"
|
| 374 |
+
},
|
| 375 |
+
"DesiredCapacity": {
|
| 376 |
+
"Ref": "DesiredCapacity"
|
| 377 |
+
}
|
| 378 |
+
}
|
| 379 |
+
},
|
| 380 |
+
"ContainerInstances": {
|
| 381 |
+
"Type": "AWS::AutoScaling::LaunchConfiguration",
|
| 382 |
+
"Properties": {
|
| 383 |
+
"ImageId": {
|
| 384 |
+
"Ref": "LatestAmiId"
|
| 385 |
+
},
|
| 386 |
+
"SecurityGroups": [
|
| 387 |
+
{
|
| 388 |
+
"Ref": "EcsSecurityGroup"
|
| 389 |
+
}
|
| 390 |
+
],
|
| 391 |
+
"InstanceType": {
|
| 392 |
+
"Ref": "InstanceType"
|
| 393 |
+
},
|
| 394 |
+
"IamInstanceProfile": {
|
| 395 |
+
"Ref": "EC2InstanceProfile"
|
| 396 |
+
},
|
| 397 |
+
"KeyName": {
|
| 398 |
+
"Ref": "KeyName"
|
| 399 |
+
},
|
| 400 |
+
"UserData": {
|
| 401 |
+
"Fn::Base64": {
|
| 402 |
+
"Fn::Sub": "#!/bin/bash -xe\necho ECS_CLUSTER=${ECSCluster} >> /etc/ecs/ecs.config\nyum install -y aws-cfn-bootstrap\n/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} \\\n --resource ECSAutoScalingGroup \\\n --region ${AWS::Region}\n"
|
| 403 |
+
}
|
| 404 |
+
}
|
| 405 |
+
}
|
| 406 |
+
},
|
| 407 |
+
"Service": {
|
| 408 |
+
"Type": "AWS::ECS::Service",
|
| 409 |
+
"DependsOn": "ALBListener",
|
| 410 |
+
"Properties": {
|
| 411 |
+
"Cluster": {
|
| 412 |
+
"Ref": "ECSCluster"
|
| 413 |
+
},
|
| 414 |
+
"DesiredCount": "1",
|
| 415 |
+
"LoadBalancers": [
|
| 416 |
+
{
|
| 417 |
+
"ContainerName": "simple-app",
|
| 418 |
+
"ContainerPort": "80",
|
| 419 |
+
"TargetGroupArn": {
|
| 420 |
+
"Ref": "ECSTG"
|
| 421 |
+
}
|
| 422 |
+
}
|
| 423 |
+
],
|
| 424 |
+
"Role": {
|
| 425 |
+
"Ref": "ECSServiceRole"
|
| 426 |
+
},
|
| 427 |
+
"TaskDefinition": {
|
| 428 |
+
"Ref": "TaskDefinition"
|
| 429 |
+
}
|
| 430 |
+
}
|
| 431 |
+
},
|
| 432 |
+
"ECSScheduledTask": {
|
| 433 |
+
"Type": "AWS::Events::Rule",
|
| 434 |
+
"DependsOn": "ECSEventRole",
|
| 435 |
+
"Properties": {
|
| 436 |
+
"Description": "Creating a Schedule with CloudFormation as an example",
|
| 437 |
+
"ScheduleExpression": {
|
| 438 |
+
"Fn::If": [
|
| 439 |
+
"CronRate",
|
| 440 |
+
{
|
| 441 |
+
"Ref": "CronSchedule"
|
| 442 |
+
},
|
| 443 |
+
{
|
| 444 |
+
"Ref": "RateSchedule"
|
| 445 |
+
}
|
| 446 |
+
]
|
| 447 |
+
},
|
| 448 |
+
"State": "ENABLED",
|
| 449 |
+
"Targets": [
|
| 450 |
+
{
|
| 451 |
+
"Arn": {
|
| 452 |
+
"Fn::GetAtt": [
|
| 453 |
+
"ECSCluster",
|
| 454 |
+
"Arn"
|
| 455 |
+
]
|
| 456 |
+
},
|
| 457 |
+
"Id": "Target1",
|
| 458 |
+
"RoleArn": {
|
| 459 |
+
"Fn::GetAtt": [
|
| 460 |
+
"ECSEventRole",
|
| 461 |
+
"Arn"
|
| 462 |
+
]
|
| 463 |
+
},
|
| 464 |
+
"EcsParameters": {
|
| 465 |
+
"TaskCount": {
|
| 466 |
+
"Ref": "SchedulerTasksCount"
|
| 467 |
+
},
|
| 468 |
+
"TaskDefinitionArn": {
|
| 469 |
+
"Ref": "TaskDefinition"
|
| 470 |
+
}
|
| 471 |
+
}
|
| 472 |
+
}
|
| 473 |
+
]
|
| 474 |
+
}
|
| 475 |
+
},
|
| 476 |
+
"ECSEventRole": {
|
| 477 |
+
"Type": "AWS::IAM::Role",
|
| 478 |
+
"Properties": {
|
| 479 |
+
"AssumeRolePolicyDocument": {
|
| 480 |
+
"Statement": [
|
| 481 |
+
{
|
| 482 |
+
"Effect": "Allow",
|
| 483 |
+
"Principal": {
|
| 484 |
+
"Service": [
|
| 485 |
+
"events.amazonaws.com"
|
| 486 |
+
]
|
| 487 |
+
},
|
| 488 |
+
"Action": [
|
| 489 |
+
"sts:AssumeRole"
|
| 490 |
+
]
|
| 491 |
+
}
|
| 492 |
+
]
|
| 493 |
+
},
|
| 494 |
+
"Path": "/",
|
| 495 |
+
"Policies": [
|
| 496 |
+
{
|
| 497 |
+
"PolicyName": "ecs-service",
|
| 498 |
+
"PolicyDocument": {
|
| 499 |
+
"Statement": [
|
| 500 |
+
{
|
| 501 |
+
"Effect": "Allow",
|
| 502 |
+
"Action": [
|
| 503 |
+
"ecs:RunTask"
|
| 504 |
+
],
|
| 505 |
+
"Resource": "*"
|
| 506 |
+
}
|
| 507 |
+
]
|
| 508 |
+
}
|
| 509 |
+
}
|
| 510 |
+
]
|
| 511 |
+
}
|
| 512 |
+
},
|
| 513 |
+
"ECSServiceRole": {
|
| 514 |
+
"Type": "AWS::IAM::Role",
|
| 515 |
+
"Properties": {
|
| 516 |
+
"AssumeRolePolicyDocument": {
|
| 517 |
+
"Statement": [
|
| 518 |
+
{
|
| 519 |
+
"Effect": "Allow",
|
| 520 |
+
"Principal": {
|
| 521 |
+
"Service": [
|
| 522 |
+
"ecs.amazonaws.com"
|
| 523 |
+
]
|
| 524 |
+
},
|
| 525 |
+
"Action": [
|
| 526 |
+
"sts:AssumeRole"
|
| 527 |
+
]
|
| 528 |
+
}
|
| 529 |
+
]
|
| 530 |
+
},
|
| 531 |
+
"Path": "/",
|
| 532 |
+
"Policies": [
|
| 533 |
+
{
|
| 534 |
+
"PolicyName": "ecs-service",
|
| 535 |
+
"PolicyDocument": {
|
| 536 |
+
"Statement": [
|
| 537 |
+
{
|
| 538 |
+
"Effect": "Allow",
|
| 539 |
+
"Action": [
|
| 540 |
+
"elasticloadbalancing:DeregisterInstancesFromLoadBalancer",
|
| 541 |
+
"elasticloadbalancing:DeregisterTargets",
|
| 542 |
+
"elasticloadbalancing:Describe*",
|
| 543 |
+
"elasticloadbalancing:RegisterInstancesWithLoadBalancer",
|
| 544 |
+
"elasticloadbalancing:RegisterTargets",
|
| 545 |
+
"ec2:Describe*",
|
| 546 |
+
"ec2:AuthorizeSecurityGroupIngress"
|
| 547 |
+
],
|
| 548 |
+
"Resource": "*"
|
| 549 |
+
}
|
| 550 |
+
]
|
| 551 |
+
}
|
| 552 |
+
}
|
| 553 |
+
]
|
| 554 |
+
}
|
| 555 |
+
},
|
| 556 |
+
"ServiceScalingTarget": {
|
| 557 |
+
"Type": "AWS::ApplicationAutoScaling::ScalableTarget",
|
| 558 |
+
"DependsOn": "Service",
|
| 559 |
+
"Properties": {
|
| 560 |
+
"MaxCapacity": 2,
|
| 561 |
+
"MinCapacity": 1,
|
| 562 |
+
"ResourceId": {
|
| 563 |
+
"Fn::Join": [
|
| 564 |
+
"",
|
| 565 |
+
[
|
| 566 |
+
"service/",
|
| 567 |
+
{
|
| 568 |
+
"Ref": "ECSCluster"
|
| 569 |
+
},
|
| 570 |
+
"/",
|
| 571 |
+
{
|
| 572 |
+
"Fn::GetAtt": [
|
| 573 |
+
"Service",
|
| 574 |
+
"Name"
|
| 575 |
+
]
|
| 576 |
+
}
|
| 577 |
+
]
|
| 578 |
+
]
|
| 579 |
+
},
|
| 580 |
+
"RoleARN": {
|
| 581 |
+
"Fn::GetAtt": [
|
| 582 |
+
"AutoscalingRole",
|
| 583 |
+
"Arn"
|
| 584 |
+
]
|
| 585 |
+
},
|
| 586 |
+
"ScalableDimension": "ecs:service:DesiredCount",
|
| 587 |
+
"ServiceNamespace": "ecs"
|
| 588 |
+
}
|
| 589 |
+
},
|
| 590 |
+
"ServiceScalingPolicy": {
|
| 591 |
+
"Type": "AWS::ApplicationAutoScaling::ScalingPolicy",
|
| 592 |
+
"Properties": {
|
| 593 |
+
"PolicyName": "AStepPolicy",
|
| 594 |
+
"PolicyType": "StepScaling",
|
| 595 |
+
"ScalingTargetId": {
|
| 596 |
+
"Ref": "ServiceScalingTarget"
|
| 597 |
+
},
|
| 598 |
+
"StepScalingPolicyConfiguration": {
|
| 599 |
+
"AdjustmentType": "PercentChangeInCapacity",
|
| 600 |
+
"Cooldown": 60,
|
| 601 |
+
"MetricAggregationType": "Average",
|
| 602 |
+
"StepAdjustments": [
|
| 603 |
+
{
|
| 604 |
+
"MetricIntervalLowerBound": 0,
|
| 605 |
+
"ScalingAdjustment": 200
|
| 606 |
+
}
|
| 607 |
+
]
|
| 608 |
+
}
|
| 609 |
+
}
|
| 610 |
+
},
|
| 611 |
+
"ALB500sAlarmScaleUp": {
|
| 612 |
+
"Type": "AWS::CloudWatch::Alarm",
|
| 613 |
+
"Properties": {
|
| 614 |
+
"EvaluationPeriods": "1",
|
| 615 |
+
"Statistic": "Average",
|
| 616 |
+
"Threshold": "10",
|
| 617 |
+
"AlarmDescription": "Alarm if our ALB generates too many HTTP 500s.",
|
| 618 |
+
"Period": "60",
|
| 619 |
+
"AlarmActions": [
|
| 620 |
+
{
|
| 621 |
+
"Ref": "ServiceScalingPolicy"
|
| 622 |
+
}
|
| 623 |
+
],
|
| 624 |
+
"Namespace": "AWS/ApplicationELB",
|
| 625 |
+
"Dimensions": [
|
| 626 |
+
{
|
| 627 |
+
"Name": "ECSService",
|
| 628 |
+
"Value": {
|
| 629 |
+
"Ref": "Service"
|
| 630 |
+
}
|
| 631 |
+
}
|
| 632 |
+
],
|
| 633 |
+
"ComparisonOperator": "GreaterThanThreshold",
|
| 634 |
+
"MetricName": "HTTPCode_ELB_5XX_Count"
|
| 635 |
+
}
|
| 636 |
+
},
|
| 637 |
+
"EC2Role": {
|
| 638 |
+
"Type": "AWS::IAM::Role",
|
| 639 |
+
"Properties": {
|
| 640 |
+
"AssumeRolePolicyDocument": {
|
| 641 |
+
"Statement": [
|
| 642 |
+
{
|
| 643 |
+
"Effect": "Allow",
|
| 644 |
+
"Principal": {
|
| 645 |
+
"Service": [
|
| 646 |
+
"ec2.amazonaws.com"
|
| 647 |
+
]
|
| 648 |
+
},
|
| 649 |
+
"Action": [
|
| 650 |
+
"sts:AssumeRole"
|
| 651 |
+
]
|
| 652 |
+
}
|
| 653 |
+
]
|
| 654 |
+
},
|
| 655 |
+
"Path": "/",
|
| 656 |
+
"Policies": [
|
| 657 |
+
{
|
| 658 |
+
"PolicyName": "ecs-service",
|
| 659 |
+
"PolicyDocument": {
|
| 660 |
+
"Statement": [
|
| 661 |
+
{
|
| 662 |
+
"Effect": "Allow",
|
| 663 |
+
"Action": [
|
| 664 |
+
"ecs:CreateCluster",
|
| 665 |
+
"ecs:DeregisterContainerInstance",
|
| 666 |
+
"ecs:DiscoverPollEndpoint",
|
| 667 |
+
"ecs:Poll",
|
| 668 |
+
"ecs:RegisterContainerInstance",
|
| 669 |
+
"ecs:StartTelemetrySession",
|
| 670 |
+
"ecs:Submit*",
|
| 671 |
+
"logs:CreateLogStream",
|
| 672 |
+
"logs:PutLogEvents"
|
| 673 |
+
],
|
| 674 |
+
"Resource": "*"
|
| 675 |
+
}
|
| 676 |
+
]
|
| 677 |
+
}
|
| 678 |
+
}
|
| 679 |
+
]
|
| 680 |
+
}
|
| 681 |
+
},
|
| 682 |
+
"AutoscalingRole": {
|
| 683 |
+
"Type": "AWS::IAM::Role",
|
| 684 |
+
"Properties": {
|
| 685 |
+
"AssumeRolePolicyDocument": {
|
| 686 |
+
"Statement": [
|
| 687 |
+
{
|
| 688 |
+
"Effect": "Allow",
|
| 689 |
+
"Principal": {
|
| 690 |
+
"Service": [
|
| 691 |
+
"application-autoscaling.amazonaws.com"
|
| 692 |
+
]
|
| 693 |
+
},
|
| 694 |
+
"Action": [
|
| 695 |
+
"sts:AssumeRole"
|
| 696 |
+
]
|
| 697 |
+
}
|
| 698 |
+
]
|
| 699 |
+
},
|
| 700 |
+
"Path": "/",
|
| 701 |
+
"Policies": [
|
| 702 |
+
{
|
| 703 |
+
"PolicyName": "service-autoscaling",
|
| 704 |
+
"PolicyDocument": {
|
| 705 |
+
"Statement": [
|
| 706 |
+
{
|
| 707 |
+
"Effect": "Allow",
|
| 708 |
+
"Action": [
|
| 709 |
+
"application-autoscaling:*",
|
| 710 |
+
"cloudwatch:DescribeAlarms",
|
| 711 |
+
"cloudwatch:PutMetricAlarm",
|
| 712 |
+
"ecs:DescribeServices",
|
| 713 |
+
"ecs:UpdateService"
|
| 714 |
+
],
|
| 715 |
+
"Resource": "*"
|
| 716 |
+
}
|
| 717 |
+
]
|
| 718 |
+
}
|
| 719 |
+
}
|
| 720 |
+
]
|
| 721 |
+
}
|
| 722 |
+
},
|
| 723 |
+
"EC2InstanceProfile": {
|
| 724 |
+
"Type": "AWS::IAM::InstanceProfile",
|
| 725 |
+
"Properties": {
|
| 726 |
+
"Path": "/",
|
| 727 |
+
"Roles": [
|
| 728 |
+
{
|
| 729 |
+
"Ref": "EC2Role"
|
| 730 |
+
}
|
| 731 |
+
]
|
| 732 |
+
}
|
| 733 |
+
}
|
| 734 |
+
},
|
| 735 |
+
"Outputs": {
|
| 736 |
+
"EcsService": {
|
| 737 |
+
"Value": {
|
| 738 |
+
"Ref": "Service"
|
| 739 |
+
}
|
| 740 |
+
},
|
| 741 |
+
"EcsCluster": {
|
| 742 |
+
"Value": {
|
| 743 |
+
"Ref": "ECSCluster"
|
| 744 |
+
}
|
| 745 |
+
},
|
| 746 |
+
"EcsTaskDef": {
|
| 747 |
+
"Value": {
|
| 748 |
+
"Ref": "TaskDefinition"
|
| 749 |
+
}
|
| 750 |
+
},
|
| 751 |
+
"ECSALB": {
|
| 752 |
+
"Description": "Your ALB DNS URL",
|
| 753 |
+
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Amazon ECS Time and Event-Based Task Scheduling with CloudFormation. This will let you run tasks on a regular, scheduled basis and in response to CloudWatch Events. It easier to launch and stop container services that you need to run only at certain times. For example a backup/cleanup task.
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
KeyName:
|
| 7 |
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the ECS instances.
|
| 8 |
+
Type: AWS::EC2::KeyPair::KeyName
|
| 9 |
+
|
| 10 |
+
VpcId:
|
| 11 |
+
Description: Select a VPC that allows instances to access the Internet.
|
| 12 |
+
Type: AWS::EC2::VPC::Id
|
| 13 |
+
|
| 14 |
+
SubnetId:
|
| 15 |
+
Description: Select at two subnets in your selected VPC.
|
| 16 |
+
Type: List<AWS::EC2::Subnet::Id>
|
| 17 |
+
|
| 18 |
+
DesiredCapacity:
|
| 19 |
+
Description: Number of instances to launch in your ECS cluster.
|
| 20 |
+
Type: Number
|
| 21 |
+
Default: 1
|
| 22 |
+
|
| 23 |
+
MaxSize:
|
| 24 |
+
Description: Maximum number of instances that can be launched in your ECS cluster.
|
| 25 |
+
Type: Number
|
| 26 |
+
Default: 1
|
| 27 |
+
|
| 28 |
+
SchedulerTasksCount:
|
| 29 |
+
Description: Maximum number of Tasks that you want to the Scheduler to run
|
| 30 |
+
Type: Number
|
| 31 |
+
Default: 1
|
| 32 |
+
|
| 33 |
+
CronOrRate:
|
| 34 |
+
Description: Choose to use a cron expression or a rate expression you want to use.
|
| 35 |
+
Type: String
|
| 36 |
+
AllowedValues:
|
| 37 |
+
- cron
|
| 38 |
+
- rate
|
| 39 |
+
Default: cron
|
| 40 |
+
|
| 41 |
+
CronSchedule:
|
| 42 |
+
Description: This defines the Schedule at which to run the. Cron Expressions - http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html#CronExpressions
|
| 43 |
+
Type: String
|
| 44 |
+
Default: cron(00 11 ? * * *)
|
| 45 |
+
|
| 46 |
+
RateSchedule:
|
| 47 |
+
Description: This defines the Schedule at which to run the. Rate Expressions - http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html#RateExpressions
|
| 48 |
+
Type: String
|
| 49 |
+
Default: rate(1 day)
|
| 50 |
+
|
| 51 |
+
InstanceType:
|
| 52 |
+
Description: EC2 instance type
|
| 53 |
+
Type: String
|
| 54 |
+
AllowedValues:
|
| 55 |
+
- t2.micro
|
| 56 |
+
- t2.small
|
| 57 |
+
- t2.medium
|
| 58 |
+
- t2.large
|
| 59 |
+
- m3.medium
|
| 60 |
+
- m3.large
|
| 61 |
+
- m3.xlarge
|
| 62 |
+
- m3.2xlarge
|
| 63 |
+
- m4.large
|
| 64 |
+
- m4.xlarge
|
| 65 |
+
- m4.2xlarge
|
| 66 |
+
- m4.4xlarge
|
| 67 |
+
- m4.10xlarge
|
| 68 |
+
- c4.large
|
| 69 |
+
- c4.xlarge
|
| 70 |
+
- c4.2xlarge
|
| 71 |
+
- c4.4xlarge
|
| 72 |
+
- c4.8xlarge
|
| 73 |
+
- c3.large
|
| 74 |
+
- c3.xlarge
|
| 75 |
+
- c3.2xlarge
|
| 76 |
+
- c3.4xlarge
|
| 77 |
+
- c3.8xlarge
|
| 78 |
+
- r3.large
|
| 79 |
+
- r3.xlarge
|
| 80 |
+
- r3.2xlarge
|
| 81 |
+
- r3.4xlarge
|
| 82 |
+
- r3.8xlarge
|
| 83 |
+
- i2.xlarge
|
| 84 |
+
- i2.2xlarge
|
| 85 |
+
- i2.4xlarge
|
| 86 |
+
- i2.8xlarge
|
| 87 |
+
Default: t2.micro
|
| 88 |
+
ConstraintDescription: Please choose a valid instance type.
|
| 89 |
+
|
| 90 |
+
LatestAmiId:
|
| 91 |
+
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
|
| 92 |
+
Default: /aws/service/ecs/optimized-ami/amazon-linux-2023/recommended/image_id
|
| 93 |
+
|
| 94 |
+
Conditions:
|
| 95 |
+
CronRate: !Equals
|
| 96 |
+
- !Ref CronOrRate
|
| 97 |
+
- cron
|
| 98 |
+
|
| 99 |
+
Resources:
|
| 100 |
+
ECSCluster:
|
| 101 |
+
Type: AWS::ECS::Cluster
|
| 102 |
+
|
| 103 |
+
EcsSecurityGroup:
|
| 104 |
+
Type: AWS::EC2::SecurityGroup
|
| 105 |
+
Properties:
|
| 106 |
+
GroupDescription: ECS Security Group
|
| 107 |
+
VpcId: !Ref VpcId
|
| 108 |
+
|
| 109 |
+
EcsSecurityGroupHTTPinbound:
|
| 110 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 111 |
+
Properties:
|
| 112 |
+
GroupId: !Ref EcsSecurityGroup
|
| 113 |
+
IpProtocol: tcp
|
| 114 |
+
FromPort: "80"
|
| 115 |
+
ToPort: "80"
|
| 116 |
+
CidrIp: 0.0.0.0/0
|
| 117 |
+
|
| 118 |
+
EcsSecurityGroupSSHinbound:
|
| 119 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 120 |
+
Properties:
|
| 121 |
+
GroupId: !Ref EcsSecurityGroup
|
| 122 |
+
IpProtocol: tcp
|
| 123 |
+
FromPort: "22"
|
| 124 |
+
ToPort: "22"
|
| 125 |
+
CidrIp: 192.168.1.0/0
|
| 126 |
+
|
| 127 |
+
EcsSecurityGroupALBports:
|
| 128 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 129 |
+
Properties:
|
| 130 |
+
GroupId: !Ref EcsSecurityGroup
|
| 131 |
+
IpProtocol: tcp
|
| 132 |
+
FromPort: "31000"
|
| 133 |
+
ToPort: "61000"
|
| 134 |
+
SourceSecurityGroupId: !Ref EcsSecurityGroup
|
| 135 |
+
|
| 136 |
+
# Create a KMS key to encrypt logs
|
| 137 |
+
LogsKmsKey:
|
| 138 |
+
Type: AWS::KMS::Key
|
| 139 |
+
Properties:
|
| 140 |
+
Description: "ECS Logs Encryption Key"
|
| 141 |
+
EnableKeyRotation: true
|
| 142 |
+
CloudwatchLogsGroup:
|
| 143 |
+
Type: AWS::Logs::LogGroup
|
| 144 |
+
Properties:
|
| 145 |
+
LogGroupName: !Join
|
| 146 |
+
- '-'
|
| 147 |
+
- - ECSLogGroup
|
| 148 |
+
- !Ref AWS::StackName
|
| 149 |
+
RetentionInDays: 14
|
| 150 |
+
KmsKeyId: !Ref LogsKmsKey
|
| 151 |
+
|
| 152 |
+
TaskDefinition:
|
| 153 |
+
Type: AWS::ECS::TaskDefinition
|
| 154 |
+
Properties:
|
| 155 |
+
Family: !Join
|
| 156 |
+
- ""
|
| 157 |
+
- - !Ref AWS::StackName
|
| 158 |
+
- -ecs-demo-app
|
| 159 |
+
ContainerDefinitions:
|
| 160 |
+
- Name: simple-app
|
| 161 |
+
Cpu: "10"
|
| 162 |
+
Essential: "true"
|
| 163 |
+
Image: httpd:2.4
|
| 164 |
+
Memory: "300"
|
| 165 |
+
LogConfiguration:
|
| 166 |
+
LogDriver: awslogs
|
| 167 |
+
Options:
|
| 168 |
+
awslogs-group: !Ref CloudwatchLogsGroup
|
| 169 |
+
awslogs-region: !Ref AWS::Region
|
| 170 |
+
awslogs-stream-prefix: ecs-demo-app
|
| 171 |
+
MountPoints:
|
| 172 |
+
- ContainerPath: /usr/local/apache2/htdocs
|
| 173 |
+
SourceVolume: my-vol
|
| 174 |
+
PortMappings:
|
| 175 |
+
- ContainerPort: 80
|
| 176 |
+
- Name: busybox
|
| 177 |
+
Cpu: 10
|
| 178 |
+
Command:
|
| 179 |
+
- '/bin/sh -c "while true; do echo ''<html> <head> <title>Amazon ECS Sample App</title> <style>body {margin-top: 40px; background-color: #333;} </style> </head><body> <div style=color:white;text-align:center> <h1>Amazon ECS Sample App</h1> <h2>Congratulations!</h2> <p>Your application is now running on a container in Amazon ECS.</p>'' > top; /bin/date > date ; echo ''</div></body></html>'' > bottom; cat top date bottom > /usr/local/apache2/htdocs/index.html ; sleep 1; done"'
|
| 180 |
+
EntryPoint:
|
| 181 |
+
- sh
|
| 182 |
+
- -c
|
| 183 |
+
Essential: false
|
| 184 |
+
Image: busybox
|
| 185 |
+
Memory: 200
|
| 186 |
+
LogConfiguration:
|
| 187 |
+
LogDriver: awslogs
|
| 188 |
+
Options:
|
| 189 |
+
awslogs-group: !Ref CloudwatchLogsGroup
|
| 190 |
+
awslogs-region: !Ref AWS::Region
|
| 191 |
+
awslogs-stream-prefix: ecs-demo-app
|
| 192 |
+
VolumesFrom:
|
| 193 |
+
- SourceContainer: simple-app
|
| 194 |
+
Volumes:
|
| 195 |
+
- Name: my-vol
|
| 196 |
+
|
| 197 |
+
ECSALB:
|
| 198 |
+
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
|
| 199 |
+
Properties:
|
| 200 |
+
Name: ECSALB
|
| 201 |
+
Scheme: internet-facing
|
| 202 |
+
LoadBalancerAttributes:
|
| 203 |
+
- Key: idle_timeout.timeout_seconds
|
| 204 |
+
Value: "30"
|
| 205 |
+
Subnets: !Ref SubnetId
|
| 206 |
+
SecurityGroups:
|
| 207 |
+
- !Ref EcsSecurityGroup
|
| 208 |
+
|
| 209 |
+
ALBListener:
|
| 210 |
+
Type: AWS::ElasticLoadBalancingV2::Listener
|
| 211 |
+
DependsOn: ECSServiceRole
|
| 212 |
+
Properties:
|
| 213 |
+
DefaultActions:
|
| 214 |
+
- Type: forward
|
| 215 |
+
TargetGroupArn: !Ref ECSTG
|
| 216 |
+
LoadBalancerArn: !Ref ECSALB
|
| 217 |
+
Port: "80"
|
| 218 |
+
Protocol: HTTP
|
| 219 |
+
|
| 220 |
+
ECSALBListenerRule:
|
| 221 |
+
Type: AWS::ElasticLoadBalancingV2::ListenerRule
|
| 222 |
+
DependsOn: ALBListener
|
| 223 |
+
Properties:
|
| 224 |
+
Actions:
|
| 225 |
+
- Type: forward
|
| 226 |
+
TargetGroupArn: !Ref ECSTG
|
| 227 |
+
Conditions:
|
| 228 |
+
- Field: path-pattern
|
| 229 |
+
Values:
|
| 230 |
+
- /
|
| 231 |
+
ListenerArn: !Ref ALBListener
|
| 232 |
+
Priority: 1
|
| 233 |
+
|
| 234 |
+
ECSTG:
|
| 235 |
+
Type: AWS::ElasticLoadBalancingV2::TargetGroup
|
| 236 |
+
DependsOn: ECSALB
|
| 237 |
+
Properties:
|
| 238 |
+
HealthCheckIntervalSeconds: 10
|
| 239 |
+
HealthCheckPath: /
|
| 240 |
+
HealthCheckProtocol: HTTP
|
| 241 |
+
HealthCheckTimeoutSeconds: 5
|
| 242 |
+
HealthyThresholdCount: 2
|
| 243 |
+
Name: ECSTG
|
| 244 |
+
Port: 80
|
| 245 |
+
Protocol: HTTP
|
| 246 |
+
UnhealthyThresholdCount: 2
|
| 247 |
+
VpcId: !Ref VpcId
|
| 248 |
+
|
| 249 |
+
ECSAutoScalingGroup:
|
| 250 |
+
CreationPolicy:
|
| 251 |
+
ResourceSignal:
|
| 252 |
+
Timeout: PT15M
|
| 253 |
+
UpdatePolicy:
|
| 254 |
+
AutoScalingReplacingUpdate:
|
| 255 |
+
WillReplace: true
|
| 256 |
+
Type: AWS::AutoScaling::AutoScalingGroup
|
| 257 |
+
Properties:
|
| 258 |
+
VPCZoneIdentifier: !Ref SubnetId
|
| 259 |
+
LaunchConfigurationName: !Ref ContainerInstances
|
| 260 |
+
MinSize: "1"
|
| 261 |
+
MaxSize: !Ref MaxSize
|
| 262 |
+
DesiredCapacity: !Ref DesiredCapacity
|
| 263 |
+
|
| 264 |
+
ContainerInstances:
|
| 265 |
+
Type: AWS::AutoScaling::LaunchConfiguration
|
| 266 |
+
Properties:
|
| 267 |
+
ImageId: !Ref LatestAmiId
|
| 268 |
+
SecurityGroups:
|
| 269 |
+
- !Ref EcsSecurityGroup
|
| 270 |
+
InstanceType: !Ref InstanceType
|
| 271 |
+
IamInstanceProfile: !Ref EC2InstanceProfile
|
| 272 |
+
KeyName: !Ref KeyName
|
| 273 |
+
UserData: !Base64
|
| 274 |
+
Fn::Sub: |
|
| 275 |
+
#!/bin/bash -xe
|
| 276 |
+
echo ECS_CLUSTER=${ECSCluster} >> /etc/ecs/ecs.config
|
| 277 |
+
yum install -y aws-cfn-bootstrap
|
| 278 |
+
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} \
|
| 279 |
+
--resource ECSAutoScalingGroup \
|
| 280 |
+
--region ${AWS::Region}
|
| 281 |
+
|
| 282 |
+
Service:
|
| 283 |
+
Type: AWS::ECS::Service
|
| 284 |
+
DependsOn: ALBListener
|
| 285 |
+
Properties:
|
| 286 |
+
Cluster: !Ref ECSCluster
|
| 287 |
+
DesiredCount: "1"
|
| 288 |
+
LoadBalancers:
|
| 289 |
+
- ContainerName: simple-app
|
| 290 |
+
ContainerPort: "80"
|
| 291 |
+
TargetGroupArn: !Ref ECSTG
|
| 292 |
+
Role: !Ref ECSServiceRole
|
| 293 |
+
TaskDefinition: !Ref TaskDefinition
|
| 294 |
+
|
| 295 |
+
ECSScheduledTask:
|
| 296 |
+
Type: AWS::Events::Rule
|
| 297 |
+
DependsOn: ECSEventRole
|
| 298 |
+
Properties:
|
| 299 |
+
Description: Creating a Schedule with CloudFormation as an example
|
| 300 |
+
ScheduleExpression: !If
|
| 301 |
+
- CronRate
|
| 302 |
+
- !Ref CronSchedule
|
| 303 |
+
- !Ref RateSchedule
|
| 304 |
+
State: ENABLED
|
| 305 |
+
Targets:
|
| 306 |
+
- Arn: !GetAtt ECSCluster.Arn
|
| 307 |
+
Id: Target1
|
| 308 |
+
RoleArn: !GetAtt ECSEventRole.Arn
|
| 309 |
+
EcsParameters:
|
| 310 |
+
TaskCount: !Ref SchedulerTasksCount
|
| 311 |
+
TaskDefinitionArn: !Ref TaskDefinition
|
| 312 |
+
|
| 313 |
+
ECSEventRole:
|
| 314 |
+
Type: AWS::IAM::Role
|
| 315 |
+
Properties:
|
| 316 |
+
AssumeRolePolicyDocument:
|
| 317 |
+
Statement:
|
| 318 |
+
- Effect: Allow
|
| 319 |
+
Principal:
|
| 320 |
+
Service:
|
| 321 |
+
- events.amazonaws.com
|
| 322 |
+
Action:
|
| 323 |
+
- sts:AssumeRole
|
| 324 |
+
Path: /
|
| 325 |
+
Policies:
|
| 326 |
+
- PolicyName: ecs-service
|
| 327 |
+
PolicyDocument:
|
| 328 |
+
Statement:
|
| 329 |
+
- Effect: Allow
|
| 330 |
+
Action:
|
| 331 |
+
- ecs:RunTask
|
| 332 |
+
Resource: '*'
|
| 333 |
+
|
| 334 |
+
ECSServiceRole:
|
| 335 |
+
Type: AWS::IAM::Role
|
| 336 |
+
Properties:
|
| 337 |
+
AssumeRolePolicyDocument:
|
| 338 |
+
Statement:
|
| 339 |
+
- Effect: Allow
|
| 340 |
+
Principal:
|
| 341 |
+
Service:
|
| 342 |
+
- ecs.amazonaws.com
|
| 343 |
+
Action:
|
| 344 |
+
- sts:AssumeRole
|
| 345 |
+
Path: /
|
| 346 |
+
Policies:
|
| 347 |
+
- PolicyName: ecs-service
|
| 348 |
+
PolicyDocument:
|
| 349 |
+
Statement:
|
| 350 |
+
- Effect: Allow
|
| 351 |
+
Action:
|
| 352 |
+
- elasticloadbalancing:DeregisterInstancesFromLoadBalancer
|
| 353 |
+
- elasticloadbalancing:DeregisterTargets
|
| 354 |
+
- elasticloadbalancing:Describe*
|
| 355 |
+
- elasticloadbalancing:RegisterInstancesWithLoadBalancer
|
| 356 |
+
- elasticloadbalancing:RegisterTargets
|
| 357 |
+
- ec2:Describe*
|
| 358 |
+
- ec2:AuthorizeSecurityGroupIngress
|
| 359 |
+
Resource: '*'
|
| 360 |
+
|
| 361 |
+
ServiceScalingTarget:
|
| 362 |
+
Type: AWS::ApplicationAutoScaling::ScalableTarget
|
| 363 |
+
DependsOn: Service
|
| 364 |
+
Properties:
|
| 365 |
+
MaxCapacity: 2
|
| 366 |
+
MinCapacity: 1
|
| 367 |
+
ResourceId: !Join
|
| 368 |
+
- ""
|
| 369 |
+
- - service/
|
| 370 |
+
- !Ref ECSCluster
|
| 371 |
+
- /
|
| 372 |
+
- !GetAtt Service.Name
|
| 373 |
+
RoleARN: !GetAtt AutoscalingRole.Arn
|
| 374 |
+
ScalableDimension: ecs:service:DesiredCount
|
| 375 |
+
ServiceNamespace: ecs
|
| 376 |
+
|
| 377 |
+
ServiceScalingPolicy:
|
| 378 |
+
Type: AWS::ApplicationAutoScaling::ScalingPolicy
|
| 379 |
+
Properties:
|
| 380 |
+
PolicyName: AStepPolicy
|
| 381 |
+
PolicyType: StepScaling
|
| 382 |
+
ScalingTargetId: !Ref ServiceScalingTarget
|
| 383 |
+
StepScalingPolicyConfiguration:
|
| 384 |
+
AdjustmentType: PercentChangeInCapacity
|
| 385 |
+
Cooldown: 60
|
| 386 |
+
MetricAggregationType: Average
|
| 387 |
+
StepAdjustments:
|
| 388 |
+
- MetricIntervalLowerBound: 0
|
| 389 |
+
ScalingAdjustment: 200
|
| 390 |
+
|
| 391 |
+
ALB500sAlarmScaleUp:
|
| 392 |
+
Type: AWS::CloudWatch::Alarm
|
| 393 |
+
Properties:
|
| 394 |
+
EvaluationPeriods: "1"
|
| 395 |
+
Statistic: Average
|
| 396 |
+
Threshold: "10"
|
| 397 |
+
AlarmDescription: Alarm if our ALB generates too many HTTP 500s.
|
| 398 |
+
Period: "60"
|
| 399 |
+
AlarmActions:
|
| 400 |
+
- !Ref ServiceScalingPolicy
|
| 401 |
+
Namespace: AWS/ApplicationELB
|
| 402 |
+
Dimensions:
|
| 403 |
+
- Name: ECSService
|
| 404 |
+
Value: !Ref Service
|
| 405 |
+
ComparisonOperator: GreaterThanThreshold
|
| 406 |
+
MetricName: HTTPCode_ELB_5XX_Count
|
| 407 |
+
|
| 408 |
+
EC2Role:
|
| 409 |
+
Type: AWS::IAM::Role
|
| 410 |
+
Properties:
|
| 411 |
+
AssumeRolePolicyDocument:
|
| 412 |
+
Statement:
|
| 413 |
+
- Effect: Allow
|
| 414 |
+
Principal:
|
| 415 |
+
Service:
|
| 416 |
+
- ec2.amazonaws.com
|
| 417 |
+
Action:
|
| 418 |
+
- sts:AssumeRole
|
| 419 |
+
Path: /
|
| 420 |
+
Policies:
|
| 421 |
+
- PolicyName: ecs-service
|
| 422 |
+
PolicyDocument:
|
| 423 |
+
Statement:
|
| 424 |
+
- Effect: Allow
|
| 425 |
+
Action:
|
| 426 |
+
- ecs:CreateCluster
|
| 427 |
+
- ecs:DeregisterContainerInstance
|
| 428 |
+
- ecs:DiscoverPollEndpoint
|
| 429 |
+
- ecs:Poll
|
| 430 |
+
- ecs:RegisterContainerInstance
|
| 431 |
+
- ecs:StartTelemetrySession
|
| 432 |
+
- ecs:Submit*
|
| 433 |
+
- logs:CreateLogStream
|
| 434 |
+
- logs:PutLogEvents
|
| 435 |
+
Resource: '*'
|
| 436 |
+
|
| 437 |
+
AutoscalingRole:
|
| 438 |
+
Type: AWS::IAM::Role
|
| 439 |
+
Properties:
|
| 440 |
+
AssumeRolePolicyDocument:
|
| 441 |
+
Statement:
|
| 442 |
+
- Effect: Allow
|
| 443 |
+
Principal:
|
| 444 |
+
Service:
|
| 445 |
+
- application-autoscaling.amazonaws.com
|
| 446 |
+
Action:
|
| 447 |
+
- sts:AssumeRole
|
| 448 |
+
Path: /
|
| 449 |
+
Policies:
|
| 450 |
+
- PolicyName: service-autoscaling
|
| 451 |
+
PolicyDocument:
|
| 452 |
+
Statement:
|
| 453 |
+
- Effect: Allow
|
| 454 |
+
Action:
|
| 455 |
+
- application-autoscaling:*
|
| 456 |
+
- cloudwatch:DescribeAlarms
|
| 457 |
+
- cloudwatch:PutMetricAlarm
|
| 458 |
+
- ecs:DescribeServices
|
| 459 |
+
- ecs:UpdateService
|
| 460 |
+
Resource: '*'
|
| 461 |
+
|
| 462 |
+
EC2InstanceProfile:
|
| 463 |
+
Type: AWS::IAM::InstanceProfile
|
| 464 |
+
Properties:
|
| 465 |
+
Path: /
|
| 466 |
+
Roles:
|
| 467 |
+
- !Ref EC2Role
|
| 468 |
+
|
| 469 |
+
Outputs:
|
| 470 |
+
EcsService:
|
| 471 |
+
Value: !Ref Service
|
| 472 |
+
|
| 473 |
+
EcsCluster:
|
| 474 |
+
Value: !Ref ECSCluster
|
| 475 |
+
|
| 476 |
+
EcsTaskDef:
|
| 477 |
+
Value: !Ref TaskDefinition
|
| 478 |
+
|
| 479 |
+
ECSALB:
|
| 480 |
+
Description: Your ALB DNS URL
|
| 481 |
+
Value: !Join
|
| 482 |
+
- ""
|
| 483 |
+
- - !GetAtt ECSALB.DNSName
|
human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/clusters/private-vpc.json
ADDED
|
@@ -0,0 +1,937 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "This stack deploys a Fargate cluster that is in a VPC with both public and private subnets. Containers can be deployed into either the public subnets or the private subnets, and there are two load balancers. One is inside the public subnet, which can be used to send traffic to the containers in the private subnet, and one in the private subnet, which can be used for private internal traffic between internal services.",
|
| 4 |
+
"Mappings": {
|
| 5 |
+
"SubnetConfig": {
|
| 6 |
+
"VPC": {
|
| 7 |
+
"CIDR": "10.0.0.0/16"
|
| 8 |
+
},
|
| 9 |
+
"PublicOne": {
|
| 10 |
+
"CIDR": "10.0.0.0/24"
|
| 11 |
+
},
|
| 12 |
+
"PublicTwo": {
|
| 13 |
+
"CIDR": "10.0.1.0/24"
|
| 14 |
+
},
|
| 15 |
+
"PrivateOne": {
|
| 16 |
+
"CIDR": "10.0.2.0/24"
|
| 17 |
+
},
|
| 18 |
+
"PrivateTwo": {
|
| 19 |
+
"CIDR": "10.0.3.0/24"
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
},
|
| 23 |
+
"Resources": {
|
| 24 |
+
"VPC": {
|
| 25 |
+
"Type": "AWS::EC2::VPC",
|
| 26 |
+
"Properties": {
|
| 27 |
+
"EnableDnsSupport": true,
|
| 28 |
+
"EnableDnsHostnames": true,
|
| 29 |
+
"CidrBlock": {
|
| 30 |
+
"Fn::FindInMap": [
|
| 31 |
+
"SubnetConfig",
|
| 32 |
+
"VPC",
|
| 33 |
+
"CIDR"
|
| 34 |
+
]
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
},
|
| 38 |
+
"PublicSubnetOne": {
|
| 39 |
+
"Type": "AWS::EC2::Subnet",
|
| 40 |
+
"Properties": {
|
| 41 |
+
"AvailabilityZone": {
|
| 42 |
+
"Fn::Select": [
|
| 43 |
+
0,
|
| 44 |
+
{
|
| 45 |
+
"Fn::GetAZs": {
|
| 46 |
+
"Ref": "AWS::Region"
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
]
|
| 50 |
+
},
|
| 51 |
+
"VpcId": {
|
| 52 |
+
"Ref": "VPC"
|
| 53 |
+
},
|
| 54 |
+
"CidrBlock": {
|
| 55 |
+
"Fn::FindInMap": [
|
| 56 |
+
"SubnetConfig",
|
| 57 |
+
"PublicOne",
|
| 58 |
+
"CIDR"
|
| 59 |
+
]
|
| 60 |
+
},
|
| 61 |
+
"MapPublicIpOnLaunch": true
|
| 62 |
+
}
|
| 63 |
+
},
|
| 64 |
+
"PublicSubnetTwo": {
|
| 65 |
+
"Type": "AWS::EC2::Subnet",
|
| 66 |
+
"Properties": {
|
| 67 |
+
"AvailabilityZone": {
|
| 68 |
+
"Fn::Select": [
|
| 69 |
+
1,
|
| 70 |
+
{
|
| 71 |
+
"Fn::GetAZs": {
|
| 72 |
+
"Ref": "AWS::Region"
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
]
|
| 76 |
+
},
|
| 77 |
+
"VpcId": {
|
| 78 |
+
"Ref": "VPC"
|
| 79 |
+
},
|
| 80 |
+
"CidrBlock": {
|
| 81 |
+
"Fn::FindInMap": [
|
| 82 |
+
"SubnetConfig",
|
| 83 |
+
"PublicTwo",
|
| 84 |
+
"CIDR"
|
| 85 |
+
]
|
| 86 |
+
},
|
| 87 |
+
"MapPublicIpOnLaunch": true
|
| 88 |
+
}
|
| 89 |
+
},
|
| 90 |
+
"PrivateSubnetOne": {
|
| 91 |
+
"Type": "AWS::EC2::Subnet",
|
| 92 |
+
"Properties": {
|
| 93 |
+
"AvailabilityZone": {
|
| 94 |
+
"Fn::Select": [
|
| 95 |
+
0,
|
| 96 |
+
{
|
| 97 |
+
"Fn::GetAZs": {
|
| 98 |
+
"Ref": "AWS::Region"
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
]
|
| 102 |
+
},
|
| 103 |
+
"VpcId": {
|
| 104 |
+
"Ref": "VPC"
|
| 105 |
+
},
|
| 106 |
+
"CidrBlock": {
|
| 107 |
+
"Fn::FindInMap": [
|
| 108 |
+
"SubnetConfig",
|
| 109 |
+
"PrivateOne",
|
| 110 |
+
"CIDR"
|
| 111 |
+
]
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
},
|
| 115 |
+
"PrivateSubnetTwo": {
|
| 116 |
+
"Type": "AWS::EC2::Subnet",
|
| 117 |
+
"Properties": {
|
| 118 |
+
"AvailabilityZone": {
|
| 119 |
+
"Fn::Select": [
|
| 120 |
+
1,
|
| 121 |
+
{
|
| 122 |
+
"Fn::GetAZs": {
|
| 123 |
+
"Ref": "AWS::Region"
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
]
|
| 127 |
+
},
|
| 128 |
+
"VpcId": {
|
| 129 |
+
"Ref": "VPC"
|
| 130 |
+
},
|
| 131 |
+
"CidrBlock": {
|
| 132 |
+
"Fn::FindInMap": [
|
| 133 |
+
"SubnetConfig",
|
| 134 |
+
"PrivateTwo",
|
| 135 |
+
"CIDR"
|
| 136 |
+
]
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
},
|
| 140 |
+
"InternetGateway": {
|
| 141 |
+
"Type": "AWS::EC2::InternetGateway"
|
| 142 |
+
},
|
| 143 |
+
"GatewayAttachement": {
|
| 144 |
+
"Type": "AWS::EC2::VPCGatewayAttachment",
|
| 145 |
+
"Properties": {
|
| 146 |
+
"VpcId": {
|
| 147 |
+
"Ref": "VPC"
|
| 148 |
+
},
|
| 149 |
+
"InternetGatewayId": {
|
| 150 |
+
"Ref": "InternetGateway"
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
+
},
|
| 154 |
+
"PublicRouteTable": {
|
| 155 |
+
"Type": "AWS::EC2::RouteTable",
|
| 156 |
+
"Properties": {
|
| 157 |
+
"VpcId": {
|
| 158 |
+
"Ref": "VPC"
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
},
|
| 162 |
+
"PublicRoute": {
|
| 163 |
+
"Type": "AWS::EC2::Route",
|
| 164 |
+
"DependsOn": "GatewayAttachement",
|
| 165 |
+
"Properties": {
|
| 166 |
+
"RouteTableId": {
|
| 167 |
+
"Ref": "PublicRouteTable"
|
| 168 |
+
},
|
| 169 |
+
"DestinationCidrBlock": "0.0.0.0/0",
|
| 170 |
+
"GatewayId": {
|
| 171 |
+
"Ref": "InternetGateway"
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
},
|
| 175 |
+
"PublicSubnetOneRouteTableAssociation": {
|
| 176 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 177 |
+
"Properties": {
|
| 178 |
+
"SubnetId": {
|
| 179 |
+
"Ref": "PublicSubnetOne"
|
| 180 |
+
},
|
| 181 |
+
"RouteTableId": {
|
| 182 |
+
"Ref": "PublicRouteTable"
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
},
|
| 186 |
+
"PublicSubnetTwoRouteTableAssociation": {
|
| 187 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 188 |
+
"Properties": {
|
| 189 |
+
"SubnetId": {
|
| 190 |
+
"Ref": "PublicSubnetTwo"
|
| 191 |
+
},
|
| 192 |
+
"RouteTableId": {
|
| 193 |
+
"Ref": "PublicRouteTable"
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
},
|
| 197 |
+
"NatGatewayOneAttachment": {
|
| 198 |
+
"Type": "AWS::EC2::EIP",
|
| 199 |
+
"DependsOn": "GatewayAttachement",
|
| 200 |
+
"Properties": {
|
| 201 |
+
"Domain": "vpc"
|
| 202 |
+
}
|
| 203 |
+
},
|
| 204 |
+
"NatGatewayTwoAttachment": {
|
| 205 |
+
"Type": "AWS::EC2::EIP",
|
| 206 |
+
"DependsOn": "GatewayAttachement",
|
| 207 |
+
"Properties": {
|
| 208 |
+
"Domain": "vpc"
|
| 209 |
+
}
|
| 210 |
+
},
|
| 211 |
+
"NatGatewayOne": {
|
| 212 |
+
"Type": "AWS::EC2::NatGateway",
|
| 213 |
+
"Properties": {
|
| 214 |
+
"AllocationId": {
|
| 215 |
+
"Fn::GetAtt": [
|
| 216 |
+
"NatGatewayOneAttachment",
|
| 217 |
+
"AllocationId"
|
| 218 |
+
]
|
| 219 |
+
},
|
| 220 |
+
"SubnetId": {
|
| 221 |
+
"Ref": "PublicSubnetOne"
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
},
|
| 225 |
+
"NatGatewayTwo": {
|
| 226 |
+
"Type": "AWS::EC2::NatGateway",
|
| 227 |
+
"Properties": {
|
| 228 |
+
"AllocationId": {
|
| 229 |
+
"Fn::GetAtt": [
|
| 230 |
+
"NatGatewayTwoAttachment",
|
| 231 |
+
"AllocationId"
|
| 232 |
+
]
|
| 233 |
+
},
|
| 234 |
+
"SubnetId": {
|
| 235 |
+
"Ref": "PublicSubnetTwo"
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
},
|
| 239 |
+
"PrivateRouteTableOne": {
|
| 240 |
+
"Type": "AWS::EC2::RouteTable",
|
| 241 |
+
"Properties": {
|
| 242 |
+
"VpcId": {
|
| 243 |
+
"Ref": "VPC"
|
| 244 |
+
}
|
| 245 |
+
}
|
| 246 |
+
},
|
| 247 |
+
"PrivateRouteOne": {
|
| 248 |
+
"Type": "AWS::EC2::Route",
|
| 249 |
+
"Properties": {
|
| 250 |
+
"RouteTableId": {
|
| 251 |
+
"Ref": "PrivateRouteTableOne"
|
| 252 |
+
},
|
| 253 |
+
"DestinationCidrBlock": "0.0.0.0/0",
|
| 254 |
+
"NatGatewayId": {
|
| 255 |
+
"Ref": "NatGatewayOne"
|
| 256 |
+
}
|
| 257 |
+
}
|
| 258 |
+
},
|
| 259 |
+
"PrivateRouteTableOneAssociation": {
|
| 260 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 261 |
+
"Properties": {
|
| 262 |
+
"RouteTableId": {
|
| 263 |
+
"Ref": "PrivateRouteTableOne"
|
| 264 |
+
},
|
| 265 |
+
"SubnetId": {
|
| 266 |
+
"Ref": "PrivateSubnetOne"
|
| 267 |
+
}
|
| 268 |
+
}
|
| 269 |
+
},
|
| 270 |
+
"PrivateRouteTableTwo": {
|
| 271 |
+
"Type": "AWS::EC2::RouteTable",
|
| 272 |
+
"Properties": {
|
| 273 |
+
"VpcId": {
|
| 274 |
+
"Ref": "VPC"
|
| 275 |
+
}
|
| 276 |
+
}
|
| 277 |
+
},
|
| 278 |
+
"PrivateRouteTwo": {
|
| 279 |
+
"Type": "AWS::EC2::Route",
|
| 280 |
+
"Properties": {
|
| 281 |
+
"RouteTableId": {
|
| 282 |
+
"Ref": "PrivateRouteTableTwo"
|
| 283 |
+
},
|
| 284 |
+
"DestinationCidrBlock": "0.0.0.0/0",
|
| 285 |
+
"NatGatewayId": {
|
| 286 |
+
"Ref": "NatGatewayTwo"
|
| 287 |
+
}
|
| 288 |
+
}
|
| 289 |
+
},
|
| 290 |
+
"PrivateRouteTableTwoAssociation": {
|
| 291 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 292 |
+
"Properties": {
|
| 293 |
+
"RouteTableId": {
|
| 294 |
+
"Ref": "PrivateRouteTableTwo"
|
| 295 |
+
},
|
| 296 |
+
"SubnetId": {
|
| 297 |
+
"Ref": "PrivateSubnetTwo"
|
| 298 |
+
}
|
| 299 |
+
}
|
| 300 |
+
},
|
| 301 |
+
"DynamoDBEndpoint": {
|
| 302 |
+
"Type": "AWS::EC2::VPCEndpoint",
|
| 303 |
+
"Properties": {
|
| 304 |
+
"PolicyDocument": {
|
| 305 |
+
"Version": "2012-10-17",
|
| 306 |
+
"Statement": [
|
| 307 |
+
{
|
| 308 |
+
"Effect": "Allow",
|
| 309 |
+
"Action": "*",
|
| 310 |
+
"Principal": "*",
|
| 311 |
+
"Resource": "*"
|
| 312 |
+
}
|
| 313 |
+
]
|
| 314 |
+
},
|
| 315 |
+
"RouteTableIds": [
|
| 316 |
+
{
|
| 317 |
+
"Ref": "PrivateRouteTableOne"
|
| 318 |
+
},
|
| 319 |
+
{
|
| 320 |
+
"Ref": "PrivateRouteTableTwo"
|
| 321 |
+
}
|
| 322 |
+
],
|
| 323 |
+
"ServiceName": {
|
| 324 |
+
"Fn::Join": [
|
| 325 |
+
"",
|
| 326 |
+
[
|
| 327 |
+
"com.amazonaws.",
|
| 328 |
+
{
|
| 329 |
+
"Ref": "AWS::Region"
|
| 330 |
+
},
|
| 331 |
+
".dynamodb"
|
| 332 |
+
]
|
| 333 |
+
]
|
| 334 |
+
},
|
| 335 |
+
"VpcId": {
|
| 336 |
+
"Ref": "VPC"
|
| 337 |
+
}
|
| 338 |
+
}
|
| 339 |
+
},
|
| 340 |
+
"ECSCluster": {
|
| 341 |
+
"Type": "AWS::ECS::Cluster"
|
| 342 |
+
},
|
| 343 |
+
"FargateContainerSecurityGroup": {
|
| 344 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 345 |
+
"Properties": {
|
| 346 |
+
"GroupDescription": "Access to the Fargate containers",
|
| 347 |
+
"VpcId": {
|
| 348 |
+
"Ref": "VPC"
|
| 349 |
+
}
|
| 350 |
+
}
|
| 351 |
+
},
|
| 352 |
+
"EcsSecurityGroupIngressFromPublicALB": {
|
| 353 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 354 |
+
"Properties": {
|
| 355 |
+
"Description": "Ingress from the public ALB",
|
| 356 |
+
"GroupId": {
|
| 357 |
+
"Ref": "FargateContainerSecurityGroup"
|
| 358 |
+
},
|
| 359 |
+
"IpProtocol": "-1",
|
| 360 |
+
"SourceSecurityGroupId": {
|
| 361 |
+
"Ref": "PublicLoadBalancerSG"
|
| 362 |
+
}
|
| 363 |
+
}
|
| 364 |
+
},
|
| 365 |
+
"EcsSecurityGroupIngressFromPrivateALB": {
|
| 366 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 367 |
+
"Properties": {
|
| 368 |
+
"Description": "Ingress from the private ALB",
|
| 369 |
+
"GroupId": {
|
| 370 |
+
"Ref": "FargateContainerSecurityGroup"
|
| 371 |
+
},
|
| 372 |
+
"IpProtocol": "-1",
|
| 373 |
+
"SourceSecurityGroupId": {
|
| 374 |
+
"Ref": "PrivateLoadBalancerSG"
|
| 375 |
+
}
|
| 376 |
+
}
|
| 377 |
+
},
|
| 378 |
+
"EcsSecurityGroupIngressFromSelf": {
|
| 379 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 380 |
+
"Properties": {
|
| 381 |
+
"Description": "Ingress from other containers in the same security group",
|
| 382 |
+
"GroupId": {
|
| 383 |
+
"Ref": "FargateContainerSecurityGroup"
|
| 384 |
+
},
|
| 385 |
+
"IpProtocol": "-1",
|
| 386 |
+
"SourceSecurityGroupId": {
|
| 387 |
+
"Ref": "FargateContainerSecurityGroup"
|
| 388 |
+
}
|
| 389 |
+
}
|
| 390 |
+
},
|
| 391 |
+
"PublicLoadBalancerSG": {
|
| 392 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 393 |
+
"Properties": {
|
| 394 |
+
"GroupDescription": "Access to the public facing load balancer",
|
| 395 |
+
"VpcId": {
|
| 396 |
+
"Ref": "VPC"
|
| 397 |
+
},
|
| 398 |
+
"SecurityGroupIngress": [
|
| 399 |
+
{
|
| 400 |
+
"CidrIp": "0.0.0.0/0",
|
| 401 |
+
"IpProtocol": "-1"
|
| 402 |
+
}
|
| 403 |
+
]
|
| 404 |
+
}
|
| 405 |
+
},
|
| 406 |
+
"PublicLoadBalancer": {
|
| 407 |
+
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
|
| 408 |
+
"DependsOn": "GatewayAttachement",
|
| 409 |
+
"Properties": {
|
| 410 |
+
"Scheme": "internet-facing",
|
| 411 |
+
"LoadBalancerAttributes": [
|
| 412 |
+
{
|
| 413 |
+
"Key": "idle_timeout.timeout_seconds",
|
| 414 |
+
"Value": "30"
|
| 415 |
+
}
|
| 416 |
+
],
|
| 417 |
+
"Subnets": [
|
| 418 |
+
{
|
| 419 |
+
"Ref": "PublicSubnetOne"
|
| 420 |
+
},
|
| 421 |
+
{
|
| 422 |
+
"Ref": "PublicSubnetTwo"
|
| 423 |
+
}
|
| 424 |
+
],
|
| 425 |
+
"SecurityGroups": [
|
| 426 |
+
{
|
| 427 |
+
"Ref": "PublicLoadBalancerSG"
|
| 428 |
+
}
|
| 429 |
+
]
|
| 430 |
+
}
|
| 431 |
+
},
|
| 432 |
+
"DummyTargetGroupPublic": {
|
| 433 |
+
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
|
| 434 |
+
"Properties": {
|
| 435 |
+
"HealthCheckIntervalSeconds": 6,
|
| 436 |
+
"HealthCheckPath": "/",
|
| 437 |
+
"HealthCheckProtocol": "HTTP",
|
| 438 |
+
"HealthCheckTimeoutSeconds": 5,
|
| 439 |
+
"HealthyThresholdCount": 2,
|
| 440 |
+
"Name": {
|
| 441 |
+
"Fn::Join": [
|
| 442 |
+
"-",
|
| 443 |
+
[
|
| 444 |
+
{
|
| 445 |
+
"Ref": "AWS::StackName"
|
| 446 |
+
},
|
| 447 |
+
"drop-1"
|
| 448 |
+
]
|
| 449 |
+
]
|
| 450 |
+
},
|
| 451 |
+
"Port": 80,
|
| 452 |
+
"Protocol": "HTTP",
|
| 453 |
+
"UnhealthyThresholdCount": 2,
|
| 454 |
+
"VpcId": {
|
| 455 |
+
"Ref": "VPC"
|
| 456 |
+
}
|
| 457 |
+
}
|
| 458 |
+
},
|
| 459 |
+
"PublicLoadBalancerListener": {
|
| 460 |
+
"Type": "AWS::ElasticLoadBalancingV2::Listener",
|
| 461 |
+
"Properties": {
|
| 462 |
+
"DefaultActions": [
|
| 463 |
+
{
|
| 464 |
+
"TargetGroupArn": {
|
| 465 |
+
"Ref": "DummyTargetGroupPublic"
|
| 466 |
+
},
|
| 467 |
+
"Type": "forward"
|
| 468 |
+
}
|
| 469 |
+
],
|
| 470 |
+
"LoadBalancerArn": {
|
| 471 |
+
"Ref": "PublicLoadBalancer"
|
| 472 |
+
},
|
| 473 |
+
"Port": 80,
|
| 474 |
+
"Protocol": "HTTP"
|
| 475 |
+
}
|
| 476 |
+
},
|
| 477 |
+
"PrivateLoadBalancerSG": {
|
| 478 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 479 |
+
"Properties": {
|
| 480 |
+
"GroupDescription": "Access to the internal load balancer",
|
| 481 |
+
"VpcId": {
|
| 482 |
+
"Ref": "VPC"
|
| 483 |
+
}
|
| 484 |
+
}
|
| 485 |
+
},
|
| 486 |
+
"PrivateLoadBalancerIngressFromECS": {
|
| 487 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 488 |
+
"Properties": {
|
| 489 |
+
"Description": "Only accept traffic from a container in the fargate container security group",
|
| 490 |
+
"GroupId": {
|
| 491 |
+
"Ref": "PrivateLoadBalancerSG"
|
| 492 |
+
},
|
| 493 |
+
"IpProtocol": "-1",
|
| 494 |
+
"SourceSecurityGroupId": {
|
| 495 |
+
"Ref": "FargateContainerSecurityGroup"
|
| 496 |
+
}
|
| 497 |
+
}
|
| 498 |
+
},
|
| 499 |
+
"PrivateLoadBalancer": {
|
| 500 |
+
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
|
| 501 |
+
"Properties": {
|
| 502 |
+
"Scheme": "internal",
|
| 503 |
+
"LoadBalancerAttributes": [
|
| 504 |
+
{
|
| 505 |
+
"Key": "idle_timeout.timeout_seconds",
|
| 506 |
+
"Value": "30"
|
| 507 |
+
}
|
| 508 |
+
],
|
| 509 |
+
"Subnets": [
|
| 510 |
+
{
|
| 511 |
+
"Ref": "PrivateSubnetOne"
|
| 512 |
+
},
|
| 513 |
+
{
|
| 514 |
+
"Ref": "PrivateSubnetTwo"
|
| 515 |
+
}
|
| 516 |
+
],
|
| 517 |
+
"SecurityGroups": [
|
| 518 |
+
{
|
| 519 |
+
"Ref": "PrivateLoadBalancerSG"
|
| 520 |
+
}
|
| 521 |
+
]
|
| 522 |
+
}
|
| 523 |
+
},
|
| 524 |
+
"DummyTargetGroupPrivate": {
|
| 525 |
+
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
|
| 526 |
+
"Properties": {
|
| 527 |
+
"HealthCheckIntervalSeconds": 6,
|
| 528 |
+
"HealthCheckPath": "/",
|
| 529 |
+
"HealthCheckProtocol": "HTTP",
|
| 530 |
+
"HealthCheckTimeoutSeconds": 5,
|
| 531 |
+
"HealthyThresholdCount": 2,
|
| 532 |
+
"Name": {
|
| 533 |
+
"Fn::Join": [
|
| 534 |
+
"-",
|
| 535 |
+
[
|
| 536 |
+
{
|
| 537 |
+
"Ref": "AWS::StackName"
|
| 538 |
+
},
|
| 539 |
+
"drop-2"
|
| 540 |
+
]
|
| 541 |
+
]
|
| 542 |
+
},
|
| 543 |
+
"Port": 80,
|
| 544 |
+
"Protocol": "HTTP",
|
| 545 |
+
"UnhealthyThresholdCount": 2,
|
| 546 |
+
"VpcId": {
|
| 547 |
+
"Ref": "VPC"
|
| 548 |
+
}
|
| 549 |
+
}
|
| 550 |
+
},
|
| 551 |
+
"PrivateLoadBalancerListener": {
|
| 552 |
+
"Type": "AWS::ElasticLoadBalancingV2::Listener",
|
| 553 |
+
"Properties": {
|
| 554 |
+
"DefaultActions": [
|
| 555 |
+
{
|
| 556 |
+
"TargetGroupArn": {
|
| 557 |
+
"Ref": "DummyTargetGroupPrivate"
|
| 558 |
+
},
|
| 559 |
+
"Type": "forward"
|
| 560 |
+
}
|
| 561 |
+
],
|
| 562 |
+
"LoadBalancerArn": {
|
| 563 |
+
"Ref": "PrivateLoadBalancer"
|
| 564 |
+
},
|
| 565 |
+
"Port": 80,
|
| 566 |
+
"Protocol": "HTTP"
|
| 567 |
+
}
|
| 568 |
+
},
|
| 569 |
+
"ECSRole": {
|
| 570 |
+
"Type": "AWS::IAM::Role",
|
| 571 |
+
"Properties": {
|
| 572 |
+
"AssumeRolePolicyDocument": {
|
| 573 |
+
"Statement": [
|
| 574 |
+
{
|
| 575 |
+
"Effect": "Allow",
|
| 576 |
+
"Principal": {
|
| 577 |
+
"Service": [
|
| 578 |
+
"ecs.amazonaws.com"
|
| 579 |
+
]
|
| 580 |
+
},
|
| 581 |
+
"Action": [
|
| 582 |
+
"sts:AssumeRole"
|
| 583 |
+
]
|
| 584 |
+
}
|
| 585 |
+
]
|
| 586 |
+
},
|
| 587 |
+
"Path": "/",
|
| 588 |
+
"Policies": [
|
| 589 |
+
{
|
| 590 |
+
"PolicyName": "ecs-service",
|
| 591 |
+
"PolicyDocument": {
|
| 592 |
+
"Statement": [
|
| 593 |
+
{
|
| 594 |
+
"Effect": "Allow",
|
| 595 |
+
"Action": [
|
| 596 |
+
"ec2:AttachNetworkInterface",
|
| 597 |
+
"ec2:CreateNetworkInterface",
|
| 598 |
+
"ec2:CreateNetworkInterfacePermission",
|
| 599 |
+
"ec2:DeleteNetworkInterface",
|
| 600 |
+
"ec2:DeleteNetworkInterfacePermission",
|
| 601 |
+
"ec2:Describe*",
|
| 602 |
+
"ec2:DetachNetworkInterface",
|
| 603 |
+
"elasticloadbalancing:DeregisterInstancesFromLoadBalancer",
|
| 604 |
+
"elasticloadbalancing:DeregisterTargets",
|
| 605 |
+
"elasticloadbalancing:Describe*",
|
| 606 |
+
"elasticloadbalancing:RegisterInstancesWithLoadBalancer",
|
| 607 |
+
"elasticloadbalancing:RegisterTargets"
|
| 608 |
+
],
|
| 609 |
+
"Resource": "*"
|
| 610 |
+
}
|
| 611 |
+
]
|
| 612 |
+
}
|
| 613 |
+
}
|
| 614 |
+
]
|
| 615 |
+
}
|
| 616 |
+
},
|
| 617 |
+
"ECSTaskExecutionRole": {
|
| 618 |
+
"Type": "AWS::IAM::Role",
|
| 619 |
+
"Properties": {
|
| 620 |
+
"AssumeRolePolicyDocument": {
|
| 621 |
+
"Statement": [
|
| 622 |
+
{
|
| 623 |
+
"Effect": "Allow",
|
| 624 |
+
"Principal": {
|
| 625 |
+
"Service": [
|
| 626 |
+
"ecs-tasks.amazonaws.com"
|
| 627 |
+
]
|
| 628 |
+
},
|
| 629 |
+
"Action": [
|
| 630 |
+
"sts:AssumeRole"
|
| 631 |
+
]
|
| 632 |
+
}
|
| 633 |
+
]
|
| 634 |
+
},
|
| 635 |
+
"Path": "/",
|
| 636 |
+
"Policies": [
|
| 637 |
+
{
|
| 638 |
+
"PolicyName": "AmazonECSTaskExecutionRolePolicy",
|
| 639 |
+
"PolicyDocument": {
|
| 640 |
+
"Statement": [
|
| 641 |
+
{
|
| 642 |
+
"Effect": "Allow",
|
| 643 |
+
"Action": [
|
| 644 |
+
"ecr:GetAuthorizationToken",
|
| 645 |
+
"ecr:BatchCheckLayerAvailability",
|
| 646 |
+
"ecr:GetDownloadUrlForLayer",
|
| 647 |
+
"ecr:BatchGetImage",
|
| 648 |
+
"logs:CreateLogStream",
|
| 649 |
+
"logs:PutLogEvents"
|
| 650 |
+
],
|
| 651 |
+
"Resource": "*"
|
| 652 |
+
}
|
| 653 |
+
]
|
| 654 |
+
}
|
| 655 |
+
}
|
| 656 |
+
]
|
| 657 |
+
}
|
| 658 |
+
}
|
| 659 |
+
},
|
| 660 |
+
"Outputs": {
|
| 661 |
+
"ClusterName": {
|
| 662 |
+
"Description": "The name of the ECS cluster",
|
| 663 |
+
"Value": {
|
| 664 |
+
"Ref": "ECSCluster"
|
| 665 |
+
},
|
| 666 |
+
"Export": {
|
| 667 |
+
"Name": {
|
| 668 |
+
"Fn::Join": [
|
| 669 |
+
":",
|
| 670 |
+
[
|
| 671 |
+
{
|
| 672 |
+
"Ref": "AWS::StackName"
|
| 673 |
+
},
|
| 674 |
+
"ClusterName"
|
| 675 |
+
]
|
| 676 |
+
]
|
| 677 |
+
}
|
| 678 |
+
}
|
| 679 |
+
},
|
| 680 |
+
"InternalUrl": {
|
| 681 |
+
"Description": "The url of the internal load balancer",
|
| 682 |
+
"Value": {
|
| 683 |
+
"Fn::Join": [
|
| 684 |
+
"",
|
| 685 |
+
[
|
| 686 |
+
"http://",
|
| 687 |
+
{
|
| 688 |
+
"Fn::GetAtt": [
|
| 689 |
+
"PrivateLoadBalancer",
|
| 690 |
+
"DNSName"
|
| 691 |
+
]
|
| 692 |
+
}
|
| 693 |
+
]
|
| 694 |
+
]
|
| 695 |
+
},
|
| 696 |
+
"Export": {
|
| 697 |
+
"Name": {
|
| 698 |
+
"Fn::Join": [
|
| 699 |
+
":",
|
| 700 |
+
[
|
| 701 |
+
{
|
| 702 |
+
"Ref": "AWS::StackName"
|
| 703 |
+
},
|
| 704 |
+
"InternalUrl"
|
| 705 |
+
]
|
| 706 |
+
]
|
| 707 |
+
}
|
| 708 |
+
}
|
| 709 |
+
},
|
| 710 |
+
"ExternalUrl": {
|
| 711 |
+
"Description": "The url of the external load balancer",
|
| 712 |
+
"Value": {
|
| 713 |
+
"Fn::Join": [
|
| 714 |
+
"",
|
| 715 |
+
[
|
| 716 |
+
"http://",
|
| 717 |
+
{
|
| 718 |
+
"Fn::GetAtt": [
|
| 719 |
+
"PublicLoadBalancer",
|
| 720 |
+
"DNSName"
|
| 721 |
+
]
|
| 722 |
+
}
|
| 723 |
+
]
|
| 724 |
+
]
|
| 725 |
+
},
|
| 726 |
+
"Export": {
|
| 727 |
+
"Name": {
|
| 728 |
+
"Fn::Join": [
|
| 729 |
+
":",
|
| 730 |
+
[
|
| 731 |
+
{
|
| 732 |
+
"Ref": "AWS::StackName"
|
| 733 |
+
},
|
| 734 |
+
"ExternalUrl"
|
| 735 |
+
]
|
| 736 |
+
]
|
| 737 |
+
}
|
| 738 |
+
}
|
| 739 |
+
},
|
| 740 |
+
"ECSRole": {
|
| 741 |
+
"Description": "The ARN of the ECS role",
|
| 742 |
+
"Value": {
|
| 743 |
+
"Fn::GetAtt": [
|
| 744 |
+
"ECSRole",
|
| 745 |
+
"Arn"
|
| 746 |
+
]
|
| 747 |
+
},
|
| 748 |
+
"Export": {
|
| 749 |
+
"Name": {
|
| 750 |
+
"Fn::Join": [
|
| 751 |
+
":",
|
| 752 |
+
[
|
| 753 |
+
{
|
| 754 |
+
"Ref": "AWS::StackName"
|
| 755 |
+
},
|
| 756 |
+
"ECSRole"
|
| 757 |
+
]
|
| 758 |
+
]
|
| 759 |
+
}
|
| 760 |
+
}
|
| 761 |
+
},
|
| 762 |
+
"ECSTaskExecutionRole": {
|
| 763 |
+
"Description": "The ARN of the ECS role",
|
| 764 |
+
"Value": {
|
| 765 |
+
"Fn::GetAtt": [
|
| 766 |
+
"ECSTaskExecutionRole",
|
| 767 |
+
"Arn"
|
| 768 |
+
]
|
| 769 |
+
},
|
| 770 |
+
"Export": {
|
| 771 |
+
"Name": {
|
| 772 |
+
"Fn::Join": [
|
| 773 |
+
":",
|
| 774 |
+
[
|
| 775 |
+
{
|
| 776 |
+
"Ref": "AWS::StackName"
|
| 777 |
+
},
|
| 778 |
+
"ECSTaskExecutionRole"
|
| 779 |
+
]
|
| 780 |
+
]
|
| 781 |
+
}
|
| 782 |
+
}
|
| 783 |
+
},
|
| 784 |
+
"PublicListener": {
|
| 785 |
+
"Description": "The ARN of the public load balancer's Listener",
|
| 786 |
+
"Value": {
|
| 787 |
+
"Ref": "PublicLoadBalancerListener"
|
| 788 |
+
},
|
| 789 |
+
"Export": {
|
| 790 |
+
"Name": {
|
| 791 |
+
"Fn::Join": [
|
| 792 |
+
":",
|
| 793 |
+
[
|
| 794 |
+
{
|
| 795 |
+
"Ref": "AWS::StackName"
|
| 796 |
+
},
|
| 797 |
+
"PublicListener"
|
| 798 |
+
]
|
| 799 |
+
]
|
| 800 |
+
}
|
| 801 |
+
}
|
| 802 |
+
},
|
| 803 |
+
"PrivateListener": {
|
| 804 |
+
"Description": "The ARN of the private load balancer's Listener",
|
| 805 |
+
"Value": {
|
| 806 |
+
"Ref": "PrivateLoadBalancerListener"
|
| 807 |
+
},
|
| 808 |
+
"Export": {
|
| 809 |
+
"Name": {
|
| 810 |
+
"Fn::Join": [
|
| 811 |
+
":",
|
| 812 |
+
[
|
| 813 |
+
{
|
| 814 |
+
"Ref": "AWS::StackName"
|
| 815 |
+
},
|
| 816 |
+
"PrivateListener"
|
| 817 |
+
]
|
| 818 |
+
]
|
| 819 |
+
}
|
| 820 |
+
}
|
| 821 |
+
},
|
| 822 |
+
"VPCId": {
|
| 823 |
+
"Description": "The ID of the VPC that this stack is deployed in",
|
| 824 |
+
"Value": {
|
| 825 |
+
"Ref": "VPC"
|
| 826 |
+
},
|
| 827 |
+
"Export": {
|
| 828 |
+
"Name": {
|
| 829 |
+
"Fn::Join": [
|
| 830 |
+
":",
|
| 831 |
+
[
|
| 832 |
+
{
|
| 833 |
+
"Ref": "AWS::StackName"
|
| 834 |
+
},
|
| 835 |
+
"VPCId"
|
| 836 |
+
]
|
| 837 |
+
]
|
| 838 |
+
}
|
| 839 |
+
}
|
| 840 |
+
},
|
| 841 |
+
"PublicSubnetOne": {
|
| 842 |
+
"Description": "Public subnet one",
|
| 843 |
+
"Value": {
|
| 844 |
+
"Ref": "PublicSubnetOne"
|
| 845 |
+
},
|
| 846 |
+
"Export": {
|
| 847 |
+
"Name": {
|
| 848 |
+
"Fn::Join": [
|
| 849 |
+
":",
|
| 850 |
+
[
|
| 851 |
+
{
|
| 852 |
+
"Ref": "AWS::StackName"
|
| 853 |
+
},
|
| 854 |
+
"PublicSubnetOne"
|
| 855 |
+
]
|
| 856 |
+
]
|
| 857 |
+
}
|
| 858 |
+
}
|
| 859 |
+
},
|
| 860 |
+
"PublicSubnetTwo": {
|
| 861 |
+
"Description": "Public subnet two",
|
| 862 |
+
"Value": {
|
| 863 |
+
"Ref": "PublicSubnetTwo"
|
| 864 |
+
},
|
| 865 |
+
"Export": {
|
| 866 |
+
"Name": {
|
| 867 |
+
"Fn::Join": [
|
| 868 |
+
":",
|
| 869 |
+
[
|
| 870 |
+
{
|
| 871 |
+
"Ref": "AWS::StackName"
|
| 872 |
+
},
|
| 873 |
+
"PublicSubnetTwo"
|
| 874 |
+
]
|
| 875 |
+
]
|
| 876 |
+
}
|
| 877 |
+
}
|
| 878 |
+
},
|
| 879 |
+
"PrivateSubnetOne": {
|
| 880 |
+
"Description": "Private subnet one",
|
| 881 |
+
"Value": {
|
| 882 |
+
"Ref": "PrivateSubnetOne"
|
| 883 |
+
},
|
| 884 |
+
"Export": {
|
| 885 |
+
"Name": {
|
| 886 |
+
"Fn::Join": [
|
| 887 |
+
":",
|
| 888 |
+
[
|
| 889 |
+
{
|
| 890 |
+
"Ref": "AWS::StackName"
|
| 891 |
+
},
|
| 892 |
+
"PrivateSubnetOne"
|
| 893 |
+
]
|
| 894 |
+
]
|
| 895 |
+
}
|
| 896 |
+
}
|
| 897 |
+
},
|
| 898 |
+
"PrivateSubnetTwo": {
|
| 899 |
+
"Description": "Private subnet two",
|
| 900 |
+
"Value": {
|
| 901 |
+
"Ref": "PrivateSubnetTwo"
|
| 902 |
+
},
|
| 903 |
+
"Export": {
|
| 904 |
+
"Name": {
|
| 905 |
+
"Fn::Join": [
|
| 906 |
+
":",
|
| 907 |
+
[
|
| 908 |
+
{
|
| 909 |
+
"Ref": "AWS::StackName"
|
| 910 |
+
},
|
| 911 |
+
"PrivateSubnetTwo"
|
| 912 |
+
]
|
| 913 |
+
]
|
| 914 |
+
}
|
| 915 |
+
}
|
| 916 |
+
},
|
| 917 |
+
"FargateContainerSecurityGroup": {
|
| 918 |
+
"Description": "A security group used to allow Fargate containers to receive traffic",
|
| 919 |
+
"Value": {
|
| 920 |
+
"Ref": "FargateContainerSecurityGroup"
|
| 921 |
+
},
|
| 922 |
+
"Export": {
|
| 923 |
+
"Name": {
|
| 924 |
+
"Fn::Join": [
|
| 925 |
+
":",
|
| 926 |
+
[
|
| 927 |
+
{
|
| 928 |
+
"Ref": "AWS::StackName"
|
| 929 |
+
},
|
| 930 |
+
"FargateContainerSecurityGroup"
|
| 931 |
+
]
|
| 932 |
+
]
|
| 933 |
+
}
|
| 934 |
+
}
|
| 935 |
+
}
|
| 936 |
+
}
|
| 937 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/clusters/private-vpc.yaml
ADDED
|
@@ -0,0 +1,602 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: This stack deploys a Fargate cluster that is in a VPC with both public and private subnets. Containers can be deployed into either the public subnets or the private subnets, and there are two load balancers. One is inside the public subnet, which can be used to send traffic to the containers in the private subnet, and one in the private subnet, which can be used for private internal traffic between internal services.
|
| 4 |
+
|
| 5 |
+
Mappings:
|
| 6 |
+
|
| 7 |
+
# Hard values for the subnet masks. These masks define
|
| 8 |
+
# the range of internal IP addresses that can be assigned.
|
| 9 |
+
# The VPC can have all IP's from 10.0.0.0 to 10.0.255.255
|
| 10 |
+
# There are four subnets which cover the ranges:
|
| 11 |
+
#
|
| 12 |
+
# 10.0.0.0 - 10.0.0.255
|
| 13 |
+
# 10.0.1.0 - 10.0.1.255
|
| 14 |
+
# 10.0.2.0 - 10.0.2.255
|
| 15 |
+
# 10.0.3.0 - 10.0.3.255
|
| 16 |
+
#
|
| 17 |
+
# If you need more IP addresses (perhaps you have so many
|
| 18 |
+
# instances that you run out) then you can customize these
|
| 19 |
+
# ranges to add more
|
| 20 |
+
SubnetConfig:
|
| 21 |
+
VPC:
|
| 22 |
+
CIDR: 10.0.0.0/16
|
| 23 |
+
PublicOne:
|
| 24 |
+
CIDR: 10.0.0.0/24
|
| 25 |
+
PublicTwo:
|
| 26 |
+
CIDR: 10.0.1.0/24
|
| 27 |
+
PrivateOne:
|
| 28 |
+
CIDR: 10.0.2.0/24
|
| 29 |
+
PrivateTwo:
|
| 30 |
+
CIDR: 10.0.3.0/24
|
| 31 |
+
|
| 32 |
+
Resources:
|
| 33 |
+
|
| 34 |
+
# VPC in which containers will be networked.
|
| 35 |
+
# It has two public subnets, and two private subnets.
|
| 36 |
+
# We distribute the subnets across the first two available subnets
|
| 37 |
+
# for the region, for high availability.
|
| 38 |
+
VPC:
|
| 39 |
+
Type: AWS::EC2::VPC
|
| 40 |
+
Properties:
|
| 41 |
+
EnableDnsSupport: true
|
| 42 |
+
EnableDnsHostnames: true
|
| 43 |
+
CidrBlock: !FindInMap
|
| 44 |
+
- SubnetConfig
|
| 45 |
+
- VPC
|
| 46 |
+
- CIDR
|
| 47 |
+
|
| 48 |
+
# Two public subnets, where containers can have public IP addresses
|
| 49 |
+
PublicSubnetOne:
|
| 50 |
+
Type: AWS::EC2::Subnet
|
| 51 |
+
Properties:
|
| 52 |
+
AvailabilityZone: !Select
|
| 53 |
+
- 0
|
| 54 |
+
- !GetAZs
|
| 55 |
+
Ref: AWS::Region
|
| 56 |
+
VpcId: !Ref VPC
|
| 57 |
+
CidrBlock: !FindInMap
|
| 58 |
+
- SubnetConfig
|
| 59 |
+
- PublicOne
|
| 60 |
+
- CIDR
|
| 61 |
+
MapPublicIpOnLaunch: true
|
| 62 |
+
|
| 63 |
+
PublicSubnetTwo:
|
| 64 |
+
Type: AWS::EC2::Subnet
|
| 65 |
+
Properties:
|
| 66 |
+
AvailabilityZone: !Select
|
| 67 |
+
- 1
|
| 68 |
+
- !GetAZs
|
| 69 |
+
Ref: AWS::Region
|
| 70 |
+
VpcId: !Ref VPC
|
| 71 |
+
CidrBlock: !FindInMap
|
| 72 |
+
- SubnetConfig
|
| 73 |
+
- PublicTwo
|
| 74 |
+
- CIDR
|
| 75 |
+
MapPublicIpOnLaunch: true
|
| 76 |
+
|
| 77 |
+
# Two private subnets where containers will only have private
|
| 78 |
+
# IP addresses, and will only be reachable by other members of the
|
| 79 |
+
# VPC
|
| 80 |
+
PrivateSubnetOne:
|
| 81 |
+
Type: AWS::EC2::Subnet
|
| 82 |
+
Properties:
|
| 83 |
+
AvailabilityZone: !Select
|
| 84 |
+
- 0
|
| 85 |
+
- !GetAZs
|
| 86 |
+
Ref: AWS::Region
|
| 87 |
+
VpcId: !Ref VPC
|
| 88 |
+
CidrBlock: !FindInMap
|
| 89 |
+
- SubnetConfig
|
| 90 |
+
- PrivateOne
|
| 91 |
+
- CIDR
|
| 92 |
+
|
| 93 |
+
PrivateSubnetTwo:
|
| 94 |
+
Type: AWS::EC2::Subnet
|
| 95 |
+
Properties:
|
| 96 |
+
AvailabilityZone: !Select
|
| 97 |
+
- 1
|
| 98 |
+
- !GetAZs
|
| 99 |
+
Ref: AWS::Region
|
| 100 |
+
VpcId: !Ref VPC
|
| 101 |
+
CidrBlock: !FindInMap
|
| 102 |
+
- SubnetConfig
|
| 103 |
+
- PrivateTwo
|
| 104 |
+
- CIDR
|
| 105 |
+
|
| 106 |
+
# Setup networking resources for the public subnets. Containers
|
| 107 |
+
# in the public subnets have public IP addresses and the routing table
|
| 108 |
+
# sends network traffic via the internet gateway.
|
| 109 |
+
InternetGateway:
|
| 110 |
+
Type: AWS::EC2::InternetGateway
|
| 111 |
+
|
| 112 |
+
GatewayAttachement:
|
| 113 |
+
Type: AWS::EC2::VPCGatewayAttachment
|
| 114 |
+
Properties:
|
| 115 |
+
VpcId: !Ref VPC
|
| 116 |
+
InternetGatewayId: !Ref InternetGateway
|
| 117 |
+
|
| 118 |
+
PublicRouteTable:
|
| 119 |
+
Type: AWS::EC2::RouteTable
|
| 120 |
+
Properties:
|
| 121 |
+
VpcId: !Ref VPC
|
| 122 |
+
|
| 123 |
+
PublicRoute:
|
| 124 |
+
Type: AWS::EC2::Route
|
| 125 |
+
DependsOn: GatewayAttachement
|
| 126 |
+
Properties:
|
| 127 |
+
RouteTableId: !Ref PublicRouteTable
|
| 128 |
+
DestinationCidrBlock: 0.0.0.0/0
|
| 129 |
+
GatewayId: !Ref InternetGateway
|
| 130 |
+
|
| 131 |
+
PublicSubnetOneRouteTableAssociation:
|
| 132 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 133 |
+
Properties:
|
| 134 |
+
SubnetId: !Ref PublicSubnetOne
|
| 135 |
+
RouteTableId: !Ref PublicRouteTable
|
| 136 |
+
|
| 137 |
+
PublicSubnetTwoRouteTableAssociation:
|
| 138 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 139 |
+
Properties:
|
| 140 |
+
SubnetId: !Ref PublicSubnetTwo
|
| 141 |
+
RouteTableId: !Ref PublicRouteTable
|
| 142 |
+
|
| 143 |
+
# Setup networking resources for the private subnets. Containers
|
| 144 |
+
# in these subnets have only private IP addresses, and must use a NAT
|
| 145 |
+
# gateway to talk to the internet. We launch two NAT gateways, one for
|
| 146 |
+
# each private subnet.
|
| 147 |
+
NatGatewayOneAttachment:
|
| 148 |
+
Type: AWS::EC2::EIP
|
| 149 |
+
DependsOn: GatewayAttachement
|
| 150 |
+
Properties:
|
| 151 |
+
Domain: vpc
|
| 152 |
+
|
| 153 |
+
NatGatewayTwoAttachment:
|
| 154 |
+
Type: AWS::EC2::EIP
|
| 155 |
+
DependsOn: GatewayAttachement
|
| 156 |
+
Properties:
|
| 157 |
+
Domain: vpc
|
| 158 |
+
|
| 159 |
+
NatGatewayOne:
|
| 160 |
+
Type: AWS::EC2::NatGateway
|
| 161 |
+
Properties:
|
| 162 |
+
AllocationId: !GetAtt NatGatewayOneAttachment.AllocationId
|
| 163 |
+
SubnetId: !Ref PublicSubnetOne
|
| 164 |
+
|
| 165 |
+
NatGatewayTwo:
|
| 166 |
+
Type: AWS::EC2::NatGateway
|
| 167 |
+
Properties:
|
| 168 |
+
AllocationId: !GetAtt NatGatewayTwoAttachment.AllocationId
|
| 169 |
+
SubnetId: !Ref PublicSubnetTwo
|
| 170 |
+
|
| 171 |
+
PrivateRouteTableOne:
|
| 172 |
+
Type: AWS::EC2::RouteTable
|
| 173 |
+
Properties:
|
| 174 |
+
VpcId: !Ref VPC
|
| 175 |
+
|
| 176 |
+
PrivateRouteOne:
|
| 177 |
+
Type: AWS::EC2::Route
|
| 178 |
+
Properties:
|
| 179 |
+
RouteTableId: !Ref PrivateRouteTableOne
|
| 180 |
+
DestinationCidrBlock: 0.0.0.0/0
|
| 181 |
+
NatGatewayId: !Ref NatGatewayOne
|
| 182 |
+
|
| 183 |
+
PrivateRouteTableOneAssociation:
|
| 184 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 185 |
+
Properties:
|
| 186 |
+
RouteTableId: !Ref PrivateRouteTableOne
|
| 187 |
+
SubnetId: !Ref PrivateSubnetOne
|
| 188 |
+
|
| 189 |
+
PrivateRouteTableTwo:
|
| 190 |
+
Type: AWS::EC2::RouteTable
|
| 191 |
+
Properties:
|
| 192 |
+
VpcId: !Ref VPC
|
| 193 |
+
|
| 194 |
+
PrivateRouteTwo:
|
| 195 |
+
Type: AWS::EC2::Route
|
| 196 |
+
Properties:
|
| 197 |
+
RouteTableId: !Ref PrivateRouteTableTwo
|
| 198 |
+
DestinationCidrBlock: 0.0.0.0/0
|
| 199 |
+
NatGatewayId: !Ref NatGatewayTwo
|
| 200 |
+
|
| 201 |
+
PrivateRouteTableTwoAssociation:
|
| 202 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 203 |
+
Properties:
|
| 204 |
+
RouteTableId: !Ref PrivateRouteTableTwo
|
| 205 |
+
SubnetId: !Ref PrivateSubnetTwo
|
| 206 |
+
|
| 207 |
+
# OPTIONAL: VPC Endpoint for DynamoDB
|
| 208 |
+
# If a container needs to access DynamoDB this allows a container in the private subnet
|
| 209 |
+
# to talk to DynamoDB directly without needing to go via the NAT gateway. This reduces
|
| 210 |
+
# the amount of bandwidth through the gateway, meaning that the gateway is free to serve
|
| 211 |
+
# your other traffic.
|
| 212 |
+
DynamoDBEndpoint:
|
| 213 |
+
Type: AWS::EC2::VPCEndpoint
|
| 214 |
+
Properties:
|
| 215 |
+
PolicyDocument:
|
| 216 |
+
Version: "2012-10-17"
|
| 217 |
+
Statement:
|
| 218 |
+
- Effect: Allow
|
| 219 |
+
Action: '*'
|
| 220 |
+
Principal: '*'
|
| 221 |
+
Resource: '*'
|
| 222 |
+
RouteTableIds:
|
| 223 |
+
- !Ref PrivateRouteTableOne
|
| 224 |
+
- !Ref PrivateRouteTableTwo
|
| 225 |
+
ServiceName: !Join
|
| 226 |
+
- ""
|
| 227 |
+
- - com.amazonaws.
|
| 228 |
+
- !Ref AWS::Region
|
| 229 |
+
- .dynamodb
|
| 230 |
+
VpcId: !Ref VPC
|
| 231 |
+
|
| 232 |
+
# ECS Resources
|
| 233 |
+
ECSCluster:
|
| 234 |
+
Type: AWS::ECS::Cluster
|
| 235 |
+
|
| 236 |
+
# A security group for the containers we will run in Fargate.
|
| 237 |
+
# Three rules, allowing network traffic from a public facing load
|
| 238 |
+
# balancer, a private internal load balancer, and from other members
|
| 239 |
+
# of the security group.
|
| 240 |
+
#
|
| 241 |
+
# Remove any of the following ingress rules that are not needed.
|
| 242 |
+
FargateContainerSecurityGroup:
|
| 243 |
+
Type: AWS::EC2::SecurityGroup
|
| 244 |
+
Properties:
|
| 245 |
+
GroupDescription: Access to the Fargate containers
|
| 246 |
+
VpcId: !Ref VPC
|
| 247 |
+
|
| 248 |
+
EcsSecurityGroupIngressFromPublicALB:
|
| 249 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 250 |
+
Properties:
|
| 251 |
+
Description: Ingress from the public ALB
|
| 252 |
+
GroupId: !Ref FargateContainerSecurityGroup
|
| 253 |
+
IpProtocol: "-1"
|
| 254 |
+
SourceSecurityGroupId: !Ref PublicLoadBalancerSG
|
| 255 |
+
|
| 256 |
+
EcsSecurityGroupIngressFromPrivateALB:
|
| 257 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 258 |
+
Properties:
|
| 259 |
+
Description: Ingress from the private ALB
|
| 260 |
+
GroupId: !Ref FargateContainerSecurityGroup
|
| 261 |
+
IpProtocol: "-1"
|
| 262 |
+
SourceSecurityGroupId: !Ref PrivateLoadBalancerSG
|
| 263 |
+
|
| 264 |
+
EcsSecurityGroupIngressFromSelf:
|
| 265 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 266 |
+
Properties:
|
| 267 |
+
Description: Ingress from other containers in the same security group
|
| 268 |
+
GroupId: !Ref FargateContainerSecurityGroup
|
| 269 |
+
IpProtocol: "-1"
|
| 270 |
+
SourceSecurityGroupId: !Ref FargateContainerSecurityGroup
|
| 271 |
+
|
| 272 |
+
# Load balancers for getting traffic to containers.
|
| 273 |
+
# This sample template creates two load balancers:
|
| 274 |
+
#
|
| 275 |
+
# - One public load balancer, hosted in public subnets that is accessible
|
| 276 |
+
# to the public, and is intended to route traffic to one or more public
|
| 277 |
+
# facing services.
|
| 278 |
+
# - One private load balancer, hosted in private subnets, that only
|
| 279 |
+
# accepts traffic from other containers in the Fargate cluster, and is
|
| 280 |
+
# intended for private services that should not be accessed directly
|
| 281 |
+
# by the public.
|
| 282 |
+
|
| 283 |
+
# A public facing load balancer, this is used for accepting traffic from the public
|
| 284 |
+
# internet and directing it to public facing microservices
|
| 285 |
+
PublicLoadBalancerSG:
|
| 286 |
+
Type: AWS::EC2::SecurityGroup
|
| 287 |
+
Properties:
|
| 288 |
+
GroupDescription: Access to the public facing load balancer
|
| 289 |
+
VpcId: !Ref VPC
|
| 290 |
+
SecurityGroupIngress:
|
| 291 |
+
|
| 292 |
+
# Allow access to ALB from anywhere on the internet
|
| 293 |
+
- CidrIp: 0.0.0.0/0
|
| 294 |
+
IpProtocol: "-1"
|
| 295 |
+
|
| 296 |
+
PublicLoadBalancer:
|
| 297 |
+
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
|
| 298 |
+
DependsOn: GatewayAttachement
|
| 299 |
+
Properties:
|
| 300 |
+
Scheme: internet-facing
|
| 301 |
+
LoadBalancerAttributes:
|
| 302 |
+
- Key: idle_timeout.timeout_seconds
|
| 303 |
+
Value: "30"
|
| 304 |
+
Subnets:
|
| 305 |
+
|
| 306 |
+
# The load balancer is placed into the public subnets, so that traffic
|
| 307 |
+
# from the internet can reach the load balancer directly via the internet gateway
|
| 308 |
+
- !Ref PublicSubnetOne
|
| 309 |
+
- !Ref PublicSubnetTwo
|
| 310 |
+
SecurityGroups:
|
| 311 |
+
- !Ref PublicLoadBalancerSG
|
| 312 |
+
|
| 313 |
+
# A dummy target group is used to setup the ALB to just drop traffic
|
| 314 |
+
# initially, before any real service target groups have been added.
|
| 315 |
+
DummyTargetGroupPublic:
|
| 316 |
+
Type: AWS::ElasticLoadBalancingV2::TargetGroup
|
| 317 |
+
Properties:
|
| 318 |
+
HealthCheckIntervalSeconds: 6
|
| 319 |
+
HealthCheckPath: /
|
| 320 |
+
HealthCheckProtocol: HTTP
|
| 321 |
+
HealthCheckTimeoutSeconds: 5
|
| 322 |
+
HealthyThresholdCount: 2
|
| 323 |
+
Name: !Join
|
| 324 |
+
- '-'
|
| 325 |
+
- - !Ref AWS::StackName
|
| 326 |
+
- drop-1
|
| 327 |
+
Port: 80
|
| 328 |
+
Protocol: HTTP
|
| 329 |
+
UnhealthyThresholdCount: 2
|
| 330 |
+
VpcId: !Ref VPC
|
| 331 |
+
|
| 332 |
+
PublicLoadBalancerListener:
|
| 333 |
+
Type: AWS::ElasticLoadBalancingV2::Listener
|
| 334 |
+
Properties:
|
| 335 |
+
DefaultActions:
|
| 336 |
+
- TargetGroupArn: !Ref DummyTargetGroupPublic
|
| 337 |
+
Type: forward
|
| 338 |
+
LoadBalancerArn: !Ref PublicLoadBalancer
|
| 339 |
+
Port: 80
|
| 340 |
+
Protocol: HTTP
|
| 341 |
+
|
| 342 |
+
# An internal load balancer, this would be used for a service that is not
|
| 343 |
+
# directly accessible to the public, but instead should only receive traffic
|
| 344 |
+
# from your other services.
|
| 345 |
+
PrivateLoadBalancerSG:
|
| 346 |
+
Type: AWS::EC2::SecurityGroup
|
| 347 |
+
Properties:
|
| 348 |
+
GroupDescription: Access to the internal load balancer
|
| 349 |
+
VpcId: !Ref VPC
|
| 350 |
+
|
| 351 |
+
PrivateLoadBalancerIngressFromECS:
|
| 352 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 353 |
+
Properties:
|
| 354 |
+
Description: Only accept traffic from a container in the fargate container security group
|
| 355 |
+
GroupId: !Ref PrivateLoadBalancerSG
|
| 356 |
+
IpProtocol: "-1"
|
| 357 |
+
SourceSecurityGroupId: !Ref FargateContainerSecurityGroup
|
| 358 |
+
|
| 359 |
+
PrivateLoadBalancer:
|
| 360 |
+
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
|
| 361 |
+
Properties:
|
| 362 |
+
Scheme: internal
|
| 363 |
+
LoadBalancerAttributes:
|
| 364 |
+
- Key: idle_timeout.timeout_seconds
|
| 365 |
+
Value: "30"
|
| 366 |
+
Subnets:
|
| 367 |
+
|
| 368 |
+
# This load balancer is put into the private subnet, so that there is no
|
| 369 |
+
# route for the public to even be able to access the private load balancer.
|
| 370 |
+
- !Ref PrivateSubnetOne
|
| 371 |
+
- !Ref PrivateSubnetTwo
|
| 372 |
+
SecurityGroups:
|
| 373 |
+
- !Ref PrivateLoadBalancerSG
|
| 374 |
+
|
| 375 |
+
# This dummy target group is used to setup the ALB to just drop traffic
|
| 376 |
+
# initially, before any real service target groups have been added.
|
| 377 |
+
DummyTargetGroupPrivate:
|
| 378 |
+
Type: AWS::ElasticLoadBalancingV2::TargetGroup
|
| 379 |
+
Properties:
|
| 380 |
+
HealthCheckIntervalSeconds: 6
|
| 381 |
+
HealthCheckPath: /
|
| 382 |
+
HealthCheckProtocol: HTTP
|
| 383 |
+
HealthCheckTimeoutSeconds: 5
|
| 384 |
+
HealthyThresholdCount: 2
|
| 385 |
+
Name: !Join
|
| 386 |
+
- '-'
|
| 387 |
+
- - !Ref AWS::StackName
|
| 388 |
+
- drop-2
|
| 389 |
+
Port: 80
|
| 390 |
+
Protocol: HTTP
|
| 391 |
+
UnhealthyThresholdCount: 2
|
| 392 |
+
VpcId: !Ref VPC
|
| 393 |
+
|
| 394 |
+
PrivateLoadBalancerListener:
|
| 395 |
+
Type: AWS::ElasticLoadBalancingV2::Listener
|
| 396 |
+
Properties:
|
| 397 |
+
DefaultActions:
|
| 398 |
+
- TargetGroupArn: !Ref DummyTargetGroupPrivate
|
| 399 |
+
Type: forward
|
| 400 |
+
LoadBalancerArn: !Ref PrivateLoadBalancer
|
| 401 |
+
Port: 80
|
| 402 |
+
Protocol: HTTP
|
| 403 |
+
|
| 404 |
+
# This is an IAM role which authorizes ECS to manage resources on your
|
| 405 |
+
# account on your behalf, such as updating your load balancer with the
|
| 406 |
+
# details of where your containers are, so that traffic can reach your
|
| 407 |
+
# containers.
|
| 408 |
+
ECSRole:
|
| 409 |
+
Type: AWS::IAM::Role
|
| 410 |
+
Properties:
|
| 411 |
+
AssumeRolePolicyDocument:
|
| 412 |
+
Statement:
|
| 413 |
+
- Effect: Allow
|
| 414 |
+
Principal:
|
| 415 |
+
Service:
|
| 416 |
+
- ecs.amazonaws.com
|
| 417 |
+
Action:
|
| 418 |
+
- sts:AssumeRole
|
| 419 |
+
Path: /
|
| 420 |
+
Policies:
|
| 421 |
+
- PolicyName: ecs-service
|
| 422 |
+
PolicyDocument:
|
| 423 |
+
Statement:
|
| 424 |
+
- Effect: Allow
|
| 425 |
+
Action:
|
| 426 |
+
|
| 427 |
+
# Rules which allow ECS to attach network interfaces to instances
|
| 428 |
+
# on your behalf in order for awsvpc networking mode to work right
|
| 429 |
+
- ec2:AttachNetworkInterface
|
| 430 |
+
- ec2:CreateNetworkInterface
|
| 431 |
+
- ec2:CreateNetworkInterfacePermission
|
| 432 |
+
- ec2:DeleteNetworkInterface
|
| 433 |
+
- ec2:DeleteNetworkInterfacePermission
|
| 434 |
+
- ec2:Describe*
|
| 435 |
+
- ec2:DetachNetworkInterface
|
| 436 |
+
|
| 437 |
+
# Rules which allow ECS to update load balancers on your behalf
|
| 438 |
+
# with the information sabout how to send traffic to your containers
|
| 439 |
+
- elasticloadbalancing:DeregisterInstancesFromLoadBalancer
|
| 440 |
+
- elasticloadbalancing:DeregisterTargets
|
| 441 |
+
- elasticloadbalancing:Describe*
|
| 442 |
+
- elasticloadbalancing:RegisterInstancesWithLoadBalancer
|
| 443 |
+
- elasticloadbalancing:RegisterTargets
|
| 444 |
+
Resource: '*'
|
| 445 |
+
|
| 446 |
+
# This is a role which is used by the ECS tasks themselves.
|
| 447 |
+
ECSTaskExecutionRole:
|
| 448 |
+
Type: AWS::IAM::Role
|
| 449 |
+
Properties:
|
| 450 |
+
AssumeRolePolicyDocument:
|
| 451 |
+
Statement:
|
| 452 |
+
- Effect: Allow
|
| 453 |
+
Principal:
|
| 454 |
+
Service:
|
| 455 |
+
- ecs-tasks.amazonaws.com
|
| 456 |
+
Action:
|
| 457 |
+
- sts:AssumeRole
|
| 458 |
+
Path: /
|
| 459 |
+
Policies:
|
| 460 |
+
- PolicyName: AmazonECSTaskExecutionRolePolicy
|
| 461 |
+
PolicyDocument:
|
| 462 |
+
Statement:
|
| 463 |
+
- Effect: Allow
|
| 464 |
+
Action:
|
| 465 |
+
|
| 466 |
+
# Allow the ECS Tasks to download images from ECR
|
| 467 |
+
- ecr:GetAuthorizationToken
|
| 468 |
+
- ecr:BatchCheckLayerAvailability
|
| 469 |
+
- ecr:GetDownloadUrlForLayer
|
| 470 |
+
- ecr:BatchGetImage
|
| 471 |
+
|
| 472 |
+
# Allow the ECS tasks to upload logs to CloudWatch
|
| 473 |
+
- logs:CreateLogStream
|
| 474 |
+
- logs:PutLogEvents
|
| 475 |
+
Resource: '*'
|
| 476 |
+
|
| 477 |
+
# These are the values output by the CloudFormation template. Be careful
|
| 478 |
+
# about changing any of them, because of them are exported with specific
|
| 479 |
+
# names so that the other task related CF templates can use them.
|
| 480 |
+
Outputs:
|
| 481 |
+
ClusterName:
|
| 482 |
+
Description: The name of the ECS cluster
|
| 483 |
+
Value: !Ref ECSCluster
|
| 484 |
+
Export:
|
| 485 |
+
Name: !Join
|
| 486 |
+
- ':'
|
| 487 |
+
- - !Ref AWS::StackName
|
| 488 |
+
- ClusterName
|
| 489 |
+
|
| 490 |
+
InternalUrl:
|
| 491 |
+
Description: The url of the internal load balancer
|
| 492 |
+
Value: !Join
|
| 493 |
+
- ""
|
| 494 |
+
- - http://
|
| 495 |
+
- !GetAtt PrivateLoadBalancer.DNSName
|
| 496 |
+
Export:
|
| 497 |
+
Name: !Join
|
| 498 |
+
- ':'
|
| 499 |
+
- - !Ref AWS::StackName
|
| 500 |
+
- InternalUrl
|
| 501 |
+
|
| 502 |
+
ExternalUrl:
|
| 503 |
+
Description: The url of the external load balancer
|
| 504 |
+
Value: !Join
|
| 505 |
+
- ""
|
| 506 |
+
- - http://
|
| 507 |
+
- !GetAtt PublicLoadBalancer.DNSName
|
| 508 |
+
Export:
|
| 509 |
+
Name: !Join
|
| 510 |
+
- ':'
|
| 511 |
+
- - !Ref AWS::StackName
|
| 512 |
+
- ExternalUrl
|
| 513 |
+
|
| 514 |
+
ECSRole:
|
| 515 |
+
Description: The ARN of the ECS role
|
| 516 |
+
Value: !GetAtt ECSRole.Arn
|
| 517 |
+
Export:
|
| 518 |
+
Name: !Join
|
| 519 |
+
- ':'
|
| 520 |
+
- - !Ref AWS::StackName
|
| 521 |
+
- ECSRole
|
| 522 |
+
|
| 523 |
+
ECSTaskExecutionRole:
|
| 524 |
+
Description: The ARN of the ECS role
|
| 525 |
+
Value: !GetAtt ECSTaskExecutionRole.Arn
|
| 526 |
+
Export:
|
| 527 |
+
Name: !Join
|
| 528 |
+
- ':'
|
| 529 |
+
- - !Ref AWS::StackName
|
| 530 |
+
- ECSTaskExecutionRole
|
| 531 |
+
|
| 532 |
+
PublicListener:
|
| 533 |
+
Description: The ARN of the public load balancer's Listener
|
| 534 |
+
Value: !Ref PublicLoadBalancerListener
|
| 535 |
+
Export:
|
| 536 |
+
Name: !Join
|
| 537 |
+
- ':'
|
| 538 |
+
- - !Ref AWS::StackName
|
| 539 |
+
- PublicListener
|
| 540 |
+
|
| 541 |
+
PrivateListener:
|
| 542 |
+
Description: The ARN of the private load balancer's Listener
|
| 543 |
+
Value: !Ref PrivateLoadBalancerListener
|
| 544 |
+
Export:
|
| 545 |
+
Name: !Join
|
| 546 |
+
- ':'
|
| 547 |
+
- - !Ref AWS::StackName
|
| 548 |
+
- PrivateListener
|
| 549 |
+
|
| 550 |
+
VPCId:
|
| 551 |
+
Description: The ID of the VPC that this stack is deployed in
|
| 552 |
+
Value: !Ref VPC
|
| 553 |
+
Export:
|
| 554 |
+
Name: !Join
|
| 555 |
+
- ':'
|
| 556 |
+
- - !Ref AWS::StackName
|
| 557 |
+
- VPCId
|
| 558 |
+
|
| 559 |
+
PublicSubnetOne:
|
| 560 |
+
Description: Public subnet one
|
| 561 |
+
Value: !Ref PublicSubnetOne
|
| 562 |
+
Export:
|
| 563 |
+
Name: !Join
|
| 564 |
+
- ':'
|
| 565 |
+
- - !Ref AWS::StackName
|
| 566 |
+
- PublicSubnetOne
|
| 567 |
+
|
| 568 |
+
PublicSubnetTwo:
|
| 569 |
+
Description: Public subnet two
|
| 570 |
+
Value: !Ref PublicSubnetTwo
|
| 571 |
+
Export:
|
| 572 |
+
Name: !Join
|
| 573 |
+
- ':'
|
| 574 |
+
- - !Ref AWS::StackName
|
| 575 |
+
- PublicSubnetTwo
|
| 576 |
+
|
| 577 |
+
PrivateSubnetOne:
|
| 578 |
+
Description: Private subnet one
|
| 579 |
+
Value: !Ref PrivateSubnetOne
|
| 580 |
+
Export:
|
| 581 |
+
Name: !Join
|
| 582 |
+
- ':'
|
| 583 |
+
- - !Ref AWS::StackName
|
| 584 |
+
- PrivateSubnetOne
|
| 585 |
+
|
| 586 |
+
PrivateSubnetTwo:
|
| 587 |
+
Description: Private subnet two
|
| 588 |
+
Value: !Ref PrivateSubnetTwo
|
| 589 |
+
Export:
|
| 590 |
+
Name: !Join
|
| 591 |
+
- ':'
|
| 592 |
+
- - !Ref AWS::StackName
|
| 593 |
+
- PrivateSubnetTwo
|
| 594 |
+
|
| 595 |
+
FargateContainerSecurityGroup:
|
| 596 |
+
Description: A security group used to allow Fargate containers to receive traffic
|
| 597 |
+
Value: !Ref FargateContainerSecurityGroup
|
| 598 |
+
Export:
|
| 599 |
+
Name: !Join
|
| 600 |
+
- ':'
|
| 601 |
+
- - !Ref AWS::StackName
|
| 602 |
+
- FargateContainerSecurityGroup
|
human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/clusters/public-vpc.json
ADDED
|
@@ -0,0 +1,545 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "A stack for deploying containerized applications in AWS Fargate. This stack runs containers in a public VPC subnet, and includes a public facing load balancer to register the services in.",
|
| 4 |
+
"Mappings": {
|
| 5 |
+
"SubnetConfig": {
|
| 6 |
+
"VPC": {
|
| 7 |
+
"CIDR": "10.0.0.0/16"
|
| 8 |
+
},
|
| 9 |
+
"PublicOne": {
|
| 10 |
+
"CIDR": "10.0.0.0/24"
|
| 11 |
+
},
|
| 12 |
+
"PublicTwo": {
|
| 13 |
+
"CIDR": "10.0.1.0/24"
|
| 14 |
+
}
|
| 15 |
+
}
|
| 16 |
+
},
|
| 17 |
+
"Resources": {
|
| 18 |
+
"VPC": {
|
| 19 |
+
"Type": "AWS::EC2::VPC",
|
| 20 |
+
"Properties": {
|
| 21 |
+
"EnableDnsSupport": true,
|
| 22 |
+
"EnableDnsHostnames": true,
|
| 23 |
+
"CidrBlock": {
|
| 24 |
+
"Fn::FindInMap": [
|
| 25 |
+
"SubnetConfig",
|
| 26 |
+
"VPC",
|
| 27 |
+
"CIDR"
|
| 28 |
+
]
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
},
|
| 32 |
+
"PublicSubnetOne": {
|
| 33 |
+
"Type": "AWS::EC2::Subnet",
|
| 34 |
+
"Properties": {
|
| 35 |
+
"AvailabilityZone": {
|
| 36 |
+
"Fn::Select": [
|
| 37 |
+
0,
|
| 38 |
+
{
|
| 39 |
+
"Fn::GetAZs": {
|
| 40 |
+
"Ref": "AWS::Region"
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
]
|
| 44 |
+
},
|
| 45 |
+
"VpcId": {
|
| 46 |
+
"Ref": "VPC"
|
| 47 |
+
},
|
| 48 |
+
"CidrBlock": {
|
| 49 |
+
"Fn::FindInMap": [
|
| 50 |
+
"SubnetConfig",
|
| 51 |
+
"PublicOne",
|
| 52 |
+
"CIDR"
|
| 53 |
+
]
|
| 54 |
+
},
|
| 55 |
+
"MapPublicIpOnLaunch": true
|
| 56 |
+
}
|
| 57 |
+
},
|
| 58 |
+
"PublicSubnetTwo": {
|
| 59 |
+
"Type": "AWS::EC2::Subnet",
|
| 60 |
+
"Properties": {
|
| 61 |
+
"AvailabilityZone": {
|
| 62 |
+
"Fn::Select": [
|
| 63 |
+
1,
|
| 64 |
+
{
|
| 65 |
+
"Fn::GetAZs": {
|
| 66 |
+
"Ref": "AWS::Region"
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
]
|
| 70 |
+
},
|
| 71 |
+
"VpcId": {
|
| 72 |
+
"Ref": "VPC"
|
| 73 |
+
},
|
| 74 |
+
"CidrBlock": {
|
| 75 |
+
"Fn::FindInMap": [
|
| 76 |
+
"SubnetConfig",
|
| 77 |
+
"PublicTwo",
|
| 78 |
+
"CIDR"
|
| 79 |
+
]
|
| 80 |
+
},
|
| 81 |
+
"MapPublicIpOnLaunch": true
|
| 82 |
+
}
|
| 83 |
+
},
|
| 84 |
+
"InternetGateway": {
|
| 85 |
+
"Type": "AWS::EC2::InternetGateway"
|
| 86 |
+
},
|
| 87 |
+
"GatewayAttachement": {
|
| 88 |
+
"Type": "AWS::EC2::VPCGatewayAttachment",
|
| 89 |
+
"Properties": {
|
| 90 |
+
"VpcId": {
|
| 91 |
+
"Ref": "VPC"
|
| 92 |
+
},
|
| 93 |
+
"InternetGatewayId": {
|
| 94 |
+
"Ref": "InternetGateway"
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
},
|
| 98 |
+
"PublicRouteTable": {
|
| 99 |
+
"Type": "AWS::EC2::RouteTable",
|
| 100 |
+
"Properties": {
|
| 101 |
+
"VpcId": {
|
| 102 |
+
"Ref": "VPC"
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
},
|
| 106 |
+
"PublicRoute": {
|
| 107 |
+
"Type": "AWS::EC2::Route",
|
| 108 |
+
"DependsOn": "GatewayAttachement",
|
| 109 |
+
"Properties": {
|
| 110 |
+
"RouteTableId": {
|
| 111 |
+
"Ref": "PublicRouteTable"
|
| 112 |
+
},
|
| 113 |
+
"DestinationCidrBlock": "0.0.0.0/0",
|
| 114 |
+
"GatewayId": {
|
| 115 |
+
"Ref": "InternetGateway"
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
},
|
| 119 |
+
"PublicSubnetOneRouteTableAssociation": {
|
| 120 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 121 |
+
"Properties": {
|
| 122 |
+
"SubnetId": {
|
| 123 |
+
"Ref": "PublicSubnetOne"
|
| 124 |
+
},
|
| 125 |
+
"RouteTableId": {
|
| 126 |
+
"Ref": "PublicRouteTable"
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
},
|
| 130 |
+
"PublicSubnetTwoRouteTableAssociation": {
|
| 131 |
+
"Type": "AWS::EC2::SubnetRouteTableAssociation",
|
| 132 |
+
"Properties": {
|
| 133 |
+
"SubnetId": {
|
| 134 |
+
"Ref": "PublicSubnetTwo"
|
| 135 |
+
},
|
| 136 |
+
"RouteTableId": {
|
| 137 |
+
"Ref": "PublicRouteTable"
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
},
|
| 141 |
+
"ECSCluster": {
|
| 142 |
+
"Type": "AWS::ECS::Cluster"
|
| 143 |
+
},
|
| 144 |
+
"FargateContainerSecurityGroup": {
|
| 145 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 146 |
+
"Properties": {
|
| 147 |
+
"GroupDescription": "Access to the Fargate containers",
|
| 148 |
+
"VpcId": {
|
| 149 |
+
"Ref": "VPC"
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
+
},
|
| 153 |
+
"EcsSecurityGroupIngressFromPublicALB": {
|
| 154 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 155 |
+
"Properties": {
|
| 156 |
+
"Description": "Ingress from the public ALB",
|
| 157 |
+
"GroupId": {
|
| 158 |
+
"Ref": "FargateContainerSecurityGroup"
|
| 159 |
+
},
|
| 160 |
+
"IpProtocol": "-1",
|
| 161 |
+
"SourceSecurityGroupId": {
|
| 162 |
+
"Ref": "PublicLoadBalancerSG"
|
| 163 |
+
}
|
| 164 |
+
}
|
| 165 |
+
},
|
| 166 |
+
"EcsSecurityGroupIngressFromSelf": {
|
| 167 |
+
"Type": "AWS::EC2::SecurityGroupIngress",
|
| 168 |
+
"Properties": {
|
| 169 |
+
"Description": "Ingress from other containers in the same security group",
|
| 170 |
+
"GroupId": {
|
| 171 |
+
"Ref": "FargateContainerSecurityGroup"
|
| 172 |
+
},
|
| 173 |
+
"IpProtocol": "-1",
|
| 174 |
+
"SourceSecurityGroupId": {
|
| 175 |
+
"Ref": "FargateContainerSecurityGroup"
|
| 176 |
+
}
|
| 177 |
+
}
|
| 178 |
+
},
|
| 179 |
+
"PublicLoadBalancerSG": {
|
| 180 |
+
"Type": "AWS::EC2::SecurityGroup",
|
| 181 |
+
"Properties": {
|
| 182 |
+
"GroupDescription": "Access to the public facing load balancer",
|
| 183 |
+
"VpcId": {
|
| 184 |
+
"Ref": "VPC"
|
| 185 |
+
},
|
| 186 |
+
"SecurityGroupIngress": [
|
| 187 |
+
{
|
| 188 |
+
"CidrIp": "0.0.0.0/0",
|
| 189 |
+
"IpProtocol": "-1"
|
| 190 |
+
}
|
| 191 |
+
]
|
| 192 |
+
}
|
| 193 |
+
},
|
| 194 |
+
"PublicLoadBalancer": {
|
| 195 |
+
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
|
| 196 |
+
"Properties": {
|
| 197 |
+
"Scheme": "internet-facing",
|
| 198 |
+
"LoadBalancerAttributes": [
|
| 199 |
+
{
|
| 200 |
+
"Key": "idle_timeout.timeout_seconds",
|
| 201 |
+
"Value": "30"
|
| 202 |
+
}
|
| 203 |
+
],
|
| 204 |
+
"Subnets": [
|
| 205 |
+
{
|
| 206 |
+
"Ref": "PublicSubnetOne"
|
| 207 |
+
},
|
| 208 |
+
{
|
| 209 |
+
"Ref": "PublicSubnetTwo"
|
| 210 |
+
}
|
| 211 |
+
],
|
| 212 |
+
"SecurityGroups": [
|
| 213 |
+
{
|
| 214 |
+
"Ref": "PublicLoadBalancerSG"
|
| 215 |
+
}
|
| 216 |
+
]
|
| 217 |
+
}
|
| 218 |
+
},
|
| 219 |
+
"DummyTargetGroupPublic": {
|
| 220 |
+
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
|
| 221 |
+
"Properties": {
|
| 222 |
+
"HealthCheckIntervalSeconds": 6,
|
| 223 |
+
"HealthCheckPath": "/",
|
| 224 |
+
"HealthCheckProtocol": "HTTP",
|
| 225 |
+
"HealthCheckTimeoutSeconds": 5,
|
| 226 |
+
"HealthyThresholdCount": 2,
|
| 227 |
+
"Name": {
|
| 228 |
+
"Fn::Join": [
|
| 229 |
+
"-",
|
| 230 |
+
[
|
| 231 |
+
{
|
| 232 |
+
"Ref": "AWS::StackName"
|
| 233 |
+
},
|
| 234 |
+
"drop-1"
|
| 235 |
+
]
|
| 236 |
+
]
|
| 237 |
+
},
|
| 238 |
+
"Port": 80,
|
| 239 |
+
"Protocol": "HTTP",
|
| 240 |
+
"UnhealthyThresholdCount": 2,
|
| 241 |
+
"VpcId": {
|
| 242 |
+
"Ref": "VPC"
|
| 243 |
+
}
|
| 244 |
+
}
|
| 245 |
+
},
|
| 246 |
+
"PublicLoadBalancerListener": {
|
| 247 |
+
"Type": "AWS::ElasticLoadBalancingV2::Listener",
|
| 248 |
+
"Properties": {
|
| 249 |
+
"DefaultActions": [
|
| 250 |
+
{
|
| 251 |
+
"TargetGroupArn": {
|
| 252 |
+
"Ref": "DummyTargetGroupPublic"
|
| 253 |
+
},
|
| 254 |
+
"Type": "forward"
|
| 255 |
+
}
|
| 256 |
+
],
|
| 257 |
+
"LoadBalancerArn": {
|
| 258 |
+
"Ref": "PublicLoadBalancer"
|
| 259 |
+
},
|
| 260 |
+
"Port": 80,
|
| 261 |
+
"Protocol": "HTTP"
|
| 262 |
+
}
|
| 263 |
+
},
|
| 264 |
+
"ECSRole": {
|
| 265 |
+
"Type": "AWS::IAM::Role",
|
| 266 |
+
"Properties": {
|
| 267 |
+
"AssumeRolePolicyDocument": {
|
| 268 |
+
"Statement": [
|
| 269 |
+
{
|
| 270 |
+
"Effect": "Allow",
|
| 271 |
+
"Principal": {
|
| 272 |
+
"Service": [
|
| 273 |
+
"ecs.amazonaws.com"
|
| 274 |
+
]
|
| 275 |
+
},
|
| 276 |
+
"Action": [
|
| 277 |
+
"sts:AssumeRole"
|
| 278 |
+
]
|
| 279 |
+
}
|
| 280 |
+
]
|
| 281 |
+
},
|
| 282 |
+
"Path": "/",
|
| 283 |
+
"Policies": [
|
| 284 |
+
{
|
| 285 |
+
"PolicyName": "ecs-service",
|
| 286 |
+
"PolicyDocument": {
|
| 287 |
+
"Statement": [
|
| 288 |
+
{
|
| 289 |
+
"Effect": "Allow",
|
| 290 |
+
"Action": [
|
| 291 |
+
"ec2:AttachNetworkInterface",
|
| 292 |
+
"ec2:CreateNetworkInterface",
|
| 293 |
+
"ec2:CreateNetworkInterfacePermission",
|
| 294 |
+
"ec2:DeleteNetworkInterface",
|
| 295 |
+
"ec2:DeleteNetworkInterfacePermission",
|
| 296 |
+
"ec2:Describe*",
|
| 297 |
+
"ec2:DetachNetworkInterface",
|
| 298 |
+
"elasticloadbalancing:DeregisterInstancesFromLoadBalancer",
|
| 299 |
+
"elasticloadbalancing:DeregisterTargets",
|
| 300 |
+
"elasticloadbalancing:Describe*",
|
| 301 |
+
"elasticloadbalancing:RegisterInstancesWithLoadBalancer",
|
| 302 |
+
"elasticloadbalancing:RegisterTargets"
|
| 303 |
+
],
|
| 304 |
+
"Resource": "*"
|
| 305 |
+
}
|
| 306 |
+
]
|
| 307 |
+
}
|
| 308 |
+
}
|
| 309 |
+
]
|
| 310 |
+
}
|
| 311 |
+
},
|
| 312 |
+
"ECSTaskExecutionRole": {
|
| 313 |
+
"Type": "AWS::IAM::Role",
|
| 314 |
+
"Properties": {
|
| 315 |
+
"AssumeRolePolicyDocument": {
|
| 316 |
+
"Statement": [
|
| 317 |
+
{
|
| 318 |
+
"Effect": "Allow",
|
| 319 |
+
"Principal": {
|
| 320 |
+
"Service": [
|
| 321 |
+
"ecs-tasks.amazonaws.com"
|
| 322 |
+
]
|
| 323 |
+
},
|
| 324 |
+
"Action": [
|
| 325 |
+
"sts:AssumeRole"
|
| 326 |
+
]
|
| 327 |
+
}
|
| 328 |
+
]
|
| 329 |
+
},
|
| 330 |
+
"Path": "/",
|
| 331 |
+
"Policies": [
|
| 332 |
+
{
|
| 333 |
+
"PolicyName": "AmazonECSTaskExecutionRolePolicy",
|
| 334 |
+
"PolicyDocument": {
|
| 335 |
+
"Statement": [
|
| 336 |
+
{
|
| 337 |
+
"Effect": "Allow",
|
| 338 |
+
"Action": [
|
| 339 |
+
"ecr:GetAuthorizationToken",
|
| 340 |
+
"ecr:BatchCheckLayerAvailability",
|
| 341 |
+
"ecr:GetDownloadUrlForLayer",
|
| 342 |
+
"ecr:BatchGetImage",
|
| 343 |
+
"logs:CreateLogStream",
|
| 344 |
+
"logs:PutLogEvents"
|
| 345 |
+
],
|
| 346 |
+
"Resource": "*"
|
| 347 |
+
}
|
| 348 |
+
]
|
| 349 |
+
}
|
| 350 |
+
}
|
| 351 |
+
]
|
| 352 |
+
}
|
| 353 |
+
}
|
| 354 |
+
},
|
| 355 |
+
"Outputs": {
|
| 356 |
+
"ClusterName": {
|
| 357 |
+
"Description": "The name of the ECS cluster",
|
| 358 |
+
"Value": {
|
| 359 |
+
"Ref": "ECSCluster"
|
| 360 |
+
},
|
| 361 |
+
"Export": {
|
| 362 |
+
"Name": {
|
| 363 |
+
"Fn::Join": [
|
| 364 |
+
":",
|
| 365 |
+
[
|
| 366 |
+
{
|
| 367 |
+
"Ref": "AWS::StackName"
|
| 368 |
+
},
|
| 369 |
+
"ClusterName"
|
| 370 |
+
]
|
| 371 |
+
]
|
| 372 |
+
}
|
| 373 |
+
}
|
| 374 |
+
},
|
| 375 |
+
"ExternalUrl": {
|
| 376 |
+
"Description": "The url of the external load balancer",
|
| 377 |
+
"Value": {
|
| 378 |
+
"Fn::Join": [
|
| 379 |
+
"",
|
| 380 |
+
[
|
| 381 |
+
"http://",
|
| 382 |
+
{
|
| 383 |
+
"Fn::GetAtt": [
|
| 384 |
+
"PublicLoadBalancer",
|
| 385 |
+
"DNSName"
|
| 386 |
+
]
|
| 387 |
+
}
|
| 388 |
+
]
|
| 389 |
+
]
|
| 390 |
+
},
|
| 391 |
+
"Export": {
|
| 392 |
+
"Name": {
|
| 393 |
+
"Fn::Join": [
|
| 394 |
+
":",
|
| 395 |
+
[
|
| 396 |
+
{
|
| 397 |
+
"Ref": "AWS::StackName"
|
| 398 |
+
},
|
| 399 |
+
"ExternalUrl"
|
| 400 |
+
]
|
| 401 |
+
]
|
| 402 |
+
}
|
| 403 |
+
}
|
| 404 |
+
},
|
| 405 |
+
"ECSRole": {
|
| 406 |
+
"Description": "The ARN of the ECS role",
|
| 407 |
+
"Value": {
|
| 408 |
+
"Fn::GetAtt": [
|
| 409 |
+
"ECSRole",
|
| 410 |
+
"Arn"
|
| 411 |
+
]
|
| 412 |
+
},
|
| 413 |
+
"Export": {
|
| 414 |
+
"Name": {
|
| 415 |
+
"Fn::Join": [
|
| 416 |
+
":",
|
| 417 |
+
[
|
| 418 |
+
{
|
| 419 |
+
"Ref": "AWS::StackName"
|
| 420 |
+
},
|
| 421 |
+
"ECSRole"
|
| 422 |
+
]
|
| 423 |
+
]
|
| 424 |
+
}
|
| 425 |
+
}
|
| 426 |
+
},
|
| 427 |
+
"ECSTaskExecutionRole": {
|
| 428 |
+
"Description": "The ARN of the ECS role",
|
| 429 |
+
"Value": {
|
| 430 |
+
"Fn::GetAtt": [
|
| 431 |
+
"ECSTaskExecutionRole",
|
| 432 |
+
"Arn"
|
| 433 |
+
]
|
| 434 |
+
},
|
| 435 |
+
"Export": {
|
| 436 |
+
"Name": {
|
| 437 |
+
"Fn::Join": [
|
| 438 |
+
":",
|
| 439 |
+
[
|
| 440 |
+
{
|
| 441 |
+
"Ref": "AWS::StackName"
|
| 442 |
+
},
|
| 443 |
+
"ECSTaskExecutionRole"
|
| 444 |
+
]
|
| 445 |
+
]
|
| 446 |
+
}
|
| 447 |
+
}
|
| 448 |
+
},
|
| 449 |
+
"PublicListener": {
|
| 450 |
+
"Description": "The ARN of the public load balancer's Listener",
|
| 451 |
+
"Value": {
|
| 452 |
+
"Ref": "PublicLoadBalancerListener"
|
| 453 |
+
},
|
| 454 |
+
"Export": {
|
| 455 |
+
"Name": {
|
| 456 |
+
"Fn::Join": [
|
| 457 |
+
":",
|
| 458 |
+
[
|
| 459 |
+
{
|
| 460 |
+
"Ref": "AWS::StackName"
|
| 461 |
+
},
|
| 462 |
+
"PublicListener"
|
| 463 |
+
]
|
| 464 |
+
]
|
| 465 |
+
}
|
| 466 |
+
}
|
| 467 |
+
},
|
| 468 |
+
"VPCId": {
|
| 469 |
+
"Description": "The ID of the VPC that this stack is deployed in",
|
| 470 |
+
"Value": {
|
| 471 |
+
"Ref": "VPC"
|
| 472 |
+
},
|
| 473 |
+
"Export": {
|
| 474 |
+
"Name": {
|
| 475 |
+
"Fn::Join": [
|
| 476 |
+
":",
|
| 477 |
+
[
|
| 478 |
+
{
|
| 479 |
+
"Ref": "AWS::StackName"
|
| 480 |
+
},
|
| 481 |
+
"VPCId"
|
| 482 |
+
]
|
| 483 |
+
]
|
| 484 |
+
}
|
| 485 |
+
}
|
| 486 |
+
},
|
| 487 |
+
"PublicSubnetOne": {
|
| 488 |
+
"Description": "Public subnet one",
|
| 489 |
+
"Value": {
|
| 490 |
+
"Ref": "PublicSubnetOne"
|
| 491 |
+
},
|
| 492 |
+
"Export": {
|
| 493 |
+
"Name": {
|
| 494 |
+
"Fn::Join": [
|
| 495 |
+
":",
|
| 496 |
+
[
|
| 497 |
+
{
|
| 498 |
+
"Ref": "AWS::StackName"
|
| 499 |
+
},
|
| 500 |
+
"PublicSubnetOne"
|
| 501 |
+
]
|
| 502 |
+
]
|
| 503 |
+
}
|
| 504 |
+
}
|
| 505 |
+
},
|
| 506 |
+
"PublicSubnetTwo": {
|
| 507 |
+
"Description": "Public subnet two",
|
| 508 |
+
"Value": {
|
| 509 |
+
"Ref": "PublicSubnetTwo"
|
| 510 |
+
},
|
| 511 |
+
"Export": {
|
| 512 |
+
"Name": {
|
| 513 |
+
"Fn::Join": [
|
| 514 |
+
":",
|
| 515 |
+
[
|
| 516 |
+
{
|
| 517 |
+
"Ref": "AWS::StackName"
|
| 518 |
+
},
|
| 519 |
+
"PublicSubnetTwo"
|
| 520 |
+
]
|
| 521 |
+
]
|
| 522 |
+
}
|
| 523 |
+
}
|
| 524 |
+
},
|
| 525 |
+
"FargateContainerSecurityGroup": {
|
| 526 |
+
"Description": "A security group used to allow Fargate containers to receive traffic",
|
| 527 |
+
"Value": {
|
| 528 |
+
"Ref": "FargateContainerSecurityGroup"
|
| 529 |
+
},
|
| 530 |
+
"Export": {
|
| 531 |
+
"Name": {
|
| 532 |
+
"Fn::Join": [
|
| 533 |
+
":",
|
| 534 |
+
[
|
| 535 |
+
{
|
| 536 |
+
"Ref": "AWS::StackName"
|
| 537 |
+
},
|
| 538 |
+
"FargateContainerSecurityGroup"
|
| 539 |
+
]
|
| 540 |
+
]
|
| 541 |
+
}
|
| 542 |
+
}
|
| 543 |
+
}
|
| 544 |
+
}
|
| 545 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/clusters/public-vpc.yaml
ADDED
|
@@ -0,0 +1,366 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: A stack for deploying containerized applications in AWS Fargate. This stack runs containers in a public VPC subnet, and includes a public facing load balancer to register the services in.
|
| 4 |
+
|
| 5 |
+
Mappings:
|
| 6 |
+
|
| 7 |
+
# Hard values for the subnet masks. These masks define
|
| 8 |
+
# the range of internal IP addresses that can be assigned.
|
| 9 |
+
# The VPC can have all IP's from 10.0.0.0 to 10.0.255.255
|
| 10 |
+
# There are two subnets which cover the ranges:
|
| 11 |
+
#
|
| 12 |
+
# 10.0.0.0 - 10.0.0.255
|
| 13 |
+
# 10.0.1.0 - 10.0.1.255
|
| 14 |
+
#
|
| 15 |
+
# If you need more IP addresses (perhaps you have so many
|
| 16 |
+
# instances that you run out) then you can customize these
|
| 17 |
+
# ranges to add more
|
| 18 |
+
SubnetConfig:
|
| 19 |
+
VPC:
|
| 20 |
+
CIDR: 10.0.0.0/16
|
| 21 |
+
PublicOne:
|
| 22 |
+
CIDR: 10.0.0.0/24
|
| 23 |
+
PublicTwo:
|
| 24 |
+
CIDR: 10.0.1.0/24
|
| 25 |
+
|
| 26 |
+
Resources:
|
| 27 |
+
|
| 28 |
+
# VPC in which containers will be networked.
|
| 29 |
+
# It has two public subnets
|
| 30 |
+
# We distribute the subnets across the first two available subnets
|
| 31 |
+
# for the region, for high availability.
|
| 32 |
+
VPC:
|
| 33 |
+
Type: AWS::EC2::VPC
|
| 34 |
+
Properties:
|
| 35 |
+
EnableDnsSupport: true
|
| 36 |
+
EnableDnsHostnames: true
|
| 37 |
+
CidrBlock: !FindInMap
|
| 38 |
+
- SubnetConfig
|
| 39 |
+
- VPC
|
| 40 |
+
- CIDR
|
| 41 |
+
|
| 42 |
+
# Two public subnets, where containers can have public IP addresses
|
| 43 |
+
PublicSubnetOne:
|
| 44 |
+
Type: AWS::EC2::Subnet
|
| 45 |
+
Properties:
|
| 46 |
+
AvailabilityZone: !Select
|
| 47 |
+
- 0
|
| 48 |
+
- !GetAZs
|
| 49 |
+
Ref: AWS::Region
|
| 50 |
+
VpcId: !Ref VPC
|
| 51 |
+
CidrBlock: !FindInMap
|
| 52 |
+
- SubnetConfig
|
| 53 |
+
- PublicOne
|
| 54 |
+
- CIDR
|
| 55 |
+
MapPublicIpOnLaunch: true
|
| 56 |
+
|
| 57 |
+
PublicSubnetTwo:
|
| 58 |
+
Type: AWS::EC2::Subnet
|
| 59 |
+
Properties:
|
| 60 |
+
AvailabilityZone: !Select
|
| 61 |
+
- 1
|
| 62 |
+
- !GetAZs
|
| 63 |
+
Ref: AWS::Region
|
| 64 |
+
VpcId: !Ref VPC
|
| 65 |
+
CidrBlock: !FindInMap
|
| 66 |
+
- SubnetConfig
|
| 67 |
+
- PublicTwo
|
| 68 |
+
- CIDR
|
| 69 |
+
MapPublicIpOnLaunch: true
|
| 70 |
+
|
| 71 |
+
# Setup networking resources for the public subnets. Containers
|
| 72 |
+
# in the public subnets have public IP addresses and the routing table
|
| 73 |
+
# sends network traffic via the internet gateway.
|
| 74 |
+
InternetGateway:
|
| 75 |
+
Type: AWS::EC2::InternetGateway
|
| 76 |
+
|
| 77 |
+
GatewayAttachement:
|
| 78 |
+
Type: AWS::EC2::VPCGatewayAttachment
|
| 79 |
+
Properties:
|
| 80 |
+
VpcId: !Ref VPC
|
| 81 |
+
InternetGatewayId: !Ref InternetGateway
|
| 82 |
+
|
| 83 |
+
PublicRouteTable:
|
| 84 |
+
Type: AWS::EC2::RouteTable
|
| 85 |
+
Properties:
|
| 86 |
+
VpcId: !Ref VPC
|
| 87 |
+
|
| 88 |
+
PublicRoute:
|
| 89 |
+
Type: AWS::EC2::Route
|
| 90 |
+
DependsOn: GatewayAttachement
|
| 91 |
+
Properties:
|
| 92 |
+
RouteTableId: !Ref PublicRouteTable
|
| 93 |
+
DestinationCidrBlock: 0.0.0.0/0
|
| 94 |
+
GatewayId: !Ref InternetGateway
|
| 95 |
+
|
| 96 |
+
PublicSubnetOneRouteTableAssociation:
|
| 97 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 98 |
+
Properties:
|
| 99 |
+
SubnetId: !Ref PublicSubnetOne
|
| 100 |
+
RouteTableId: !Ref PublicRouteTable
|
| 101 |
+
|
| 102 |
+
PublicSubnetTwoRouteTableAssociation:
|
| 103 |
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
| 104 |
+
Properties:
|
| 105 |
+
SubnetId: !Ref PublicSubnetTwo
|
| 106 |
+
RouteTableId: !Ref PublicRouteTable
|
| 107 |
+
|
| 108 |
+
# ECS Resources
|
| 109 |
+
ECSCluster:
|
| 110 |
+
Type: AWS::ECS::Cluster
|
| 111 |
+
|
| 112 |
+
# A security group for the containers we will run in Fargate.
|
| 113 |
+
# Two rules, allowing network traffic from a public facing load
|
| 114 |
+
# balancer and from other members of the security group.
|
| 115 |
+
#
|
| 116 |
+
# Remove any of the following ingress rules that are not needed.
|
| 117 |
+
# If you want to make direct requests to a container using its
|
| 118 |
+
# public IP address you'll need to add a security group rule
|
| 119 |
+
# to allow traffic from all IP addresses.
|
| 120 |
+
FargateContainerSecurityGroup:
|
| 121 |
+
Type: AWS::EC2::SecurityGroup
|
| 122 |
+
Properties:
|
| 123 |
+
GroupDescription: Access to the Fargate containers
|
| 124 |
+
VpcId: !Ref VPC
|
| 125 |
+
|
| 126 |
+
EcsSecurityGroupIngressFromPublicALB:
|
| 127 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 128 |
+
Properties:
|
| 129 |
+
Description: Ingress from the public ALB
|
| 130 |
+
GroupId: !Ref FargateContainerSecurityGroup
|
| 131 |
+
IpProtocol: "-1"
|
| 132 |
+
SourceSecurityGroupId: !Ref PublicLoadBalancerSG
|
| 133 |
+
|
| 134 |
+
EcsSecurityGroupIngressFromSelf:
|
| 135 |
+
Type: AWS::EC2::SecurityGroupIngress
|
| 136 |
+
Properties:
|
| 137 |
+
Description: Ingress from other containers in the same security group
|
| 138 |
+
GroupId: !Ref FargateContainerSecurityGroup
|
| 139 |
+
IpProtocol: "-1"
|
| 140 |
+
SourceSecurityGroupId: !Ref FargateContainerSecurityGroup
|
| 141 |
+
|
| 142 |
+
# Load balancers for getting traffic to containers.
|
| 143 |
+
# This sample template creates one load balancer:
|
| 144 |
+
#
|
| 145 |
+
# - One public load balancer, hosted in public subnets that is accessible
|
| 146 |
+
# to the public, and is intended to route traffic to one or more public
|
| 147 |
+
# facing services.
|
| 148 |
+
|
| 149 |
+
# A public facing load balancer, this is used for accepting traffic from the public
|
| 150 |
+
# internet and directing it to public facing microservices
|
| 151 |
+
PublicLoadBalancerSG:
|
| 152 |
+
Type: AWS::EC2::SecurityGroup
|
| 153 |
+
Properties:
|
| 154 |
+
GroupDescription: Access to the public facing load balancer
|
| 155 |
+
VpcId: !Ref VPC
|
| 156 |
+
SecurityGroupIngress:
|
| 157 |
+
|
| 158 |
+
# Allow access to ALB from anywhere on the internet
|
| 159 |
+
- CidrIp: 0.0.0.0/0
|
| 160 |
+
IpProtocol: "-1"
|
| 161 |
+
|
| 162 |
+
PublicLoadBalancer:
|
| 163 |
+
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
|
| 164 |
+
Properties:
|
| 165 |
+
Scheme: internet-facing
|
| 166 |
+
LoadBalancerAttributes:
|
| 167 |
+
- Key: idle_timeout.timeout_seconds
|
| 168 |
+
Value: "30"
|
| 169 |
+
Subnets:
|
| 170 |
+
|
| 171 |
+
# The load balancer is placed into the public subnets, so that traffic
|
| 172 |
+
# from the internet can reach the load balancer directly via the internet gateway
|
| 173 |
+
- !Ref PublicSubnetOne
|
| 174 |
+
- !Ref PublicSubnetTwo
|
| 175 |
+
SecurityGroups:
|
| 176 |
+
- !Ref PublicLoadBalancerSG
|
| 177 |
+
|
| 178 |
+
# A dummy target group is used to setup the ALB to just drop traffic
|
| 179 |
+
# initially, before any real service target groups have been added.
|
| 180 |
+
DummyTargetGroupPublic:
|
| 181 |
+
Type: AWS::ElasticLoadBalancingV2::TargetGroup
|
| 182 |
+
Properties:
|
| 183 |
+
HealthCheckIntervalSeconds: 6
|
| 184 |
+
HealthCheckPath: /
|
| 185 |
+
HealthCheckProtocol: HTTP
|
| 186 |
+
HealthCheckTimeoutSeconds: 5
|
| 187 |
+
HealthyThresholdCount: 2
|
| 188 |
+
Name: !Join
|
| 189 |
+
- '-'
|
| 190 |
+
- - !Ref AWS::StackName
|
| 191 |
+
- drop-1
|
| 192 |
+
Port: 80
|
| 193 |
+
Protocol: HTTP
|
| 194 |
+
UnhealthyThresholdCount: 2
|
| 195 |
+
VpcId: !Ref VPC
|
| 196 |
+
|
| 197 |
+
PublicLoadBalancerListener:
|
| 198 |
+
Type: AWS::ElasticLoadBalancingV2::Listener
|
| 199 |
+
Properties:
|
| 200 |
+
DefaultActions:
|
| 201 |
+
- TargetGroupArn: !Ref DummyTargetGroupPublic
|
| 202 |
+
Type: forward
|
| 203 |
+
LoadBalancerArn: !Ref PublicLoadBalancer
|
| 204 |
+
Port: 80
|
| 205 |
+
Protocol: HTTP
|
| 206 |
+
|
| 207 |
+
# This is an IAM role which authorizes ECS to manage resources on your
|
| 208 |
+
# account on your behalf, such as updating your load balancer with the
|
| 209 |
+
# details of where your containers are, so that traffic can reach your
|
| 210 |
+
# containers.
|
| 211 |
+
ECSRole:
|
| 212 |
+
Type: AWS::IAM::Role
|
| 213 |
+
Properties:
|
| 214 |
+
AssumeRolePolicyDocument:
|
| 215 |
+
Statement:
|
| 216 |
+
- Effect: Allow
|
| 217 |
+
Principal:
|
| 218 |
+
Service:
|
| 219 |
+
- ecs.amazonaws.com
|
| 220 |
+
Action:
|
| 221 |
+
- sts:AssumeRole
|
| 222 |
+
Path: /
|
| 223 |
+
Policies:
|
| 224 |
+
- PolicyName: ecs-service
|
| 225 |
+
PolicyDocument:
|
| 226 |
+
Statement:
|
| 227 |
+
- Effect: Allow
|
| 228 |
+
Action:
|
| 229 |
+
|
| 230 |
+
# Rules which allow ECS to attach network interfaces to instances
|
| 231 |
+
# on your behalf in order for awsvpc networking mode to work right
|
| 232 |
+
- ec2:AttachNetworkInterface
|
| 233 |
+
- ec2:CreateNetworkInterface
|
| 234 |
+
- ec2:CreateNetworkInterfacePermission
|
| 235 |
+
- ec2:DeleteNetworkInterface
|
| 236 |
+
- ec2:DeleteNetworkInterfacePermission
|
| 237 |
+
- ec2:Describe*
|
| 238 |
+
- ec2:DetachNetworkInterface
|
| 239 |
+
|
| 240 |
+
# Rules which allow ECS to update load balancers on your behalf
|
| 241 |
+
# with the information sabout how to send traffic to your containers
|
| 242 |
+
- elasticloadbalancing:DeregisterInstancesFromLoadBalancer
|
| 243 |
+
- elasticloadbalancing:DeregisterTargets
|
| 244 |
+
- elasticloadbalancing:Describe*
|
| 245 |
+
- elasticloadbalancing:RegisterInstancesWithLoadBalancer
|
| 246 |
+
- elasticloadbalancing:RegisterTargets
|
| 247 |
+
Resource: '*'
|
| 248 |
+
|
| 249 |
+
# This is a role which is used by the ECS tasks themselves.
|
| 250 |
+
ECSTaskExecutionRole:
|
| 251 |
+
Type: AWS::IAM::Role
|
| 252 |
+
Properties:
|
| 253 |
+
AssumeRolePolicyDocument:
|
| 254 |
+
Statement:
|
| 255 |
+
- Effect: Allow
|
| 256 |
+
Principal:
|
| 257 |
+
Service:
|
| 258 |
+
- ecs-tasks.amazonaws.com
|
| 259 |
+
Action:
|
| 260 |
+
- sts:AssumeRole
|
| 261 |
+
Path: /
|
| 262 |
+
Policies:
|
| 263 |
+
- PolicyName: AmazonECSTaskExecutionRolePolicy
|
| 264 |
+
PolicyDocument:
|
| 265 |
+
Statement:
|
| 266 |
+
- Effect: Allow
|
| 267 |
+
Action:
|
| 268 |
+
|
| 269 |
+
# Allow the ECS Tasks to download images from ECR
|
| 270 |
+
- ecr:GetAuthorizationToken
|
| 271 |
+
- ecr:BatchCheckLayerAvailability
|
| 272 |
+
- ecr:GetDownloadUrlForLayer
|
| 273 |
+
- ecr:BatchGetImage
|
| 274 |
+
|
| 275 |
+
# Allow the ECS tasks to upload logs to CloudWatch
|
| 276 |
+
- logs:CreateLogStream
|
| 277 |
+
- logs:PutLogEvents
|
| 278 |
+
Resource: '*'
|
| 279 |
+
|
| 280 |
+
# These are the values output by the CloudFormation template. Be careful
|
| 281 |
+
# about changing any of them, because of them are exported with specific
|
| 282 |
+
# names so that the other task related CF templates can use them.
|
| 283 |
+
Outputs:
|
| 284 |
+
ClusterName:
|
| 285 |
+
Description: The name of the ECS cluster
|
| 286 |
+
Value: !Ref ECSCluster
|
| 287 |
+
Export:
|
| 288 |
+
Name: !Join
|
| 289 |
+
- ':'
|
| 290 |
+
- - !Ref AWS::StackName
|
| 291 |
+
- ClusterName
|
| 292 |
+
|
| 293 |
+
ExternalUrl:
|
| 294 |
+
Description: The url of the external load balancer
|
| 295 |
+
Value: !Join
|
| 296 |
+
- ""
|
| 297 |
+
- - http://
|
| 298 |
+
- !GetAtt PublicLoadBalancer.DNSName
|
| 299 |
+
Export:
|
| 300 |
+
Name: !Join
|
| 301 |
+
- ':'
|
| 302 |
+
- - !Ref AWS::StackName
|
| 303 |
+
- ExternalUrl
|
| 304 |
+
|
| 305 |
+
ECSRole:
|
| 306 |
+
Description: The ARN of the ECS role
|
| 307 |
+
Value: !GetAtt ECSRole.Arn
|
| 308 |
+
Export:
|
| 309 |
+
Name: !Join
|
| 310 |
+
- ':'
|
| 311 |
+
- - !Ref AWS::StackName
|
| 312 |
+
- ECSRole
|
| 313 |
+
|
| 314 |
+
ECSTaskExecutionRole:
|
| 315 |
+
Description: The ARN of the ECS role
|
| 316 |
+
Value: !GetAtt ECSTaskExecutionRole.Arn
|
| 317 |
+
Export:
|
| 318 |
+
Name: !Join
|
| 319 |
+
- ':'
|
| 320 |
+
- - !Ref AWS::StackName
|
| 321 |
+
- ECSTaskExecutionRole
|
| 322 |
+
|
| 323 |
+
PublicListener:
|
| 324 |
+
Description: The ARN of the public load balancer's Listener
|
| 325 |
+
Value: !Ref PublicLoadBalancerListener
|
| 326 |
+
Export:
|
| 327 |
+
Name: !Join
|
| 328 |
+
- ':'
|
| 329 |
+
- - !Ref AWS::StackName
|
| 330 |
+
- PublicListener
|
| 331 |
+
|
| 332 |
+
VPCId:
|
| 333 |
+
Description: The ID of the VPC that this stack is deployed in
|
| 334 |
+
Value: !Ref VPC
|
| 335 |
+
Export:
|
| 336 |
+
Name: !Join
|
| 337 |
+
- ':'
|
| 338 |
+
- - !Ref AWS::StackName
|
| 339 |
+
- VPCId
|
| 340 |
+
|
| 341 |
+
PublicSubnetOne:
|
| 342 |
+
Description: Public subnet one
|
| 343 |
+
Value: !Ref PublicSubnetOne
|
| 344 |
+
Export:
|
| 345 |
+
Name: !Join
|
| 346 |
+
- ':'
|
| 347 |
+
- - !Ref AWS::StackName
|
| 348 |
+
- PublicSubnetOne
|
| 349 |
+
|
| 350 |
+
PublicSubnetTwo:
|
| 351 |
+
Description: Public subnet two
|
| 352 |
+
Value: !Ref PublicSubnetTwo
|
| 353 |
+
Export:
|
| 354 |
+
Name: !Join
|
| 355 |
+
- ':'
|
| 356 |
+
- - !Ref AWS::StackName
|
| 357 |
+
- PublicSubnetTwo
|
| 358 |
+
|
| 359 |
+
FargateContainerSecurityGroup:
|
| 360 |
+
Description: A security group used to allow Fargate containers to receive traffic
|
| 361 |
+
Value: !Ref FargateContainerSecurityGroup
|
| 362 |
+
Export:
|
| 363 |
+
Name: !Join
|
| 364 |
+
- ':'
|
| 365 |
+
- - !Ref AWS::StackName
|
| 366 |
+
- FargateContainerSecurityGroup
|
human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/services/private-subnet-private-service.json
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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STemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Deploy a service on AWS Fargate, hosted in a private subnet, behind a private load balancer.",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"StackName": {
|
| 6 |
+
"Description": "The name of the parent Fargate networking stack that you created. Necessary to locate and reference resources created by that stack.",
|
| 7 |
+
"Type": "String",
|
| 8 |
+
"Default": "production"
|
| 9 |
+
},
|
| 10 |
+
"ServiceName": {
|
| 11 |
+
"Description": "A name for the service",
|
| 12 |
+
"Type": "String",
|
| 13 |
+
"Default": "nginx"
|
| 14 |
+
},
|
| 15 |
+
"ImageUrl": {
|
| 16 |
+
"Description": "The url of a docker image that contains the application process that will handle the traffic for this service",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"Default": "nginx"
|
| 19 |
+
},
|
| 20 |
+
"ContainerPort": {
|
| 21 |
+
"Description": "What port number the application inside the docker container is binding to",
|
| 22 |
+
"Type": "Number",
|
| 23 |
+
"Default": 80
|
| 24 |
+
},
|
| 25 |
+
"ContainerCpu": {
|
| 26 |
+
"Description": "How much CPU to give the container. 1024 is 1 CPU",
|
| 27 |
+
"Type": "Number",
|
| 28 |
+
"Default": 256
|
| 29 |
+
},
|
| 30 |
+
"ContainerMemory": {
|
| 31 |
+
"Description": "How much memory in megabytes to give the container",
|
| 32 |
+
"Type": "Number",
|
| 33 |
+
"Default": 512
|
| 34 |
+
},
|
| 35 |
+
"Path": {
|
| 36 |
+
"Description": "A path on the public load balancer that this service should be connected to. Use * to send all load balancer traffic to this service.",
|
| 37 |
+
"Type": "String",
|
| 38 |
+
"Default": "*"
|
| 39 |
+
},
|
| 40 |
+
"Priority": {
|
| 41 |
+
"Description": "The priority for the routing rule added to the load balancer. This only applies if your have multiple services which have been assigned to different paths on the load balancer.",
|
| 42 |
+
"Type": "Number",
|
| 43 |
+
"Default": 1
|
| 44 |
+
},
|
| 45 |
+
"DesiredCount": {
|
| 46 |
+
"Description": "How many copies of the service task to run",
|
| 47 |
+
"Type": "Number",
|
| 48 |
+
"Default": 2
|
| 49 |
+
},
|
| 50 |
+
"Role": {
|
| 51 |
+
"Description": "(Optional) An IAM role to give the service's containers if the code within needs to access other AWS resources like S3 buckets, DynamoDB tables, etc",
|
| 52 |
+
"Type": "String",
|
| 53 |
+
"Default": ""
|
| 54 |
+
}
|
| 55 |
+
},
|
| 56 |
+
"Conditions": {
|
| 57 |
+
"HasCustomRole": {
|
| 58 |
+
"Fn::Not": [
|
| 59 |
+
{
|
| 60 |
+
"Fn::Equals": [
|
| 61 |
+
{
|
| 62 |
+
"Ref": "Role"
|
| 63 |
+
},
|
| 64 |
+
""
|
| 65 |
+
]
|
| 66 |
+
}
|
| 67 |
+
]
|
| 68 |
+
}
|
| 69 |
+
},
|
| 70 |
+
"Resources": {
|
| 71 |
+
"TaskDefinition": {
|
| 72 |
+
"Type": "AWS::ECS::TaskDefinition",
|
| 73 |
+
"Properties": {
|
| 74 |
+
"Family": {
|
| 75 |
+
"Ref": "ServiceName"
|
| 76 |
+
},
|
| 77 |
+
"Cpu": {
|
| 78 |
+
"Ref": "ContainerCpu"
|
| 79 |
+
},
|
| 80 |
+
"Memory": {
|
| 81 |
+
"Ref": "ContainerMemory"
|
| 82 |
+
},
|
| 83 |
+
"NetworkMode": "awsvpc",
|
| 84 |
+
"RequiresCompatibilities": [
|
| 85 |
+
"FARGATE"
|
| 86 |
+
],
|
| 87 |
+
"ExecutionRoleArn": {
|
| 88 |
+
"Fn::ImportValue": {
|
| 89 |
+
"Fn::Join": [
|
| 90 |
+
":",
|
| 91 |
+
[
|
| 92 |
+
{
|
| 93 |
+
"Ref": "StackName"
|
| 94 |
+
},
|
| 95 |
+
"ECSTaskExecutionRole"
|
| 96 |
+
]
|
| 97 |
+
]
|
| 98 |
+
}
|
| 99 |
+
},
|
| 100 |
+
"TaskRoleArn": {
|
| 101 |
+
"Fn::If": [
|
| 102 |
+
"HasCustomRole",
|
| 103 |
+
{
|
| 104 |
+
"Ref": "Role"
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"Ref": "AWS::NoValue"
|
| 108 |
+
}
|
| 109 |
+
]
|
| 110 |
+
},
|
| 111 |
+
"ContainerDefinitions": [
|
| 112 |
+
{
|
| 113 |
+
"Name": {
|
| 114 |
+
"Ref": "ServiceName"
|
| 115 |
+
},
|
| 116 |
+
"Essential": true,
|
| 117 |
+
"Cpu": {
|
| 118 |
+
"Ref": "ContainerCpu"
|
| 119 |
+
},
|
| 120 |
+
"Memory": {
|
| 121 |
+
"Ref": "ContainerMemory"
|
| 122 |
+
},
|
| 123 |
+
"Image": {
|
| 124 |
+
"Ref": "ImageUrl"
|
| 125 |
+
},
|
| 126 |
+
"PortMappings": [
|
| 127 |
+
{
|
| 128 |
+
"ContainerPort": {
|
| 129 |
+
"Ref": "ContainerPort"
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
]
|
| 133 |
+
}
|
| 134 |
+
]
|
| 135 |
+
}
|
| 136 |
+
},
|
| 137 |
+
"Service": {
|
| 138 |
+
"Type": "AWS::ECS::Service",
|
| 139 |
+
"DependsOn": "LoadBalancerRule",
|
| 140 |
+
"Properties": {
|
| 141 |
+
"ServiceName": {
|
| 142 |
+
"Ref": "ServiceName"
|
| 143 |
+
},
|
| 144 |
+
"Cluster": {
|
| 145 |
+
"Fn::ImportValue": {
|
| 146 |
+
"Fn::Join": [
|
| 147 |
+
":",
|
| 148 |
+
[
|
| 149 |
+
{
|
| 150 |
+
"Ref": "StackName"
|
| 151 |
+
},
|
| 152 |
+
"ClusterName"
|
| 153 |
+
]
|
| 154 |
+
]
|
| 155 |
+
}
|
| 156 |
+
},
|
| 157 |
+
"LaunchType": "FARGATE",
|
| 158 |
+
"DeploymentConfiguration": {
|
| 159 |
+
"MaximumPercent": 200,
|
| 160 |
+
"MinimumHealthyPercent": 75
|
| 161 |
+
},
|
| 162 |
+
"DesiredCount": {
|
| 163 |
+
"Ref": "DesiredCount"
|
| 164 |
+
},
|
| 165 |
+
"NetworkConfiguration": {
|
| 166 |
+
"AwsvpcConfiguration": {
|
| 167 |
+
"SecurityGroups": [
|
| 168 |
+
{
|
| 169 |
+
"Fn::ImportValue": {
|
| 170 |
+
"Fn::Join": [
|
| 171 |
+
":",
|
| 172 |
+
[
|
| 173 |
+
{
|
| 174 |
+
"Ref": "StackName"
|
| 175 |
+
},
|
| 176 |
+
"FargateContainerSecurityGroup"
|
| 177 |
+
]
|
| 178 |
+
]
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
],
|
| 182 |
+
"Subnets": [
|
| 183 |
+
{
|
| 184 |
+
"Fn::ImportValue": {
|
| 185 |
+
"Fn::Join": [
|
| 186 |
+
":",
|
| 187 |
+
[
|
| 188 |
+
{
|
| 189 |
+
"Ref": "StackName"
|
| 190 |
+
},
|
| 191 |
+
"PrivateSubnetOne"
|
| 192 |
+
]
|
| 193 |
+
]
|
| 194 |
+
}
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"Fn::ImportValue": {
|
| 198 |
+
"Fn::Join": [
|
| 199 |
+
":",
|
| 200 |
+
[
|
| 201 |
+
{
|
| 202 |
+
"Ref": "StackName"
|
| 203 |
+
},
|
| 204 |
+
"PrivateSubnetTwo"
|
| 205 |
+
]
|
| 206 |
+
]
|
| 207 |
+
}
|
| 208 |
+
}
|
| 209 |
+
]
|
| 210 |
+
}
|
| 211 |
+
},
|
| 212 |
+
"TaskDefinition": {
|
| 213 |
+
"Ref": "TaskDefinition"
|
| 214 |
+
},
|
| 215 |
+
"LoadBalancers": [
|
| 216 |
+
{
|
| 217 |
+
"ContainerName": {
|
| 218 |
+
"Ref": "ServiceName"
|
| 219 |
+
},
|
| 220 |
+
"ContainerPort": {
|
| 221 |
+
"Ref": "ContainerPort"
|
| 222 |
+
},
|
| 223 |
+
"TargetGroupArn": {
|
| 224 |
+
"Ref": "TargetGroup"
|
| 225 |
+
}
|
| 226 |
+
}
|
| 227 |
+
]
|
| 228 |
+
}
|
| 229 |
+
},
|
| 230 |
+
"TargetGroup": {
|
| 231 |
+
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
|
| 232 |
+
"Properties": {
|
| 233 |
+
"HealthCheckIntervalSeconds": 6,
|
| 234 |
+
"HealthCheckPath": "/",
|
| 235 |
+
"HealthCheckProtocol": "HTTP",
|
| 236 |
+
"HealthCheckTimeoutSeconds": 5,
|
| 237 |
+
"HealthyThresholdCount": 2,
|
| 238 |
+
"TargetType": "ip",
|
| 239 |
+
"Name": {
|
| 240 |
+
"Ref": "ServiceName"
|
| 241 |
+
},
|
| 242 |
+
"Port": {
|
| 243 |
+
"Ref": "ContainerPort"
|
| 244 |
+
},
|
| 245 |
+
"Protocol": "HTTP",
|
| 246 |
+
"UnhealthyThresholdCount": 2,
|
| 247 |
+
"VpcId": {
|
| 248 |
+
"Fn::ImportValue": {
|
| 249 |
+
"Fn::Join": [
|
| 250 |
+
":",
|
| 251 |
+
[
|
| 252 |
+
{
|
| 253 |
+
"Ref": "StackName"
|
| 254 |
+
},
|
| 255 |
+
"VPCId"
|
| 256 |
+
]
|
| 257 |
+
]
|
| 258 |
+
}
|
| 259 |
+
}
|
| 260 |
+
}
|
| 261 |
+
},
|
| 262 |
+
"LoadBalancerRule": {
|
| 263 |
+
"Type": "AWS::ElasticLoadBalancingV2::ListenerRule",
|
| 264 |
+
"Properties": {
|
| 265 |
+
"Actions": [
|
| 266 |
+
{
|
| 267 |
+
"TargetGroupArn": {
|
| 268 |
+
"Ref": "TargetGroup"
|
| 269 |
+
},
|
| 270 |
+
"Type": "forward"
|
| 271 |
+
}
|
| 272 |
+
],
|
| 273 |
+
"Conditions": [
|
| 274 |
+
{
|
| 275 |
+
"Field": "path-pattern",
|
| 276 |
+
"Values": [
|
| 277 |
+
{
|
| 278 |
+
"Ref": "Path"
|
| 279 |
+
}
|
| 280 |
+
]
|
| 281 |
+
}
|
| 282 |
+
],
|
| 283 |
+
"ListenerArn": {
|
| 284 |
+
"Fn::ImportValue": {
|
| 285 |
+
"Fn::Join": [
|
| 286 |
+
":",
|
| 287 |
+
[
|
| 288 |
+
{
|
| 289 |
+
"Ref": "StackName"
|
| 290 |
+
},
|
| 291 |
+
"PrivateListener"
|
| 292 |
+
]
|
| 293 |
+
]
|
| 294 |
+
}
|
| 295 |
+
},
|
| 296 |
+
"Priority": {
|
| 297 |
+
"Ref": "Priority"
|
| 298 |
+
}
|
| 299 |
+
}
|
| 300 |
+
}
|
| 301 |
+
}
|
| 302 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/services/private-subnet-private-service.yaml
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Deploy a service on AWS Fargate, hosted in a private subnet, behind a private load balancer.
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
StackName:
|
| 7 |
+
Description: The name of the parent Fargate networking stack that you created. Necessary to locate and reference resources created by that stack.
|
| 8 |
+
Type: String
|
| 9 |
+
Default: production
|
| 10 |
+
|
| 11 |
+
ServiceName:
|
| 12 |
+
Description: A name for the service
|
| 13 |
+
Type: String
|
| 14 |
+
Default: nginx
|
| 15 |
+
|
| 16 |
+
ImageUrl:
|
| 17 |
+
Description: The url of a docker image that contains the application process that will handle the traffic for this service
|
| 18 |
+
Type: String
|
| 19 |
+
Default: nginx
|
| 20 |
+
|
| 21 |
+
ContainerPort:
|
| 22 |
+
Description: What port number the application inside the docker container is binding to
|
| 23 |
+
Type: Number
|
| 24 |
+
Default: 80
|
| 25 |
+
|
| 26 |
+
ContainerCpu:
|
| 27 |
+
Description: How much CPU to give the container. 1024 is 1 CPU
|
| 28 |
+
Type: Number
|
| 29 |
+
Default: 256
|
| 30 |
+
|
| 31 |
+
ContainerMemory:
|
| 32 |
+
Description: How much memory in megabytes to give the container
|
| 33 |
+
Type: Number
|
| 34 |
+
Default: 512
|
| 35 |
+
|
| 36 |
+
Path:
|
| 37 |
+
Description: A path on the public load balancer that this service should be connected to. Use * to send all load balancer traffic to this service.
|
| 38 |
+
Type: String
|
| 39 |
+
Default: '*'
|
| 40 |
+
|
| 41 |
+
Priority:
|
| 42 |
+
Description: The priority for the routing rule added to the load balancer. This only applies if your have multiple services which have been assigned to different paths on the load balancer.
|
| 43 |
+
Type: Number
|
| 44 |
+
Default: 1
|
| 45 |
+
|
| 46 |
+
DesiredCount:
|
| 47 |
+
Description: How many copies of the service task to run
|
| 48 |
+
Type: Number
|
| 49 |
+
Default: 2
|
| 50 |
+
|
| 51 |
+
Role:
|
| 52 |
+
Description: (Optional) An IAM role to give the service's containers if the code within needs to access other AWS resources like S3 buckets, DynamoDB tables, etc
|
| 53 |
+
Type: String
|
| 54 |
+
Default: ""
|
| 55 |
+
|
| 56 |
+
Conditions:
|
| 57 |
+
HasCustomRole: !Not
|
| 58 |
+
- !Equals
|
| 59 |
+
- !Ref Role
|
| 60 |
+
- ""
|
| 61 |
+
|
| 62 |
+
Resources:
|
| 63 |
+
|
| 64 |
+
# The task definition. This is a simple metadata description of what
|
| 65 |
+
# container to run, and what resource requirements it has.
|
| 66 |
+
TaskDefinition:
|
| 67 |
+
Type: AWS::ECS::TaskDefinition
|
| 68 |
+
Properties:
|
| 69 |
+
Family: !Ref ServiceName
|
| 70 |
+
Cpu: !Ref ContainerCpu
|
| 71 |
+
Memory: !Ref ContainerMemory
|
| 72 |
+
NetworkMode: awsvpc
|
| 73 |
+
RequiresCompatibilities:
|
| 74 |
+
- FARGATE
|
| 75 |
+
ExecutionRoleArn: !ImportValue
|
| 76 |
+
Fn::Join:
|
| 77 |
+
- ':'
|
| 78 |
+
- - !Ref StackName
|
| 79 |
+
- ECSTaskExecutionRole
|
| 80 |
+
TaskRoleArn: !If
|
| 81 |
+
- HasCustomRole
|
| 82 |
+
- !Ref Role
|
| 83 |
+
- !Ref AWS::NoValue
|
| 84 |
+
ContainerDefinitions:
|
| 85 |
+
- Name: !Ref ServiceName
|
| 86 |
+
Essential: true
|
| 87 |
+
Cpu: !Ref ContainerCpu
|
| 88 |
+
Memory: !Ref ContainerMemory
|
| 89 |
+
Image: !Ref ImageUrl
|
| 90 |
+
PortMappings:
|
| 91 |
+
- ContainerPort: !Ref ContainerPort
|
| 92 |
+
|
| 93 |
+
# The service. The service is a resource which allows you to run multiple
|
| 94 |
+
# copies of a type of task, and gather up their logs and metrics, as well
|
| 95 |
+
# as monitor the number of running tasks and replace any that have crashed
|
| 96 |
+
Service:
|
| 97 |
+
Type: AWS::ECS::Service
|
| 98 |
+
DependsOn: LoadBalancerRule
|
| 99 |
+
Properties:
|
| 100 |
+
ServiceName: !Ref ServiceName
|
| 101 |
+
Cluster: !ImportValue
|
| 102 |
+
Fn::Join:
|
| 103 |
+
- ':'
|
| 104 |
+
- - !Ref StackName
|
| 105 |
+
- ClusterName
|
| 106 |
+
LaunchType: FARGATE
|
| 107 |
+
DeploymentConfiguration:
|
| 108 |
+
MaximumPercent: 200
|
| 109 |
+
MinimumHealthyPercent: 75
|
| 110 |
+
DesiredCount: !Ref DesiredCount
|
| 111 |
+
NetworkConfiguration:
|
| 112 |
+
AwsvpcConfiguration:
|
| 113 |
+
SecurityGroups:
|
| 114 |
+
- !ImportValue
|
| 115 |
+
Fn::Join:
|
| 116 |
+
- ':'
|
| 117 |
+
- - !Ref StackName
|
| 118 |
+
- FargateContainerSecurityGroup
|
| 119 |
+
Subnets:
|
| 120 |
+
- !ImportValue
|
| 121 |
+
Fn::Join:
|
| 122 |
+
- ':'
|
| 123 |
+
- - !Ref StackName
|
| 124 |
+
- PrivateSubnetOne
|
| 125 |
+
- !ImportValue
|
| 126 |
+
Fn::Join:
|
| 127 |
+
- ':'
|
| 128 |
+
- - !Ref StackName
|
| 129 |
+
- PrivateSubnetTwo
|
| 130 |
+
TaskDefinition: !Ref TaskDefinition
|
| 131 |
+
LoadBalancers:
|
| 132 |
+
- ContainerName: !Ref ServiceName
|
| 133 |
+
ContainerPort: !Ref ContainerPort
|
| 134 |
+
TargetGroupArn: !Ref TargetGroup
|
| 135 |
+
|
| 136 |
+
# A target group. This is used for keeping track of all the tasks, and
|
| 137 |
+
# what IP addresses / port numbers they have. You can query it yourself,
|
| 138 |
+
# to use the addresses yourself, but most often this target group is just
|
| 139 |
+
# connected to an application load balancer, or network load balancer, so
|
| 140 |
+
# it can automatically distribute traffic across all the targets.
|
| 141 |
+
TargetGroup:
|
| 142 |
+
Type: AWS::ElasticLoadBalancingV2::TargetGroup
|
| 143 |
+
Properties:
|
| 144 |
+
HealthCheckIntervalSeconds: 6
|
| 145 |
+
HealthCheckPath: /
|
| 146 |
+
HealthCheckProtocol: HTTP
|
| 147 |
+
HealthCheckTimeoutSeconds: 5
|
| 148 |
+
HealthyThresholdCount: 2
|
| 149 |
+
TargetType: ip
|
| 150 |
+
Name: !Ref ServiceName
|
| 151 |
+
Port: !Ref ContainerPort
|
| 152 |
+
Protocol: HTTP
|
| 153 |
+
UnhealthyThresholdCount: 2
|
| 154 |
+
VpcId: !ImportValue
|
| 155 |
+
Fn::Join:
|
| 156 |
+
- ':'
|
| 157 |
+
- - !Ref StackName
|
| 158 |
+
- VPCId
|
| 159 |
+
|
| 160 |
+
# Create a rule on the load balancer for routing traffic to the target group
|
| 161 |
+
LoadBalancerRule:
|
| 162 |
+
Type: AWS::ElasticLoadBalancingV2::ListenerRule
|
| 163 |
+
Properties:
|
| 164 |
+
Actions:
|
| 165 |
+
- TargetGroupArn: !Ref TargetGroup
|
| 166 |
+
Type: forward
|
| 167 |
+
Conditions:
|
| 168 |
+
- Field: path-pattern
|
| 169 |
+
Values:
|
| 170 |
+
- !Ref Path
|
| 171 |
+
ListenerArn: !ImportValue
|
| 172 |
+
Fn::Join:
|
| 173 |
+
- ':'
|
| 174 |
+
- - !Ref StackName
|
| 175 |
+
- PrivateListener
|
| 176 |
+
Priority: !Ref Priority
|
human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/services/private-subnet-public-service.json
ADDED
|
@@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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Deploy a service on AWS Fargate, hosted in a private subnet, but accessible via a public load balancer.",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"StackName": {
|
| 6 |
+
"Description": "The name of the parent Fargate networking stack that you created. Necessary to locate and reference resources created by that stack.",
|
| 7 |
+
"Type": "String",
|
| 8 |
+
"Default": "production"
|
| 9 |
+
},
|
| 10 |
+
"ServiceName": {
|
| 11 |
+
"Description": "A name for the service",
|
| 12 |
+
"Type": "String",
|
| 13 |
+
"Default": "nginx"
|
| 14 |
+
},
|
| 15 |
+
"ImageUrl": {
|
| 16 |
+
"Description": "The url of a docker image that contains the application process that will handle the traffic for this service",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"Default": "nginx"
|
| 19 |
+
},
|
| 20 |
+
"ContainerPort": {
|
| 21 |
+
"Description": "What port number the application inside the docker container is binding to",
|
| 22 |
+
"Type": "Number",
|
| 23 |
+
"Default": 80
|
| 24 |
+
},
|
| 25 |
+
"ContainerCpu": {
|
| 26 |
+
"Description": "How much CPU to give the container. 1024 is 1 CPU",
|
| 27 |
+
"Type": "Number",
|
| 28 |
+
"Default": 256
|
| 29 |
+
},
|
| 30 |
+
"ContainerMemory": {
|
| 31 |
+
"Description": "How much memory in megabytes to give the container",
|
| 32 |
+
"Type": "Number",
|
| 33 |
+
"Default": 512
|
| 34 |
+
},
|
| 35 |
+
"Path": {
|
| 36 |
+
"Description": "A path on the public load balancer that this service should be connected to. Use * to send all load balancer traffic to this service.",
|
| 37 |
+
"Type": "String",
|
| 38 |
+
"Default": "*"
|
| 39 |
+
},
|
| 40 |
+
"Priority": {
|
| 41 |
+
"Description": "The priority for the routing rule added to the load balancer. This only applies if your have multiple services which have been assigned to different paths on the load balancer.",
|
| 42 |
+
"Type": "Number",
|
| 43 |
+
"Default": 1
|
| 44 |
+
},
|
| 45 |
+
"DesiredCount": {
|
| 46 |
+
"Description": "How many copies of the service task to run",
|
| 47 |
+
"Type": "Number",
|
| 48 |
+
"Default": 2
|
| 49 |
+
},
|
| 50 |
+
"Role": {
|
| 51 |
+
"Description": "(Optional) An IAM role to give the service's containers if the code within needs to access other AWS resources like S3 buckets, DynamoDB tables, etc",
|
| 52 |
+
"Type": "String",
|
| 53 |
+
"Default": ""
|
| 54 |
+
}
|
| 55 |
+
},
|
| 56 |
+
"Conditions": {
|
| 57 |
+
"HasCustomRole": {
|
| 58 |
+
"Fn::Not": [
|
| 59 |
+
{
|
| 60 |
+
"Fn::Equals": [
|
| 61 |
+
{
|
| 62 |
+
"Ref": "Role"
|
| 63 |
+
},
|
| 64 |
+
""
|
| 65 |
+
]
|
| 66 |
+
}
|
| 67 |
+
]
|
| 68 |
+
}
|
| 69 |
+
},
|
| 70 |
+
"Resources": {
|
| 71 |
+
"TaskDefinition": {
|
| 72 |
+
"Type": "AWS::ECS::TaskDefinition",
|
| 73 |
+
"Properties": {
|
| 74 |
+
"Family": {
|
| 75 |
+
"Ref": "ServiceName"
|
| 76 |
+
},
|
| 77 |
+
"Cpu": {
|
| 78 |
+
"Ref": "ContainerCpu"
|
| 79 |
+
},
|
| 80 |
+
"Memory": {
|
| 81 |
+
"Ref": "ContainerMemory"
|
| 82 |
+
},
|
| 83 |
+
"NetworkMode": "awsvpc",
|
| 84 |
+
"RequiresCompatibilities": [
|
| 85 |
+
"FARGATE"
|
| 86 |
+
],
|
| 87 |
+
"ExecutionRoleArn": {
|
| 88 |
+
"Fn::ImportValue": {
|
| 89 |
+
"Fn::Join": [
|
| 90 |
+
":",
|
| 91 |
+
[
|
| 92 |
+
{
|
| 93 |
+
"Ref": "StackName"
|
| 94 |
+
},
|
| 95 |
+
"ECSTaskExecutionRole"
|
| 96 |
+
]
|
| 97 |
+
]
|
| 98 |
+
}
|
| 99 |
+
},
|
| 100 |
+
"TaskRoleArn": {
|
| 101 |
+
"Fn::If": [
|
| 102 |
+
"HasCustomRole",
|
| 103 |
+
{
|
| 104 |
+
"Ref": "Role"
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"Ref": "AWS::NoValue"
|
| 108 |
+
}
|
| 109 |
+
]
|
| 110 |
+
},
|
| 111 |
+
"ContainerDefinitions": [
|
| 112 |
+
{
|
| 113 |
+
"Name": {
|
| 114 |
+
"Ref": "ServiceName"
|
| 115 |
+
},
|
| 116 |
+
"Essential": true,
|
| 117 |
+
"Cpu": {
|
| 118 |
+
"Ref": "ContainerCpu"
|
| 119 |
+
},
|
| 120 |
+
"Memory": {
|
| 121 |
+
"Ref": "ContainerMemory"
|
| 122 |
+
},
|
| 123 |
+
"Image": {
|
| 124 |
+
"Ref": "ImageUrl"
|
| 125 |
+
},
|
| 126 |
+
"PortMappings": [
|
| 127 |
+
{
|
| 128 |
+
"ContainerPort": {
|
| 129 |
+
"Ref": "ContainerPort"
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
]
|
| 133 |
+
}
|
| 134 |
+
]
|
| 135 |
+
}
|
| 136 |
+
},
|
| 137 |
+
"Service": {
|
| 138 |
+
"Type": "AWS::ECS::Service",
|
| 139 |
+
"DependsOn": "LoadBalancerRule",
|
| 140 |
+
"Properties": {
|
| 141 |
+
"ServiceName": {
|
| 142 |
+
"Ref": "ServiceName"
|
| 143 |
+
},
|
| 144 |
+
"Cluster": {
|
| 145 |
+
"Fn::ImportValue": {
|
| 146 |
+
"Fn::Join": [
|
| 147 |
+
":",
|
| 148 |
+
[
|
| 149 |
+
{
|
| 150 |
+
"Ref": "StackName"
|
| 151 |
+
},
|
| 152 |
+
"ClusterName"
|
| 153 |
+
]
|
| 154 |
+
]
|
| 155 |
+
}
|
| 156 |
+
},
|
| 157 |
+
"LaunchType": "FARGATE",
|
| 158 |
+
"DeploymentConfiguration": {
|
| 159 |
+
"MaximumPercent": 200,
|
| 160 |
+
"MinimumHealthyPercent": 75
|
| 161 |
+
},
|
| 162 |
+
"DesiredCount": {
|
| 163 |
+
"Ref": "DesiredCount"
|
| 164 |
+
},
|
| 165 |
+
"NetworkConfiguration": {
|
| 166 |
+
"AwsvpcConfiguration": {
|
| 167 |
+
"AssignPublicIp": "ENABLED",
|
| 168 |
+
"SecurityGroups": [
|
| 169 |
+
{
|
| 170 |
+
"Fn::ImportValue": {
|
| 171 |
+
"Fn::Join": [
|
| 172 |
+
":",
|
| 173 |
+
[
|
| 174 |
+
{
|
| 175 |
+
"Ref": "StackName"
|
| 176 |
+
},
|
| 177 |
+
"FargateContainerSecurityGroup"
|
| 178 |
+
]
|
| 179 |
+
]
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
],
|
| 183 |
+
"Subnets": [
|
| 184 |
+
{
|
| 185 |
+
"Fn::ImportValue": {
|
| 186 |
+
"Fn::Join": [
|
| 187 |
+
":",
|
| 188 |
+
[
|
| 189 |
+
{
|
| 190 |
+
"Ref": "StackName"
|
| 191 |
+
},
|
| 192 |
+
"PrivateSubnetOne"
|
| 193 |
+
]
|
| 194 |
+
]
|
| 195 |
+
}
|
| 196 |
+
},
|
| 197 |
+
{
|
| 198 |
+
"Fn::ImportValue": {
|
| 199 |
+
"Fn::Join": [
|
| 200 |
+
":",
|
| 201 |
+
[
|
| 202 |
+
{
|
| 203 |
+
"Ref": "StackName"
|
| 204 |
+
},
|
| 205 |
+
"PrivateSubnetTwo"
|
| 206 |
+
]
|
| 207 |
+
]
|
| 208 |
+
}
|
| 209 |
+
}
|
| 210 |
+
]
|
| 211 |
+
}
|
| 212 |
+
},
|
| 213 |
+
"TaskDefinition": {
|
| 214 |
+
"Ref": "TaskDefinition"
|
| 215 |
+
},
|
| 216 |
+
"LoadBalancers": [
|
| 217 |
+
{
|
| 218 |
+
"ContainerName": {
|
| 219 |
+
"Ref": "ServiceName"
|
| 220 |
+
},
|
| 221 |
+
"ContainerPort": {
|
| 222 |
+
"Ref": "ContainerPort"
|
| 223 |
+
},
|
| 224 |
+
"TargetGroupArn": {
|
| 225 |
+
"Ref": "TargetGroup"
|
| 226 |
+
}
|
| 227 |
+
}
|
| 228 |
+
]
|
| 229 |
+
}
|
| 230 |
+
},
|
| 231 |
+
"TargetGroup": {
|
| 232 |
+
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
|
| 233 |
+
"Properties": {
|
| 234 |
+
"HealthCheckIntervalSeconds": 6,
|
| 235 |
+
"HealthCheckPath": "/",
|
| 236 |
+
"HealthCheckProtocol": "HTTP",
|
| 237 |
+
"HealthCheckTimeoutSeconds": 5,
|
| 238 |
+
"HealthyThresholdCount": 2,
|
| 239 |
+
"TargetType": "ip",
|
| 240 |
+
"Name": {
|
| 241 |
+
"Ref": "ServiceName"
|
| 242 |
+
},
|
| 243 |
+
"Port": {
|
| 244 |
+
"Ref": "ContainerPort"
|
| 245 |
+
},
|
| 246 |
+
"Protocol": "HTTP",
|
| 247 |
+
"UnhealthyThresholdCount": 2,
|
| 248 |
+
"VpcId": {
|
| 249 |
+
"Fn::ImportValue": {
|
| 250 |
+
"Fn::Join": [
|
| 251 |
+
":",
|
| 252 |
+
[
|
| 253 |
+
{
|
| 254 |
+
"Ref": "StackName"
|
| 255 |
+
},
|
| 256 |
+
"VPCId"
|
| 257 |
+
]
|
| 258 |
+
]
|
| 259 |
+
}
|
| 260 |
+
}
|
| 261 |
+
}
|
| 262 |
+
},
|
| 263 |
+
"LoadBalancerRule": {
|
| 264 |
+
"Type": "AWS::ElasticLoadBalancingV2::ListenerRule",
|
| 265 |
+
"Properties": {
|
| 266 |
+
"Actions": [
|
| 267 |
+
{
|
| 268 |
+
"TargetGroupArn": {
|
| 269 |
+
"Ref": "TargetGroup"
|
| 270 |
+
},
|
| 271 |
+
"Type": "forward"
|
| 272 |
+
}
|
| 273 |
+
],
|
| 274 |
+
"Conditions": [
|
| 275 |
+
{
|
| 276 |
+
"Field": "path-pattern",
|
| 277 |
+
"Values": [
|
| 278 |
+
{
|
| 279 |
+
"Ref": "Path"
|
| 280 |
+
}
|
| 281 |
+
]
|
| 282 |
+
}
|
| 283 |
+
],
|
| 284 |
+
"ListenerArn": {
|
| 285 |
+
"Fn::ImportValue": {
|
| 286 |
+
"Fn::Join": [
|
| 287 |
+
":",
|
| 288 |
+
[
|
| 289 |
+
{
|
| 290 |
+
"Ref": "StackName"
|
| 291 |
+
},
|
| 292 |
+
"PublicListener"
|
| 293 |
+
]
|
| 294 |
+
]
|
| 295 |
+
}
|
| 296 |
+
},
|
| 297 |
+
"Priority": {
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Deploy a service on AWS Fargate, hosted in a private subnet, but accessible via a public load balancer.
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
StackName:
|
| 7 |
+
Description: The name of the parent Fargate networking stack that you created. Necessary to locate and reference resources created by that stack.
|
| 8 |
+
Type: String
|
| 9 |
+
Default: production
|
| 10 |
+
|
| 11 |
+
ServiceName:
|
| 12 |
+
Description: A name for the service
|
| 13 |
+
Type: String
|
| 14 |
+
Default: nginx
|
| 15 |
+
|
| 16 |
+
ImageUrl:
|
| 17 |
+
Description: The url of a docker image that contains the application process that will handle the traffic for this service
|
| 18 |
+
Type: String
|
| 19 |
+
Default: nginx
|
| 20 |
+
|
| 21 |
+
ContainerPort:
|
| 22 |
+
Description: What port number the application inside the docker container is binding to
|
| 23 |
+
Type: Number
|
| 24 |
+
Default: 80
|
| 25 |
+
|
| 26 |
+
ContainerCpu:
|
| 27 |
+
Description: How much CPU to give the container. 1024 is 1 CPU
|
| 28 |
+
Type: Number
|
| 29 |
+
Default: 256
|
| 30 |
+
|
| 31 |
+
ContainerMemory:
|
| 32 |
+
Description: How much memory in megabytes to give the container
|
| 33 |
+
Type: Number
|
| 34 |
+
Default: 512
|
| 35 |
+
|
| 36 |
+
Path:
|
| 37 |
+
Description: A path on the public load balancer that this service should be connected to. Use * to send all load balancer traffic to this service.
|
| 38 |
+
Type: String
|
| 39 |
+
Default: '*'
|
| 40 |
+
|
| 41 |
+
Priority:
|
| 42 |
+
Description: The priority for the routing rule added to the load balancer. This only applies if your have multiple services which have been assigned to different paths on the load balancer.
|
| 43 |
+
Type: Number
|
| 44 |
+
Default: 1
|
| 45 |
+
|
| 46 |
+
DesiredCount:
|
| 47 |
+
Description: How many copies of the service task to run
|
| 48 |
+
Type: Number
|
| 49 |
+
Default: 2
|
| 50 |
+
|
| 51 |
+
Role:
|
| 52 |
+
Description: (Optional) An IAM role to give the service's containers if the code within needs to access other AWS resources like S3 buckets, DynamoDB tables, etc
|
| 53 |
+
Type: String
|
| 54 |
+
Default: ""
|
| 55 |
+
|
| 56 |
+
Conditions:
|
| 57 |
+
HasCustomRole: !Not
|
| 58 |
+
- !Equals
|
| 59 |
+
- !Ref Role
|
| 60 |
+
- ""
|
| 61 |
+
|
| 62 |
+
Resources:
|
| 63 |
+
|
| 64 |
+
# The task definition. This is a simple metadata description of what
|
| 65 |
+
# container to run, and what resource requirements it has.
|
| 66 |
+
TaskDefinition:
|
| 67 |
+
Type: AWS::ECS::TaskDefinition
|
| 68 |
+
Properties:
|
| 69 |
+
Family: !Ref ServiceName
|
| 70 |
+
Cpu: !Ref ContainerCpu
|
| 71 |
+
Memory: !Ref ContainerMemory
|
| 72 |
+
NetworkMode: awsvpc
|
| 73 |
+
RequiresCompatibilities:
|
| 74 |
+
- FARGATE
|
| 75 |
+
ExecutionRoleArn: !ImportValue
|
| 76 |
+
Fn::Join:
|
| 77 |
+
- ':'
|
| 78 |
+
- - !Ref StackName
|
| 79 |
+
- ECSTaskExecutionRole
|
| 80 |
+
TaskRoleArn: !If
|
| 81 |
+
- HasCustomRole
|
| 82 |
+
- !Ref Role
|
| 83 |
+
- !Ref AWS::NoValue
|
| 84 |
+
ContainerDefinitions:
|
| 85 |
+
- Name: !Ref ServiceName
|
| 86 |
+
Essential: true
|
| 87 |
+
Cpu: !Ref ContainerCpu
|
| 88 |
+
Memory: !Ref ContainerMemory
|
| 89 |
+
Image: !Ref ImageUrl
|
| 90 |
+
PortMappings:
|
| 91 |
+
- ContainerPort: !Ref ContainerPort
|
| 92 |
+
|
| 93 |
+
# The service. The service is a resource which allows you to run multiple
|
| 94 |
+
# copies of a type of task, and gather up their logs and metrics, as well
|
| 95 |
+
# as monitor the number of running tasks and replace any that have crashed
|
| 96 |
+
Service:
|
| 97 |
+
Type: AWS::ECS::Service
|
| 98 |
+
DependsOn: LoadBalancerRule
|
| 99 |
+
Properties:
|
| 100 |
+
ServiceName: !Ref ServiceName
|
| 101 |
+
Cluster: !ImportValue
|
| 102 |
+
Fn::Join:
|
| 103 |
+
- ':'
|
| 104 |
+
- - !Ref StackName
|
| 105 |
+
- ClusterName
|
| 106 |
+
LaunchType: FARGATE
|
| 107 |
+
DeploymentConfiguration:
|
| 108 |
+
MaximumPercent: 200
|
| 109 |
+
MinimumHealthyPercent: 75
|
| 110 |
+
DesiredCount: !Ref DesiredCount
|
| 111 |
+
NetworkConfiguration:
|
| 112 |
+
AwsvpcConfiguration:
|
| 113 |
+
AssignPublicIp: ENABLED
|
| 114 |
+
SecurityGroups:
|
| 115 |
+
- !ImportValue
|
| 116 |
+
Fn::Join:
|
| 117 |
+
- ':'
|
| 118 |
+
- - !Ref StackName
|
| 119 |
+
- FargateContainerSecurityGroup
|
| 120 |
+
Subnets:
|
| 121 |
+
- !ImportValue
|
| 122 |
+
Fn::Join:
|
| 123 |
+
- ':'
|
| 124 |
+
- - !Ref StackName
|
| 125 |
+
- PrivateSubnetOne
|
| 126 |
+
- !ImportValue
|
| 127 |
+
Fn::Join:
|
| 128 |
+
- ':'
|
| 129 |
+
- - !Ref StackName
|
| 130 |
+
- PrivateSubnetTwo
|
| 131 |
+
TaskDefinition: !Ref TaskDefinition
|
| 132 |
+
LoadBalancers:
|
| 133 |
+
- ContainerName: !Ref ServiceName
|
| 134 |
+
ContainerPort: !Ref ContainerPort
|
| 135 |
+
TargetGroupArn: !Ref TargetGroup
|
| 136 |
+
|
| 137 |
+
# A target group. This is used for keeping track of all the tasks, and
|
| 138 |
+
# what IP addresses / port numbers they have. You can query it yourself,
|
| 139 |
+
# to use the addresses yourself, but most often this target group is just
|
| 140 |
+
# connected to an application load balancer, or network load balancer, so
|
| 141 |
+
# it can automatically distribute traffic across all the targets.
|
| 142 |
+
TargetGroup:
|
| 143 |
+
Type: AWS::ElasticLoadBalancingV2::TargetGroup
|
| 144 |
+
Properties:
|
| 145 |
+
HealthCheckIntervalSeconds: 6
|
| 146 |
+
HealthCheckPath: /
|
| 147 |
+
HealthCheckProtocol: HTTP
|
| 148 |
+
HealthCheckTimeoutSeconds: 5
|
| 149 |
+
HealthyThresholdCount: 2
|
| 150 |
+
TargetType: ip
|
| 151 |
+
Name: !Ref ServiceName
|
| 152 |
+
Port: !Ref ContainerPort
|
| 153 |
+
Protocol: HTTP
|
| 154 |
+
UnhealthyThresholdCount: 2
|
| 155 |
+
VpcId: !ImportValue
|
| 156 |
+
Fn::Join:
|
| 157 |
+
- ':'
|
| 158 |
+
- - !Ref StackName
|
| 159 |
+
- VPCId
|
| 160 |
+
|
| 161 |
+
# Create a rule on the load balancer for routing traffic to the target group
|
| 162 |
+
LoadBalancerRule:
|
| 163 |
+
Type: AWS::ElasticLoadBalancingV2::ListenerRule
|
| 164 |
+
Properties:
|
| 165 |
+
Actions:
|
| 166 |
+
- TargetGroupArn: !Ref TargetGroup
|
| 167 |
+
Type: forward
|
| 168 |
+
Conditions:
|
| 169 |
+
- Field: path-pattern
|
| 170 |
+
Values:
|
| 171 |
+
- !Ref Path
|
| 172 |
+
ListenerArn: !ImportValue
|
| 173 |
+
Fn::Join:
|
| 174 |
+
- ':'
|
| 175 |
+
- - !Ref StackName
|
| 176 |
+
- PublicListener
|
| 177 |
+
Priority: !Ref Priority
|
human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/services/public-service.json
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"AWSTemplateFormatVersion": "2010-09-09",
|
| 3 |
+
"Description": "Deploy a service on AWS Fargate, hosted in a public subnet, and accessible via a public load balancer.",
|
| 4 |
+
"Parameters": {
|
| 5 |
+
"StackName": {
|
| 6 |
+
"Description": "The name of the parent Fargate networking stack that you created. Necessary to locate and reference resources created by that stack.",
|
| 7 |
+
"Type": "String",
|
| 8 |
+
"Default": "production"
|
| 9 |
+
},
|
| 10 |
+
"ServiceName": {
|
| 11 |
+
"Description": "A name for the service",
|
| 12 |
+
"Type": "String",
|
| 13 |
+
"Default": "nginx"
|
| 14 |
+
},
|
| 15 |
+
"ImageUrl": {
|
| 16 |
+
"Description": "The url of a docker image that contains the application process that will handle the traffic for this service",
|
| 17 |
+
"Type": "String",
|
| 18 |
+
"Default": "nginx"
|
| 19 |
+
},
|
| 20 |
+
"ContainerPort": {
|
| 21 |
+
"Description": "What port number the application inside the docker container is binding to",
|
| 22 |
+
"Type": "Number",
|
| 23 |
+
"Default": 80
|
| 24 |
+
},
|
| 25 |
+
"ContainerCpu": {
|
| 26 |
+
"Description": "How much CPU to give the container. 1024 is 1 CPU",
|
| 27 |
+
"Type": "Number",
|
| 28 |
+
"Default": 256
|
| 29 |
+
},
|
| 30 |
+
"ContainerMemory": {
|
| 31 |
+
"Description": "How much memory in megabytes to give the container",
|
| 32 |
+
"Type": "Number",
|
| 33 |
+
"Default": 512
|
| 34 |
+
},
|
| 35 |
+
"Path": {
|
| 36 |
+
"Description": "A path on the public load balancer that this service should be connected to. Use * to send all load balancer traffic to this service.",
|
| 37 |
+
"Type": "String",
|
| 38 |
+
"Default": "*"
|
| 39 |
+
},
|
| 40 |
+
"Priority": {
|
| 41 |
+
"Description": "The priority for the routing rule added to the load balancer. This only applies if your have multiple services which have been assigned to different paths on the load balancer.",
|
| 42 |
+
"Type": "Number",
|
| 43 |
+
"Default": 1
|
| 44 |
+
},
|
| 45 |
+
"DesiredCount": {
|
| 46 |
+
"Description": "How many copies of the service task to run",
|
| 47 |
+
"Type": "Number",
|
| 48 |
+
"Default": 2
|
| 49 |
+
},
|
| 50 |
+
"Role": {
|
| 51 |
+
"Description": "(Optional) An IAM role to give the service's containers if the code within needs to access other AWS resources like S3 buckets, DynamoDB tables, etc",
|
| 52 |
+
"Type": "String",
|
| 53 |
+
"Default": ""
|
| 54 |
+
}
|
| 55 |
+
},
|
| 56 |
+
"Conditions": {
|
| 57 |
+
"HasCustomRole": {
|
| 58 |
+
"Fn::Not": [
|
| 59 |
+
{
|
| 60 |
+
"Fn::Equals": [
|
| 61 |
+
{
|
| 62 |
+
"Ref": "Role"
|
| 63 |
+
},
|
| 64 |
+
""
|
| 65 |
+
]
|
| 66 |
+
}
|
| 67 |
+
]
|
| 68 |
+
}
|
| 69 |
+
},
|
| 70 |
+
"Resources": {
|
| 71 |
+
"TaskDefinition": {
|
| 72 |
+
"Type": "AWS::ECS::TaskDefinition",
|
| 73 |
+
"Properties": {
|
| 74 |
+
"Family": {
|
| 75 |
+
"Ref": "ServiceName"
|
| 76 |
+
},
|
| 77 |
+
"Cpu": {
|
| 78 |
+
"Ref": "ContainerCpu"
|
| 79 |
+
},
|
| 80 |
+
"Memory": {
|
| 81 |
+
"Ref": "ContainerMemory"
|
| 82 |
+
},
|
| 83 |
+
"NetworkMode": "awsvpc",
|
| 84 |
+
"RequiresCompatibilities": [
|
| 85 |
+
"FARGATE"
|
| 86 |
+
],
|
| 87 |
+
"ExecutionRoleArn": {
|
| 88 |
+
"Fn::ImportValue": {
|
| 89 |
+
"Fn::Join": [
|
| 90 |
+
":",
|
| 91 |
+
[
|
| 92 |
+
{
|
| 93 |
+
"Ref": "StackName"
|
| 94 |
+
},
|
| 95 |
+
"ECSTaskExecutionRole"
|
| 96 |
+
]
|
| 97 |
+
]
|
| 98 |
+
}
|
| 99 |
+
},
|
| 100 |
+
"TaskRoleArn": {
|
| 101 |
+
"Fn::If": [
|
| 102 |
+
"HasCustomRole",
|
| 103 |
+
{
|
| 104 |
+
"Ref": "Role"
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"Ref": "AWS::NoValue"
|
| 108 |
+
}
|
| 109 |
+
]
|
| 110 |
+
},
|
| 111 |
+
"ContainerDefinitions": [
|
| 112 |
+
{
|
| 113 |
+
"Name": {
|
| 114 |
+
"Ref": "ServiceName"
|
| 115 |
+
},
|
| 116 |
+
"Essential": true,
|
| 117 |
+
"Cpu": {
|
| 118 |
+
"Ref": "ContainerCpu"
|
| 119 |
+
},
|
| 120 |
+
"Memory": {
|
| 121 |
+
"Ref": "ContainerMemory"
|
| 122 |
+
},
|
| 123 |
+
"Image": {
|
| 124 |
+
"Ref": "ImageUrl"
|
| 125 |
+
},
|
| 126 |
+
"PortMappings": [
|
| 127 |
+
{
|
| 128 |
+
"ContainerPort": {
|
| 129 |
+
"Ref": "ContainerPort"
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
]
|
| 133 |
+
}
|
| 134 |
+
]
|
| 135 |
+
}
|
| 136 |
+
},
|
| 137 |
+
"Service": {
|
| 138 |
+
"Type": "AWS::ECS::Service",
|
| 139 |
+
"DependsOn": "LoadBalancerRule",
|
| 140 |
+
"Properties": {
|
| 141 |
+
"ServiceName": {
|
| 142 |
+
"Ref": "ServiceName"
|
| 143 |
+
},
|
| 144 |
+
"Cluster": {
|
| 145 |
+
"Fn::ImportValue": {
|
| 146 |
+
"Fn::Join": [
|
| 147 |
+
":",
|
| 148 |
+
[
|
| 149 |
+
{
|
| 150 |
+
"Ref": "StackName"
|
| 151 |
+
},
|
| 152 |
+
"ClusterName"
|
| 153 |
+
]
|
| 154 |
+
]
|
| 155 |
+
}
|
| 156 |
+
},
|
| 157 |
+
"LaunchType": "FARGATE",
|
| 158 |
+
"DeploymentConfiguration": {
|
| 159 |
+
"MaximumPercent": 200,
|
| 160 |
+
"MinimumHealthyPercent": 75
|
| 161 |
+
},
|
| 162 |
+
"DesiredCount": {
|
| 163 |
+
"Ref": "DesiredCount"
|
| 164 |
+
},
|
| 165 |
+
"NetworkConfiguration": {
|
| 166 |
+
"AwsvpcConfiguration": {
|
| 167 |
+
"AssignPublicIp": "ENABLED",
|
| 168 |
+
"SecurityGroups": [
|
| 169 |
+
{
|
| 170 |
+
"Fn::ImportValue": {
|
| 171 |
+
"Fn::Join": [
|
| 172 |
+
":",
|
| 173 |
+
[
|
| 174 |
+
{
|
| 175 |
+
"Ref": "StackName"
|
| 176 |
+
},
|
| 177 |
+
"FargateContainerSecurityGroup"
|
| 178 |
+
]
|
| 179 |
+
]
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
],
|
| 183 |
+
"Subnets": [
|
| 184 |
+
{
|
| 185 |
+
"Fn::ImportValue": {
|
| 186 |
+
"Fn::Join": [
|
| 187 |
+
":",
|
| 188 |
+
[
|
| 189 |
+
{
|
| 190 |
+
"Ref": "StackName"
|
| 191 |
+
},
|
| 192 |
+
"PublicSubnetOne"
|
| 193 |
+
]
|
| 194 |
+
]
|
| 195 |
+
}
|
| 196 |
+
},
|
| 197 |
+
{
|
| 198 |
+
"Fn::ImportValue": {
|
| 199 |
+
"Fn::Join": [
|
| 200 |
+
":",
|
| 201 |
+
[
|
| 202 |
+
{
|
| 203 |
+
"Ref": "StackName"
|
| 204 |
+
},
|
| 205 |
+
"PublicSubnetTwo"
|
| 206 |
+
]
|
| 207 |
+
]
|
| 208 |
+
}
|
| 209 |
+
}
|
| 210 |
+
]
|
| 211 |
+
}
|
| 212 |
+
},
|
| 213 |
+
"TaskDefinition": {
|
| 214 |
+
"Ref": "TaskDefinition"
|
| 215 |
+
},
|
| 216 |
+
"LoadBalancers": [
|
| 217 |
+
{
|
| 218 |
+
"ContainerName": {
|
| 219 |
+
"Ref": "ServiceName"
|
| 220 |
+
},
|
| 221 |
+
"ContainerPort": {
|
| 222 |
+
"Ref": "ContainerPort"
|
| 223 |
+
},
|
| 224 |
+
"TargetGroupArn": {
|
| 225 |
+
"Ref": "TargetGroup"
|
| 226 |
+
}
|
| 227 |
+
}
|
| 228 |
+
]
|
| 229 |
+
}
|
| 230 |
+
},
|
| 231 |
+
"TargetGroup": {
|
| 232 |
+
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
|
| 233 |
+
"Properties": {
|
| 234 |
+
"HealthCheckIntervalSeconds": 6,
|
| 235 |
+
"HealthCheckPath": "/",
|
| 236 |
+
"HealthCheckProtocol": "HTTP",
|
| 237 |
+
"HealthCheckTimeoutSeconds": 5,
|
| 238 |
+
"HealthyThresholdCount": 2,
|
| 239 |
+
"TargetType": "ip",
|
| 240 |
+
"Name": {
|
| 241 |
+
"Ref": "ServiceName"
|
| 242 |
+
},
|
| 243 |
+
"Port": {
|
| 244 |
+
"Ref": "ContainerPort"
|
| 245 |
+
},
|
| 246 |
+
"Protocol": "HTTP",
|
| 247 |
+
"UnhealthyThresholdCount": 2,
|
| 248 |
+
"VpcId": {
|
| 249 |
+
"Fn::ImportValue": {
|
| 250 |
+
"Fn::Join": [
|
| 251 |
+
":",
|
| 252 |
+
[
|
| 253 |
+
{
|
| 254 |
+
"Ref": "StackName"
|
| 255 |
+
},
|
| 256 |
+
"VPCId"
|
| 257 |
+
]
|
| 258 |
+
]
|
| 259 |
+
}
|
| 260 |
+
}
|
| 261 |
+
}
|
| 262 |
+
},
|
| 263 |
+
"LoadBalancerRule": {
|
| 264 |
+
"Type": "AWS::ElasticLoadBalancingV2::ListenerRule",
|
| 265 |
+
"Properties": {
|
| 266 |
+
"Actions": [
|
| 267 |
+
{
|
| 268 |
+
"TargetGroupArn": {
|
| 269 |
+
"Ref": "TargetGroup"
|
| 270 |
+
},
|
| 271 |
+
"Type": "forward"
|
| 272 |
+
}
|
| 273 |
+
],
|
| 274 |
+
"Conditions": [
|
| 275 |
+
{
|
| 276 |
+
"Field": "path-pattern",
|
| 277 |
+
"Values": [
|
| 278 |
+
{
|
| 279 |
+
"Ref": "Path"
|
| 280 |
+
}
|
| 281 |
+
]
|
| 282 |
+
}
|
| 283 |
+
],
|
| 284 |
+
"ListenerArn": {
|
| 285 |
+
"Fn::ImportValue": {
|
| 286 |
+
"Fn::Join": [
|
| 287 |
+
":",
|
| 288 |
+
[
|
| 289 |
+
{
|
| 290 |
+
"Ref": "StackName"
|
| 291 |
+
},
|
| 292 |
+
"PublicListener"
|
| 293 |
+
]
|
| 294 |
+
]
|
| 295 |
+
}
|
| 296 |
+
},
|
| 297 |
+
"Priority": {
|
| 298 |
+
"Ref": "Priority"
|
| 299 |
+
}
|
| 300 |
+
}
|
| 301 |
+
}
|
| 302 |
+
}
|
| 303 |
+
}
|
human_reference_dataset/aws-cloudformation-templates/ECS/FargateLaunchType/services/public-service.yaml
ADDED
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AWSTemplateFormatVersion: "2010-09-09"
|
| 2 |
+
|
| 3 |
+
Description: Deploy a service on AWS Fargate, hosted in a public subnet, and accessible via a public load balancer.
|
| 4 |
+
|
| 5 |
+
Parameters:
|
| 6 |
+
StackName:
|
| 7 |
+
Description: The name of the parent Fargate networking stack that you created. Necessary to locate and reference resources created by that stack.
|
| 8 |
+
Type: String
|
| 9 |
+
Default: production
|
| 10 |
+
|
| 11 |
+
ServiceName:
|
| 12 |
+
Description: A name for the service
|
| 13 |
+
Type: String
|
| 14 |
+
Default: nginx
|
| 15 |
+
|
| 16 |
+
ImageUrl:
|
| 17 |
+
Description: The url of a docker image that contains the application process that will handle the traffic for this service
|
| 18 |
+
Type: String
|
| 19 |
+
Default: nginx
|
| 20 |
+
|
| 21 |
+
ContainerPort:
|
| 22 |
+
Description: What port number the application inside the docker container is binding to
|
| 23 |
+
Type: Number
|
| 24 |
+
Default: 80
|
| 25 |
+
|
| 26 |
+
ContainerCpu:
|
| 27 |
+
Description: How much CPU to give the container. 1024 is 1 CPU
|
| 28 |
+
Type: Number
|
| 29 |
+
Default: 256
|
| 30 |
+
|
| 31 |
+
ContainerMemory:
|
| 32 |
+
Description: How much memory in megabytes to give the container
|
| 33 |
+
Type: Number
|
| 34 |
+
Default: 512
|
| 35 |
+
|
| 36 |
+
Path:
|
| 37 |
+
Description: A path on the public load balancer that this service should be connected to. Use * to send all load balancer traffic to this service.
|
| 38 |
+
Type: String
|
| 39 |
+
Default: '*'
|
| 40 |
+
|
| 41 |
+
Priority:
|
| 42 |
+
Description: The priority for the routing rule added to the load balancer. This only applies if your have multiple services which have been assigned to different paths on the load balancer.
|
| 43 |
+
Type: Number
|
| 44 |
+
Default: 1
|
| 45 |
+
|
| 46 |
+
DesiredCount:
|
| 47 |
+
Description: How many copies of the service task to run
|
| 48 |
+
Type: Number
|
| 49 |
+
Default: 2
|
| 50 |
+
|
| 51 |
+
Role:
|
| 52 |
+
Description: (Optional) An IAM role to give the service's containers if the code within needs to access other AWS resources like S3 buckets, DynamoDB tables, etc
|
| 53 |
+
Type: String
|
| 54 |
+
Default: ""
|
| 55 |
+
|
| 56 |
+
Conditions:
|
| 57 |
+
HasCustomRole: !Not
|
| 58 |
+
- !Equals
|
| 59 |
+
- !Ref Role
|
| 60 |
+
- ""
|
| 61 |
+
|
| 62 |
+
Resources:
|
| 63 |
+
|
| 64 |
+
# The task definition. This is a simple metadata description of what
|
| 65 |
+
# container to run, and what resource requirements it has.
|
| 66 |
+
TaskDefinition:
|
| 67 |
+
Type: AWS::ECS::TaskDefinition
|
| 68 |
+
Properties:
|
| 69 |
+
Family: !Ref ServiceName
|
| 70 |
+
Cpu: !Ref ContainerCpu
|
| 71 |
+
Memory: !Ref ContainerMemory
|
| 72 |
+
NetworkMode: awsvpc
|
| 73 |
+
RequiresCompatibilities:
|
| 74 |
+
- FARGATE
|
| 75 |
+
ExecutionRoleArn: !ImportValue
|
| 76 |
+
Fn::Join:
|
| 77 |
+
- ':'
|
| 78 |
+
- - !Ref StackName
|
| 79 |
+
- ECSTaskExecutionRole
|
| 80 |
+
TaskRoleArn: !If
|
| 81 |
+
- HasCustomRole
|
| 82 |
+
- !Ref Role
|
| 83 |
+
- !Ref AWS::NoValue
|
| 84 |
+
ContainerDefinitions:
|
| 85 |
+
- Name: !Ref ServiceName
|
| 86 |
+
Essential: true
|
| 87 |
+
Cpu: !Ref ContainerCpu
|
| 88 |
+
Memory: !Ref ContainerMemory
|
| 89 |
+
Image: !Ref ImageUrl
|
| 90 |
+
PortMappings:
|
| 91 |
+
- ContainerPort: !Ref ContainerPort
|
| 92 |
+
|
| 93 |
+
# The service. The service is a resource which allows you to run multiple
|
| 94 |
+
# copies of a type of task, and gather up their logs and metrics, as well
|
| 95 |
+
# as monitor the number of running tasks and replace any that have crashed
|
| 96 |
+
Service:
|
| 97 |
+
Type: AWS::ECS::Service
|
| 98 |
+
DependsOn: LoadBalancerRule
|
| 99 |
+
Properties:
|
| 100 |
+
ServiceName: !Ref ServiceName
|
| 101 |
+
Cluster: !ImportValue
|
| 102 |
+
Fn::Join:
|
| 103 |
+
- ':'
|
| 104 |
+
- - !Ref StackName
|
| 105 |
+
- ClusterName
|
| 106 |
+
LaunchType: FARGATE
|
| 107 |
+
DeploymentConfiguration:
|
| 108 |
+
MaximumPercent: 200
|
| 109 |
+
MinimumHealthyPercent: 75
|
| 110 |
+
DesiredCount: !Ref DesiredCount
|
| 111 |
+
NetworkConfiguration:
|
| 112 |
+
AwsvpcConfiguration:
|
| 113 |
+
AssignPublicIp: ENABLED
|
| 114 |
+
SecurityGroups:
|
| 115 |
+
- !ImportValue
|
| 116 |
+
Fn::Join:
|
| 117 |
+
- ':'
|
| 118 |
+
- - !Ref StackName
|
| 119 |
+
- FargateContainerSecurityGroup
|
| 120 |
+
Subnets:
|
| 121 |
+
- !ImportValue
|
| 122 |
+
Fn::Join:
|
| 123 |
+
- ':'
|
| 124 |
+
- - !Ref StackName
|
| 125 |
+
- PublicSubnetOne
|
| 126 |
+
- !ImportValue
|
| 127 |
+
Fn::Join:
|
| 128 |
+
- ':'
|
| 129 |
+
- - !Ref StackName
|
| 130 |
+
- PublicSubnetTwo
|
| 131 |
+
TaskDefinition: !Ref TaskDefinition
|
| 132 |
+
LoadBalancers:
|
| 133 |
+
- ContainerName: !Ref ServiceName
|
| 134 |
+
ContainerPort: !Ref ContainerPort
|
| 135 |
+
TargetGroupArn: !Ref TargetGroup
|
| 136 |
+
|
| 137 |
+
# A target group. This is used for keeping track of all the tasks, and
|
| 138 |
+
# what IP addresses / port numbers they have. You can query it yourself,
|
| 139 |
+
# to use the addresses yourself, but most often this target group is just
|
| 140 |
+
# connected to an application load balancer, or network load balancer, so
|
| 141 |
+
# it can automatically distribute traffic across all the targets.
|
| 142 |
+
TargetGroup:
|
| 143 |
+
Type: AWS::ElasticLoadBalancingV2::TargetGroup
|
| 144 |
+
Properties:
|
| 145 |
+
HealthCheckIntervalSeconds: 6
|
| 146 |
+
HealthCheckPath: /
|
| 147 |
+
HealthCheckProtocol: HTTP
|
| 148 |
+
HealthCheckTimeoutSeconds: 5
|
| 149 |
+
HealthyThresholdCount: 2
|
| 150 |
+
TargetType: ip
|
| 151 |
+
Name: !Ref ServiceName
|
| 152 |
+
Port: !Ref ContainerPort
|
| 153 |
+
Protocol: HTTP
|
| 154 |
+
UnhealthyThresholdCount: 2
|
| 155 |
+
VpcId: !ImportValue
|
| 156 |
+
Fn::Join:
|
| 157 |
+
- ':'
|
| 158 |
+
- - !Ref StackName
|
| 159 |
+
- VPCId
|
| 160 |
+
|
| 161 |
+
# Create a rule on the load balancer for routing traffic to the target group
|
| 162 |
+
LoadBalancerRule:
|
| 163 |
+
Type: AWS::ElasticLoadBalancingV2::ListenerRule
|
| 164 |
+
Properties:
|
| 165 |
+
Actions:
|
| 166 |
+
- TargetGroupArn: !Ref TargetGroup
|
| 167 |
+
Type: forward
|
| 168 |
+
Conditions:
|
| 169 |
+
- Field: path-pattern
|
| 170 |
+
Values:
|
| 171 |
+
- !Ref Path
|
| 172 |
+
ListenerArn: !ImportValue
|
| 173 |
+
Fn::Join:
|
| 174 |
+
- ':'
|
| 175 |
+
- - !Ref StackName
|
| 176 |
+
- PublicListener
|
| 177 |
+
Priority: !Ref Priority
|
human_reference_dataset/aws-cloudformation-templates/ECS/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Deploy containers using Elastic Container Service and CloudFormation
|
| 2 |
+
|
| 3 |
+
__Note: For more modern CloudFormation examples, see [Containers on AWS
|
| 4 |
+
patterns for
|
| 5 |
+
CloudFormation](https://containersonaws.com/pattern/?tool=cloudformation). This
|
| 6 |
+
large collection of patterns has CloudFormation snippets and entire reference
|
| 7 |
+
applications that you can deploy for a variety of different real world use
|
| 8 |
+
cases.__
|
| 9 |
+
|
| 10 |
+
Several combinations of template are available in this folder. You can deploy
|
| 11 |
+
containers with two different networking approaches:
|
| 12 |
+
|
| 13 |
+
- Public VPC subnet with direct internet access
|
| 14 |
+
- Private VPC subnet without direct internet access
|
| 15 |
+
|
| 16 |
+
You can choose two different options for hosting the containers:
|
| 17 |
+
|
| 18 |
+
- AWS Fargate for hands-off container execution without managing EC2 instances
|
| 19 |
+
- Self managed cluster of EC2 hosts for control over instance type, or to use
|
| 20 |
+
reserved or spot instances for savings
|
| 21 |
+
|
| 22 |
+
You can also choose between two different ways of sending traffic to the
|
| 23 |
+
container:
|
| 24 |
+
|
| 25 |
+
- A public facing load balancer that accepts traffic from anyone on the
|
| 26 |
+
internet (ideal for a public facing web service)
|
| 27 |
+
- A private, internal load balancer that only accepts traffic from other
|
| 28 |
+
containers in the cluster (ideal for a private, internal service).
|
| 29 |
+
|
| 30 |
+
To use these templates launch a cluster template for the launch type and
|
| 31 |
+
networking stack that you want. Then launch a service template for each service
|
| 32 |
+
you want to run in the cluster. When launching a service template its important
|
| 33 |
+
to make sure the "StackName" value is filled in with the same name that you
|
| 34 |
+
selected for the name of your cluster stack.
|
| 35 |
+
|
| 36 |
+
Each of the service stacks has default values prefilled for launching a simple
|
| 37 |
+
Nginx container, but can be adjusted to launch your own container.
|
| 38 |
+
|
| 39 |
+
## Fully Public Container
|
| 40 |
+
|
| 41 |
+

|
| 43 |
+
|
| 44 |
+
This architecture deploys your container into its own VPC, inside a public
|
| 45 |
+
facing network subnet. The containers are hosted with direct access to the
|
| 46 |
+
internet, and they are also accessible to other clients on the internet via a
|
| 47 |
+
public facing application load balancer.
|
| 48 |
+
|
| 49 |
+
### Run in AWS Fargate
|
| 50 |
+
|
| 51 |
+
1. Launch the [fully public](FargateLaunchType/clusters/public-vpc.yml) or the
|
| 52 |
+
[public + private](FargateLaunchType/clusters/private-vpc.yml) cluster template
|
| 53 |
+
2. Launch the [public facing service
|
| 54 |
+
template](FargateLaunchType/services/public-service.yml).
|
| 55 |
+
|
| 56 |
+
### Run on EC2
|
| 57 |
+
|
| 58 |
+
1. Launch the [fully public](EC2LaunchType/clusters/public-vpc.yml) or the
|
| 59 |
+
[public + private](EC2LaunchType/clusters/private-vpc.yml) cluster template
|
| 60 |
+
2. Launch the [public facing service
|
| 61 |
+
template](EC2LaunchType/services/public-service.yml).
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
## Publicly Exposed Service with Private Networking
|
| 68 |
+
|
| 69 |
+

|
| 71 |
+
|
| 72 |
+
This architecture deploys your container into a private subnet. The containers
|
| 73 |
+
do not have direct internet access, or a public IP address. Their outbound
|
| 74 |
+
traffic must go out via a NAT gateway, and receipients of requests from the
|
| 75 |
+
containers will just see the request orginating from the IP address of the NAT
|
| 76 |
+
gateway. However, inbound traffic from the public can still reach the
|
| 77 |
+
containers because there is a public facing load balancer that can proxy
|
| 78 |
+
traffic from the public to the containers in the private subnet.
|
| 79 |
+
|
| 80 |
+
### Run in AWS Fargate
|
| 81 |
+
|
| 82 |
+
1. Launch the [public + private](FargateLaunchType/clusters/private-vpc.yml)
|
| 83 |
+
cluster template
|
| 84 |
+
2. Launch the [public facing, private subnet service
|
| 85 |
+
template](FargateLaunchType/services/private-subnet-public-service.yml).
|
| 86 |
+
|
| 87 |
+
### Run on EC2
|
| 88 |
+
|
| 89 |
+
1. Launch the [public + private](EC2LaunchType/clusters/private-vpc.yml)
|
| 90 |
+
cluster template
|
| 91 |
+
2. Launch the [public facing, private subnet service
|
| 92 |
+
template](EC2LaunchType/services/public-service.yml).
|
| 93 |
+
|
| 94 |
+
## Internal Service with Private Networking
|
| 95 |
+
|
| 96 |
+

|
| 98 |
+
|
| 99 |
+
This architecture deploys your container in a private subnet, with no direct
|
| 100 |
+
internet access. Outbound traffic from your container goes through an NAT
|
| 101 |
+
gateway, and receipients of requests from the containers will just see the
|
| 102 |
+
request orginating from the IP address of the NAT gateway. There is no acess to
|
| 103 |
+
the container for the public. Instead there is a private, internal load
|
| 104 |
+
balancer that only accepts traffic from other containers in the cluster. This
|
| 105 |
+
is ideal for an internal service that is used by other services, but should not
|
| 106 |
+
be used directly by the public.
|
| 107 |
+
|
| 108 |
+
### Run in AWS Fargate
|
| 109 |
+
|
| 110 |
+
1. Launch the [public + private](FargateLaunchType/clusters/private-vpc.yml)
|
| 111 |
+
cluster template
|
| 112 |
+
2. Launch the [private service, private subnet
|
| 113 |
+
template](FargateLaunchType/services/private-subnet-private-service.yml).
|
| 114 |
+
|
| 115 |
+
### Run on EC2
|
| 116 |
+
|
| 117 |
+
1. Launch the [public + private](EC2LaunchType/clusters/private-vpc.yml)
|
| 118 |
+
cluster template
|
| 119 |
+
2. Launch the [private service, private subnet
|
| 120 |
+
template](EC2LaunchType/services/private-service.yml).
|
| 121 |
+
|
human_reference_dataset/aws-cloudformation-templates/ECS/images/private-task-private-loadbalancer.svg
ADDED
|
|
human_reference_dataset/aws-cloudformation-templates/ECS/images/private-task-public-loadbalancer.svg
ADDED
|
|
human_reference_dataset/aws-cloudformation-templates/ECS/images/private-task.png
ADDED
|
Git LFS Details
|
human_reference_dataset/aws-cloudformation-templates/ECS/images/public-task-public-loadbalancer.svg
ADDED
|
|
human_reference_dataset/aws-cloudformation-templates/ECS/images/public-task.png
ADDED
|
Git LFS Details
|