Skip to content

Commit 15182d8

Browse files
authored
fix: ecs rule in target group (#126)
* fix: ecs rule in target group * fix: serialize extra param with base64
1 parent d5362a4 commit 15182d8

File tree

2 files changed

+13
-39
lines changed

2 files changed

+13
-39
lines changed

src/emd/cfn/ecs/template.yaml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ Resources:
307307
DependsOn:
308308
- ECSTaskExecutionRole
309309
- EC2Role
310-
- ServiceTargetGroup
311310
- UpdateCapacityProvider
312311
Properties:
313312
ServiceName: !Sub '${AWS::StackName}'
@@ -331,10 +330,6 @@ Resources:
331330
MinimumHealthyPercent: 75
332331
DesiredCount: !Ref DesiredCount
333332
TaskDefinition: !Ref TaskDefinition
334-
LoadBalancers:
335-
- ContainerName: !Sub '${AWS::StackName}'
336-
ContainerPort: !Ref ContainerPort
337-
TargetGroupArn: !Ref ServiceTargetGroup
338333
ServiceConnectConfiguration:
339334
Enabled: true
340335
Namespace: emd-service-connect-namespace
@@ -363,32 +358,6 @@ Resources:
363358
SourceSecurityGroupId: !Ref APIRouterSecurityGroup
364359
Description: Allow traffic from API router service to model service
365360

366-
ServiceTargetGroup:
367-
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
368-
Properties:
369-
HealthCheckIntervalSeconds: 120
370-
HealthCheckPath: /ping
371-
HealthCheckProtocol: HTTP
372-
HealthCheckTimeoutSeconds: 5
373-
HealthyThresholdCount: 2
374-
TargetType: ip
375-
Port: !Ref ContainerPort
376-
Protocol: HTTP
377-
Matcher:
378-
HttpCode: 200-404
379-
UnhealthyThresholdCount: 10
380-
VpcId: !Ref VPCID
381-
TargetGroupAttributes:
382-
- Key: deregistration_delay.timeout_seconds
383-
Value: 0
384-
ServiceIngressfromLoadBalancer:
385-
Type: 'AWS::EC2::SecurityGroupIngress'
386-
Properties:
387-
Description: Ingress from the public ALB
388-
GroupId: !Ref ServiceSecurityGroup
389-
IpProtocol: -1
390-
SourceSecurityGroupId: !Ref PublicLoadBalancerSecurityGroup
391-
392361
ForceApiRouterDeployment:
393362
Type: Custom::ForceApiRouterDeployment
394363
DependsOn: Service
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
import json
22
import argparse
3-
4-
JSON_DOUBLE_QUOTE_REPLACE = '<!>'
5-
JSON_SINGLE_QUOTE_REPLACE = '<*>'
3+
import base64
64

75

86
def load_extra_params(string):
9-
string = string.replace(JSON_DOUBLE_QUOTE_REPLACE,'"').replace(JSON_SINGLE_QUOTE_REPLACE,"'")
107
try:
11-
return json.loads(string)
12-
except json.JSONDecodeError:
8+
# Decode the base64 string back to JSON string
9+
json_bytes = base64.b64decode(string.encode('utf-8'))
10+
json_str = json_bytes.decode('utf-8')
11+
return json.loads(json_str)
12+
except (base64.binascii.Error, UnicodeDecodeError, json.JSONDecodeError):
1313
raise argparse.ArgumentTypeError(f"Invalid dictionary format: {string}")
1414

15-
def dump_extra_params(d:dict):
16-
return json.dumps(d).replace("'", JSON_SINGLE_QUOTE_REPLACE).replace('"', JSON_DOUBLE_QUOTE_REPLACE)
15+
16+
def dump_extra_params(d: dict):
17+
# Convert dict to JSON string, then encode to base64
18+
json_str = json.dumps(d)
19+
json_bytes = json_str.encode('utf-8')
20+
base64_bytes = base64.b64encode(json_bytes)
21+
return base64_bytes.decode('utf-8')

0 commit comments

Comments
 (0)