-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-service.yml
125 lines (116 loc) · 3.86 KB
/
test-service.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
AWSTemplateFormatVersion: 2010-09-09
Description: Test layer
Parameters:
TestBackendECRRepositoryURI:
Description: Test backend repository's URI of Amazon Container Registry
Type: String
Default: "987666890397.dkr.ecr.eu-central-1.amazonaws.com/web3-auth-server-rust:latest"
TestBackendPort:
Description: Test backend port
Type: Number
Default: 8000
Resources:
# Backend cluster
TestSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Enable HTTP access via ALB on port 8000 by default, but can be overwritten by TestBackendPort parameter
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: !Ref TestBackendPort
ToPort: !Ref TestBackendPort
CidrIp: !ImportValue BattlemonVpcCIDR
VpcId: !ImportValue BattlemonVpcId
Tags:
- Key: Name
Value: TestSecurityGroup
TestBackendCluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: TestBackendCluster
CapacityProviders:
- FARGATE
- FARGATE_SPOT
DefaultCapacityProviderStrategy:
- CapacityProvider: FARGATE
Weight: 1
- CapacityProvider: FARGATE_SPOT
Weight: 1
ClusterSettings:
- Name: containerInsights
Value: enabled
Tags:
- Key: Name
Value: TestBackendCluster
# Test service
TestBackendService:
Type: AWS::ECS::Service
Properties:
ServiceName: TestBackendService
Cluster: !Ref TestBackendCluster
TaskDefinition: !Ref TestTaskDefinition
DesiredCount: 2
LaunchType: FARGATE
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: DISABLED
Subnets: [ !ImportValue BattlemonPrivateSubnet1, !ImportValue BattlemonPrivateSubnet2 ]
SecurityGroups: [ !Ref TestSecurityGroup ]
LoadBalancers:
- ContainerName: TestBackend
ContainerPort: !Ref TestBackendPort
TargetGroupArn: !ImportValue ALBTargetGroup
Tags:
- Key: Name
Value: TestBackendService
TestBackendLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: /aws/ecs/test-backend
RetentionInDays: 7
TestTaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
RequiresCompatibilities: [ FARGATE ]
Family: TestBackend
NetworkMode: awsvpc
ExecutionRoleArn: !ImportValue BattlemonTaskExecutionRoleArn
ContainerDefinitions:
- Name: TestBackend
Image: !Ref TestBackendECRRepositoryURI
Essential: true
PortMappings:
- ContainerPort: !Ref TestBackendPort
Protocol: tcp
Environment:
- Name: APP_APP__HOST
Value: "0.0.0.0"
- Name: APP_APP__PORT
Value: !Ref TestBackendPort
- Name: APP_DB__HOST
Value: !ImportValue BattlemonDatabaseInstanceEndpointAddress
- Name: APP_DB__USERNAME
Value: !ImportValue BattlemonDatabaseUsername
- Name: APP_DB__DB_NAME
Value: !ImportValue BattlemonDatabaseName
- Name: APP_DB__PORT
Value: !ImportValue BattlemonDatabasePort
Secrets:
- Name: APP_DB__PASSWORD
ValueFrom: !ImportValue BattlemonDatabasePassword
- Name: APP_SECRETS__KEY_PAIR
ValueFrom: 'arn:aws:secretsmanager:eu-central-1:987666890397:secret:test-secret-irLTyi'
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref TestBackendLogGroup
awslogs-region: !Ref 'AWS::Region'
awslogs-stream-prefix: ecs
Cpu: 256
Memory: 0.5 GB
RuntimePlatform:
CpuArchitecture: X86_64
OperatingSystemFamily: LINUX
Tags:
- Key: Name
Value: TestBackendTaskDefinition