jolly-fall-57688
11/16/2022, 3:55 PM# Build the Fargate cluster
cluster = aws.ecs.Cluster("dev-fargate-cluster")
# Define the Fargate service settings and configuration
service = awsx.ecs.FargateService("my_fargate_cluster_service",
cluster = cluster.arn,
network_configuration = aws.ecs.ServiceNetworkConfigurationArgs(
subnets = vpc.private_subnet_ids,
security_groups = [sg.id]
),
task_definition_args = awsx.ecs.FargateServiceTaskDefinitionArgs(
containers = {
"react": awsx.ecs.TaskDefinitionContainerDefinitionArgs(
image = img.image_uri,
memory = 50,
cpu = 128,
essential = True,
port_mappings = [awsx.ecs.TaskDefinitionPortMappingArgs(
container_port = 80,
host_port = 80,
protocol = "tcp",
target_group = alb.default_target_group
)]
)
}
)
)
billowy-army-68599
11/16/2022, 3:57 PMjolly-fall-57688
11/16/2022, 3:58 PMbillowy-army-68599
11/16/2022, 4:00 PMjolly-fall-57688
11/16/2022, 4:03 PM# Reduces # of NatGateways to save $$$ NOT intended for production
nat_gateways=awsx.ec2.NatGatewayConfigurationArgs(
strategy = awsx.ec2.NatGatewayStrategy.SINGLE
quaint-hydrogen-7228
11/16/2022, 4:40 PMjolly-fall-57688
11/16/2022, 4:50 PMdescription = "Allow web traffic for cluster",
vpc_id = vpc.vpc_id,
ingress = [aws.ec2.SecurityGroupIngressArgs(
description = "Allow port 80 inbound from Internet",
from_port = 80,
to_port = 80,
protocol = "tcp",
cidr_blocks = ["0.0.0.0/0"]
)],
egress = [aws.ec2.SecurityGroupEgressArgs(
description = "Allow all traffic out from cluster",
from_port = 0,
to_port = 0,
protocol = "tcp",
cidr_blocks = ["0.0.0.0/0"]
)]