-
Notifications
You must be signed in to change notification settings - Fork 0
/
battlemon-api-service.yml
181 lines (164 loc) · 6.13 KB
/
battlemon-api-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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
AWSTemplateFormatVersion: 2010-09-09
Description: BattlemonAPI layer
Parameters:
BattlemonAPIBackendECRRepositoryURI:
Description: Battlemon backend API repository's URI of Amazon Container Registry
Type: String
Default: "987666890397.dkr.ecr.eu-central-1.amazonaws.com/battlemon-api:latest"
BattlemonAPIGRPCPort:
Description: GRPC port for Battlemon API backend
Type: Number
Default: 3001
BattlemonAPILogLevel:
Description: Log level for BattlemonAPI service
Type: String
Default: info
BattlemonAPIServeSwagger:
Description: Serve Swagger
Type: String
Default: true
BattlemonAPIAccessKeyContractAddress:
Description: AccessKey contract address
Type: String
Default: '0x715418aD6e0CE69a5FfA72Eb34ECc04d712Cd106'
BattlemonAPIGemsContractAddress:
Description: Gems contract address
Type: String
Default: '0xeAe2c6b00C57DC313b1B6d46094fE032Fe1740e5'
BattlemonAPIReferralContractAddress:
Description: Referral contract address
Type: String
Default: '0x62c99ae88D1048d65aFF47a97f976c8F174B5Ee5'
BattlemonAPIBlockchainProviderUrl:
Description: Blockchain provider url
Type: String
Default: 'https://linea-goerli.infura.io/v3/'
Resources:
BattlemonAPISecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Enable HTTP access via ALB on port 3000 by default, but can be overwritten by BattlemonAPIBackendPort parameter
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: !ImportValue BattlemonAPIBackendPort
ToPort: !ImportValue BattlemonAPIBackendPort
CidrIp: !ImportValue BattlemonVpcCIDR
- IpProtocol: tcp
FromPort: !Ref BattlemonAPIGRPCPort
ToPort: !Ref BattlemonAPIGRPCPort
CidrIp: !ImportValue BattlemonVpcCIDR
VpcId: !ImportValue BattlemonVpcId
Tags:
- Key: Name
Value: BattlemonAPISecurityGroup
# BattlemonAPI service
BattlemonAPIBackendService:
Type: AWS::ECS::Service
Properties:
ServiceName: BattlemonAPIBackendService
ServiceRegistries:
- RegistryArn: !ImportValue BattlemonAPIDiscoveryService
Cluster: !ImportValue BattlemonBackendCluster
TaskDefinition: !Ref BattlemonApiTaskDefinition
DesiredCount: 2
LaunchType: FARGATE
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: DISABLED
Subnets: [ !ImportValue BattlemonPrivateSubnet1, !ImportValue BattlemonPrivateSubnet2 ]
SecurityGroups: [ !Ref BattlemonAPISecurityGroup ]
LoadBalancers:
- ContainerName: BattlemonAPIBackend
ContainerPort: !ImportValue BattlemonAPIBackendPort
TargetGroupArn: !ImportValue ALBTargetGroup
Tags:
- Key: Name
Value: BattlemonAPIBackendService
BattlemonAPIBackendLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: /aws/ecs/battlemon-api-backend
RetentionInDays: 7
BattlemonApiTaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
RequiresCompatibilities: [ FARGATE ]
Family: BattlemonAPIBackend
NetworkMode: awsvpc
ExecutionRoleArn: !ImportValue BattlemonTaskExecutionRoleArn
ContainerDefinitions:
- Name: BattlemonAPIBackend
Image: !Ref BattlemonAPIBackendECRRepositoryURI
Essential: true
PortMappings:
- ContainerPort: !ImportValue BattlemonAPIBackendPort
Protocol: tcp
Environment:
- Name: PORT
Value: !ImportValue BattlemonAPIBackendPort
- Name: GRPC_PORT
Value: !Ref BattlemonAPIGRPCPort
- Name: DATABASE_HOST
Value: !ImportValue BattlemonDatabaseInstanceEndpointAddress
- Name: DATABASE_USER
Value: !ImportValue BattlemonDatabaseUsername
- Name: DATABASE_NAME
Value: !ImportValue BattlemonDatabaseName
- Name: DATABASE_PORT
Value: !ImportValue BattlemonDatabasePort
- Name: LOG_LEVEL
Value: !Ref BattlemonAPILogLevel
- Name: SERVE_SWAGGER
Value: !Ref BattlemonAPIServeSwagger
- Name: ACCESS_KEY_CONTRACT_ADDRESS
Value: !Ref BattlemonAPIAccessKeyContractAddress
- Name: GEMS_CONTRACT_ADDRESS
Value: !Ref BattlemonAPIGemsContractAddress
- Name: REFERRAL_CONTRACT_ADDRESS
Value: !Ref BattlemonAPIReferralContractAddress
- Name: BLOCKCHAIN_PROVIDER_URL
Value: !Ref BattlemonAPIBlockchainProviderUrl
Secrets:
- Name: DATABASE_PASSWORD
ValueFrom: !ImportValue BattlemonDatabasePassword
- Name: JWT_SECRET
ValueFrom: !ImportValue BattlemonAPIJWTSecret
- Name: SERVER_PRIVATE_KEY
ValueFrom: !ImportValue BattlemonAPIServerPrivateKey
- Name: BLOCKCHAIN_PROVIDER_API_KEY
ValueFrom: !ImportValue BattlemonAPIBlockchainProviderApiKey
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref BattlemonAPIBackendLogGroup
awslogs-region: !Ref 'AWS::Region'
awslogs-stream-prefix: ecs
Cpu: 256
Memory: 0.5 GB
RuntimePlatform:
CpuArchitecture: ARM64
OperatingSystemFamily: LINUX
Tags:
- Key: Name
Value: BattlemonAPIBackendTaskDefinition
Outputs:
BattlemonAPIGRPCPort:
Value: !Ref BattlemonAPIGRPCPort
Export:
Name: BattlemonAPIGRPCPort
BattlemonAPIBlockchainProviderUrl:
Value: !Ref BattlemonAPIBlockchainProviderUrl
Export:
Name: BattlemonAPIBlockchainProviderUrl
BattlemonAPIAccessKeyContractAddress:
Value: !Ref BattlemonAPIAccessKeyContractAddress
Export:
Name: BattlemonAPIAccessKeyContractAddress
BattlemonAPIGemsContractAddress:
Value: !Ref BattlemonAPIGemsContractAddress
Export:
Name: BattlemonAPIGemsContractAddress
BattlemonAPIReferralContractAddress:
Value: !Ref BattlemonAPIReferralContractAddress
Export:
Name: BattlemonAPIReferralContractAddress