Skip to content

Commit b89b3a5

Browse files
v2.4
1 parent 4041e1f commit b89b3a5

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

infra/ecs-services.yml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AWSTemplateFormatVersion: '2010-09-09'
2-
Description: ECS Services + ALB for Ecommerce Microservices
2+
Description: ECS Services + ALB + CloudWatch Logs for Ecommerce Microservices
33

44
Parameters:
55
VPCId:
@@ -17,6 +17,26 @@ Parameters:
1717

1818
Resources:
1919

20+
# --------- CloudWatch Log Groups ---------
21+
UserLogGroup:
22+
Type: AWS::Logs::LogGroup
23+
Properties:
24+
LogGroupName: /ecs/user-service
25+
RetentionInDays: 7
26+
27+
ProductLogGroup:
28+
Type: AWS::Logs::LogGroup
29+
Properties:
30+
LogGroupName: /ecs/product-service
31+
RetentionInDays: 7
32+
33+
OrderLogGroup:
34+
Type: AWS::Logs::LogGroup
35+
Properties:
36+
LogGroupName: /ecs/order-service
37+
RetentionInDays: 7
38+
39+
# --------- ALB and Networking ---------
2040
ALBSecurityGroup:
2141
Type: AWS::EC2::SecurityGroup
2242
Properties:
@@ -27,9 +47,6 @@ Resources:
2747
FromPort: 80
2848
ToPort: 80
2949
CidrIp: 0.0.0.0/0
30-
Tags:
31-
- Key: Name
32-
Value: alb-sg
3350

3451
ALB:
3552
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
@@ -52,6 +69,7 @@ Resources:
5269
ContentType: text/plain
5370
MessageBody: Not Found
5471

72+
# --------- Target Groups ---------
5573
UserTG:
5674
Type: AWS::ElasticLoadBalancingV2::TargetGroup
5775
Properties:
@@ -79,6 +97,7 @@ Resources:
7997
TargetType: ip
8098
HealthCheckPath: /order
8199

100+
# --------- Listener Rules ---------
82101
UserRule:
83102
Type: AWS::ElasticLoadBalancingV2::ListenerRule
84103
Properties:
@@ -115,11 +134,13 @@ Resources:
115134
- Type: forward
116135
TargetGroupArn: !Ref OrderTG
117136

137+
# --------- ECS Services ---------
118138
UserService:
119139
Type: AWS::ECS::Service
120140
DependsOn:
121141
- UserRule
122142
- ALBListener
143+
- UserLogGroup
123144
Properties:
124145
Cluster: ecommerce-cluster
125146
DesiredCount: 1
@@ -139,6 +160,7 @@ Resources:
139160
DependsOn:
140161
- ProductRule
141162
- ALBListener
163+
- ProductLogGroup
142164
Properties:
143165
Cluster: ecommerce-cluster
144166
DesiredCount: 1
@@ -158,6 +180,7 @@ Resources:
158180
DependsOn:
159181
- OrderRule
160182
- ALBListener
183+
- OrderLogGroup
161184
Properties:
162185
Cluster: ecommerce-cluster
163186
DesiredCount: 1

0 commit comments

Comments
 (0)