Adds final version with new prompt
This commit is contained in:
@@ -6,33 +6,42 @@ import ecr
|
||||
import json
|
||||
|
||||
def deploy_app(config_ecs_app, app_ecs_cluster, alb_security_group, app_load_balancer_arn):
|
||||
lb_config = config_ecs_app["lb_config"]
|
||||
target_group = aws.lb.TargetGroup(f"app-target-group-{lb_config['listener_port']}",
|
||||
port=lb_config["target_port"],
|
||||
protocol="HTTP",
|
||||
vpc_id=config.network["vpc_id"],
|
||||
target_type="ip",
|
||||
health_check=aws.lb.TargetGroupHealthCheckArgs(
|
||||
path="/", # TODO if it doesn't work, can use /docs for fastapi
|
||||
protocol="HTTP",
|
||||
port="traffic-port",
|
||||
healthy_threshold=2,
|
||||
unhealthy_threshold=2,
|
||||
timeout=5,
|
||||
interval=30,
|
||||
matcher="200-499",
|
||||
),
|
||||
)
|
||||
aws.lb.Listener(f"app-listener-{lb_config['listener_port']}",
|
||||
load_balancer_arn=app_load_balancer_arn,
|
||||
port=lb_config["listener_port"],
|
||||
protocol="HTTP",
|
||||
default_actions=[aws.lb.ListenerDefaultActionArgs(
|
||||
type="forward",
|
||||
target_group_arn=target_group.arn,
|
||||
)],
|
||||
)
|
||||
# target_groups.append(target_group)
|
||||
lb_configs = config_ecs_app["lb_configs"]
|
||||
target_groups = []
|
||||
load_balancers = []
|
||||
|
||||
for lb_config in lb_configs:
|
||||
tg = aws.lb.TargetGroup(f"app-target-group-{lb_config['listener_port']}",
|
||||
port=lb_config["target_port"],
|
||||
protocol="HTTP",
|
||||
vpc_id=config.network["vpc_id"],
|
||||
target_type="ip",
|
||||
health_check=aws.lb.TargetGroupHealthCheckArgs(
|
||||
path="/",
|
||||
protocol="HTTP",
|
||||
port="traffic-port",
|
||||
healthy_threshold=2,
|
||||
unhealthy_threshold=2,
|
||||
timeout=5,
|
||||
interval=30,
|
||||
matcher="200-499",
|
||||
),
|
||||
)
|
||||
aws.lb.Listener(f"app-listener-{lb_config['listener_port']}",
|
||||
load_balancer_arn=app_load_balancer_arn,
|
||||
port=lb_config["listener_port"],
|
||||
protocol="HTTP",
|
||||
default_actions=[aws.lb.ListenerDefaultActionArgs(
|
||||
type="forward",
|
||||
target_group_arn=tg.arn,
|
||||
)],
|
||||
)
|
||||
target_groups.append(tg)
|
||||
load_balancers.append(aws.ecs.ServiceLoadBalancerArgs(
|
||||
target_group_arn=tg.arn,
|
||||
container_name=f"{config.project_name}-{config_ecs_app['task_name']}-{config.environment}-service",
|
||||
container_port=lb_config["target_port"],
|
||||
))
|
||||
|
||||
# Build and Push ECR
|
||||
# ecr_repos = ecr.create_ecr_repo(config_ecs_app['ecr_repo_name'])
|
||||
@@ -79,12 +88,11 @@ def deploy_app(config_ecs_app, app_ecs_cluster, alb_security_group, app_load_bal
|
||||
"cpu": 0,
|
||||
"portMappings": [
|
||||
{
|
||||
"name": "api",
|
||||
"containerPort": lb_config["container_port"],
|
||||
"hostPort": lb_config["target_port"],
|
||||
"name": lb_cfg["name"],
|
||||
"containerPort": lb_cfg["container_port"],
|
||||
"hostPort": lb_cfg["target_port"],
|
||||
"protocol": "tcp",
|
||||
}
|
||||
# } for lb_config_item in lb_configs
|
||||
} for lb_cfg in lb_configs
|
||||
],
|
||||
"essential": True,
|
||||
"logConfiguration": {
|
||||
@@ -135,12 +143,6 @@ def deploy_app(config_ecs_app, app_ecs_cluster, alb_security_group, app_load_bal
|
||||
)
|
||||
|
||||
# ECS Service Setup
|
||||
load_balancer = aws.ecs.ServiceLoadBalancerArgs(
|
||||
target_group_arn=target_group.arn,
|
||||
container_name=f"{config.project_name}-{config_ecs_app['task_name']}-{config.environment}-service",
|
||||
container_port=lb_config["target_port"],
|
||||
)
|
||||
|
||||
app_service = aws.ecs.Service(f"{config.project_name}-{config_ecs_app['task_name']}-service",
|
||||
cluster=app_ecs_cluster.arn,
|
||||
task_definition=app_task_definition.arn,
|
||||
@@ -151,7 +153,7 @@ def deploy_app(config_ecs_app, app_ecs_cluster, alb_security_group, app_load_bal
|
||||
security_groups=[app_ecs_security_group.id],
|
||||
subnets=config.network["ecs_subnet_ids"],
|
||||
),
|
||||
load_balancers=[load_balancer],
|
||||
load_balancers=load_balancers,
|
||||
scheduling_strategy="REPLICA",
|
||||
service_connect_configuration=aws.ecs.ServiceServiceConnectConfigurationArgs(
|
||||
enabled=True,
|
||||
|
||||
Reference in New Issue
Block a user