-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws-ecs-patterns: Cannot create a public/private LoadBalancedFargateService in a VPC with multiple public/private subnets #3626
Comments
@realharry can you add what your vpc definition looks like? (appropriately redacted - remove any confidential info, such as account IDs or internal project names, etc.) |
I was able to successfully create a stack using: const vpc = new ec2.Vpc(stack, 'MyVpc', { maxAzs: 2 });
const cluster = new ecs.Cluster(stack, 'Cluster', { vpc });
new ecs_patterns.LoadBalancedFargateService(stack, "FargateService", {
cluster,
image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
cpu: 1024,
memoryLimitMiB: 4096,
desiredCount: 2,
publicLoadBalancer: false,
containerPort: 443,
loadBalancerType: LoadBalancerType.APPLICATION,
}); |
Hi @pkandasamy91 Yes, it does work in some cases. As you can see from my repeatedly updated title :) I couldn't figure out/pinpoint what exactly was causing the failure. Here's my VPC setup: private createVpc = (id: string, cidr: string): ec2.Vpc => {
const vpc = new ec2.Vpc(this, id, {
cidr,
maxAzs: 2,
enableDnsSupport: true,
enableDnsHostnames: true,
subnetConfiguration: [
{
cidrMask: 22,
name: 'Frontend',
subnetType: ec2.SubnetType.PUBLIC,
},
{
cidrMask: 22,
name: 'Backend',
subnetType: ec2.SubnetType.PRIVATE,
},
{
cidrMask: 26,
name: 'Vpn',
subnetType: ec2.SubnetType.PRIVATE,
},
{
cidrMask: 26,
name: 'Database',
subnetType: ec2.SubnetType.ISOLATED,
}
],
});
return vpc;
}; where cider range is, for example, 10.1.0.0/16. Thanks! |
I create a cluster as follows, if relevant: this.vpc = ec2.Vpc.fromLookup(this, vpcId, { vpcId }); private createFargateCluster = (id: string): ecs.Cluster => {
const cluster = new ecs.Cluster(this, id, {
clusterName: id,
vpc: this.vpc
});
return cluster;
}; This is in a separate stack from VPC. (that is, an existing vpc stack is used when we create fargate clusters.) |
OK, I figured out. It turns out you cannot create a Updated the issue title accordingly. |
Hey @realharry, thanks for updating the issue. When setting the An application load balancer can point to multiple With the provided VPC |
Hi @sonofachamp thanks for the update/confirmation. I think that the CDK API, e.g., LoadBalancedFargateService, providing a way to select particular subnets for the ELB can solve this issue. |
@realharry I've opened a separate issue to track that as a feature request as we determine the best way to expose that configuration. |
I'm submitting a ...
What is the current behavior?
If the current behavior is a πͺ²bugπͺ²: Please provide the steps to reproduce
Create a vpc with multiple subnets, and try to create a
LoadBalancedFargateService
. For example,When doing
cdk deploy
, I get the following error:It should work.
I'd like to use high-level
ecsPatterns
constructs.Please tell us about your environment:
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)
Related tickets:
The text was updated successfully, but these errors were encountered: