I'm trying to get the assigned public IP address of an ECS service but I couldn't find a way to reference it.
const backendService = new ecs.FargateService(
this,
"EcsBackendAppService",
{
cluster: backendCluster,
taskDefinition: backendTaskDefinition,
desiredCount: 1,
assignPublicIp: true,
securityGroups: [vpcDefaultSecurityGroup],
serviceName: "backend",
}
);
Is it possible to get the public IP in CDK?
No, it is not possible, because the public IP address will be different for each task that ECS launches - if the task is restarted for any reason, the IP will change.