dazzling-kilobyte-32990
05/13/2021, 12:45 PMbrave-planet-10645
05/13/2021, 12:54 PMconst task = new awsx.ecs.FargateTaskDefinition("td", {
containers: {
nginx: {
image: "nginx",
portMappings: [{protocol: "tcp", containerPort: 80, hostPort: 80}]
}
}
})
dazzling-kilobyte-32990
05/13/2021, 12:56 PMconst alb = new awsx.lb.ApplicationLoadBalancer("backend-ecs-alb");
const listener = alb.createListener("backend-ecs-listener", { port: 80 });
const nginx = new awsx.ecs.FargateService("backend-ecs", {
taskDefinitionArgs: {
containers: {
backend: {
image: image,
memory: 128,
portMappings: [listener],
},
},
},
desiredCount: 2,
});
FargateTaskDefinition
for this?brave-planet-10645
05/13/2021, 1:07 PMconst alb = new awsx.lb.ApplicationLoadBalancer("backend-ecs-alb");
const listener = alb.createListener("backend-ecs-listener", { port: 80 });
const nginx = new awsx.ecs.FargateService("backend-ecs", {
taskDefinitionArgs: {
containers: {
backend: {
image: image,
memory: 128,
portMappings: [{protocol: "tcp", containerPort: 80, hostPort: 80}],
},
},
},
desiredCount: 2,
});
dazzling-kilobyte-32990
05/13/2021, 1:08 PMbrave-planet-10645
05/13/2021, 1:09 PMcontainerPort
from 80
to 5000
dazzling-kilobyte-32990
05/13/2021, 1:12 PMportMappings: [listener],
from the taskDefinition, how does the LB get bound to the ECS task?import * as awsx from "@pulumi/awsx";
const image = awsx.ecr.buildAndPushImage("backend-ecs", {
context: "./app",
});
const cluster = new awsx.ecs.Cluster("backend-ecs-cluster");
const alb = new awsx.elasticloadbalancingv2.ApplicationLoadBalancer("backend-ecs-alb", {
external: true,
securityGroups: cluster.securityGroups
});
const atg = alb.createTargetGroup("backend-ecs-tg", {
port: 5000,
protocol: "HTTP",
deregistrationDelay: 0
});
const web = atg.createListener("web", {
port: 80
});
const appService = new awsx.ecs.FargateService("backend-ecs-fargateservice", {
cluster,
taskDefinitionArgs: {
container: {
image: image,
portMappings: [web],
},
},
desiredCount: 1,
});
export const url = web.endpoint.hostname;
brave-planet-10645
05/13/2021, 1:56 PMconst lb = new awsx.lb.NetworkTargetGroup("nginx", { port: 5000 })
.createListener("listener", {port: 80});
dazzling-kilobyte-32990
05/13/2021, 1:57 PM