-
Notifications
You must be signed in to change notification settings - Fork 101
/
api.yml
93 lines (84 loc) · 2.36 KB
/
api.yml
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
AWSTemplateFormatVersion: '2010-09-09'
Description: container on ecs cluster
Resources:
Task:
Type: AWS::ECS::TaskDefinition
Properties:
Family: apis
Cpu: 256
Memory: 512
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
ExecutionRoleArn: !ImportValue ECSTaskExecutionRole
ContainerDefinitions:
- Name: booksapi
Image: 532497595666.dkr.ecr.us-west-2.amazonaws.com/books-api:v1
Cpu: 256
Memory: 512
PortMappings:
- ContainerPort: 4567
Protocol: tcp
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: 'apis'
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: 'books-api'
Service:
Type: AWS::ECS::Service
DependsOn: ListenerRule
Properties:
ServiceName: books-service
TaskDefinition: !Ref Task
Cluster: !ImportValue 'ECSCluster'
LaunchType: FARGATE
DesiredCount: 2
DeploymentConfiguration:
MaximumPercent: 200
MinimumHealthyPercent: 70
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: ENABLED
Subnets:
- !ImportValue Subnet1
- !ImportValue Subnet2
SecurityGroups:
- !ImportValue ContainerSecurityGroup
LoadBalancers:
- ContainerName: booksapi
ContainerPort: 4567
TargetGroupArn: !Ref TargetGroup
TargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
Name: books-tg
VpcId: !ImportValue VPC
Port: 80
Protocol: HTTP
Matcher:
HttpCode: 200-299
HealthCheckIntervalSeconds: 10
HealthCheckPath: /stat
HealthCheckProtocol: HTTP
HealthCheckTimeoutSeconds: 5
HealthyThresholdCount: 10
TargetType: ip
ListenerRule:
Type: AWS::ElasticLoadBalancingV2::ListenerRule
Properties:
ListenerArn: !ImportValue Listener
Priority: 2
Conditions:
- Field: path-pattern
Values:
- /api/book*
Actions:
- TargetGroupArn: !Ref TargetGroup
Type: forward
Outputs:
ApiEndpoint:
Description: Books API Endpoint
Value: !Join ['', ['http://', !ImportValue DomainName, '/api/books']]
Export:
Name: 'BooksApiEndpoint'