-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmaster.yaml
96 lines (82 loc) · 3.93 KB
/
master.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Description: >
This template deploys a VPC with public and private subnets spread across
two Availabilty Zones. It deploys an Internet Gateway and a pair of NAT
Gateways, with the relevant routes in each of the subnets.
It then deploys an ECS cluster distributed across multiple Availability Zones.
Finally, it deploys a pair of example ECS services from containers published in
Amazon EC2 Container Registry (Amazon ECR).
Last Modified: 7th February 2018
Author: Paul Lewis <pjlewis@amazon.co.uk>
Resources:
VPC:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://s3.amazonaws.com/fargate-refarch-cloudformation/infrastructure/vpc.yaml
Parameters:
EnvironmentName: !Ref AWS::StackName
PrivateSubnet1CIDR: 10.180.24.0/21
PrivateSubnet2CIDR: 10.180.32.0/21
PublicSubnet1CIDR: 10.180.8.0/21
PublicSubnet2CIDR: 10.180.16.0/21
VpcCIDR: 10.180.0.0/16
SecurityGroups:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://s3.amazonaws.com/fargate-refarch-cloudformation/infrastructure/security-groups.yaml
Parameters:
EnvironmentName: !Ref AWS::StackName
VPC: !GetAtt VPC.Outputs.VPC
ALB:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://s3.amazonaws.com/fargate-refarch-cloudformation/infrastructure/load-balancers.yaml
Parameters:
EnvironmentName: !Ref AWS::StackName
SecurityGroup: !GetAtt SecurityGroups.Outputs.LoadBalancerSecurityGroup
Subnets: !GetAtt VPC.Outputs.PublicSubnets
VPC: !GetAtt VPC.Outputs.VPC
ECS:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://s3.amazonaws.com/fargate-refarch-cloudformation/infrastructure/ecs-cluster.yaml
Parameters:
EnvironmentName: !Ref AWS::StackName
VPC: !GetAtt VPC.Outputs.VPC
ProductService:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://s3.amazonaws.com/fargate-refarch-cloudformation/services/product-service/service.yaml
Parameters:
Cluster: !GetAtt ECS.Outputs.Cluster
DesiredCount: 2
ECSTaskExecutionRole: !GetAtt ECS.Outputs.ECSTaskExecutionRole
Listener: !GetAtt ALB.Outputs.Listener
Path: /products
SecurityGroup: !GetAtt SecurityGroups.Outputs.ECSHostSecurityGroup
Subnets: !GetAtt VPC.Outputs.PrivateSubnets
TaskCpu: 512
TaskMemory: 1024
VPC: !GetAtt VPC.Outputs.VPC
WebsiteService:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://s3.amazonaws.com/fargate-refarch-cloudformation/services/website-service/service.yaml
Parameters:
Cluster: !GetAtt ECS.Outputs.Cluster
DesiredCount: 2
ECSTaskExecutionRole: !GetAtt ECS.Outputs.ECSTaskExecutionRole
Listener: !GetAtt ALB.Outputs.Listener
Path: /
ProductServiceUrl: !Join [ "/", [ !GetAtt ALB.Outputs.LoadBalancerUrl, "products" ]]
SecurityGroup: !GetAtt SecurityGroups.Outputs.ECSHostSecurityGroup
Subnets: !GetAtt VPC.Outputs.PrivateSubnets
TaskCpu: 256
TaskMemory: 512
VPC: !GetAtt VPC.Outputs.VPC
Outputs:
ProductServiceUrl:
Description: The URL endpoint for the product service
Value: !Join [ "/", [ !GetAtt ALB.Outputs.LoadBalancerUrl, "products" ]]
WebsiteServiceUrl:
Description: The URL endpoint for the website service
Value: !Join ["", [ !GetAtt ALB.Outputs.LoadBalancerUrl, "/" ]]