Skip to content
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-cdk-lib/aws-ecs-patterns): (use exist VPC for ApplicationLoadBalancedFargateService error) #26660

Closed
JiaTingYefei opened this issue Aug 7, 2023 · 2 comments
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@JiaTingYefei
Copy link

Describe the bug

When I tried use an exist VPC to create ECS cluster and ApplicationLoadBalancedFargateService, I got an error:
Error: There are no 'Public' subnet groups in this VPC. Available types: Deprecated_Private_NAT,Private,Deprecated_Private

The VPC has 2 public subnet and 2 private subnet.

Code below:

this.vpc = ec2.Vpc.fromVpcAttributes(this, `Vpc-carbon-mgt`, {
      vpcId: 'vpc-0a2d4755',
      availabilityZones: Fn.getAzs(),
      privateSubnetIds: 'subnet-042872beda,subnet-0f86502'.split(',')
})

this.cluster = new Cluster(this, 'ECSCluster', {
        vpc: this.vpc,
        containerInsights: true,
      });


 const metabaseService = new ApplicationLoadBalancedFargateService(this, 'MetaBase-Service', {
            platformVersion: FargatePlatformVersion.VERSION1_4,
            cluster: props.cluster,
            // taskSubnets: {subnets: [ec2.Subnet.fromSubnetId(this, '01af7912cecd', 'subnet-01af794ecd'),ec2.Subnet.fromSubnetId(this, '0e1284c734f069', 'subnet-0e1282f4f069')]},
            cpu: 1024,
            memoryLimitMiB: 4096,
            taskImageOptions: {
                containerPort: 3000,
                // image: ContainerImage.fromEcrRepository(repository, IdpConfig.ECR_METABASE_IMAGE_TAG),
                image: ContainerImage.fromRegistry('metabase/metabase:latest'),
                environment: {
                    'MB_DB_TYPE': 'mysql',
                },
            },
            desiredCount: 1,
            circuitBreaker: { rollback: true },
            healthCheckGracePeriod: Duration.minutes(3),
            listenerPort: IdpConfig.ALB_PORT
        });

Expected Behavior

Create ApplicationLoadBalancedFargateService in an exist VPC.

Current Behavior

Can not create ApplicationLoadBalancedFargateService in an exist VPC.

Reproduction Steps

NA

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.90.0

Framework Version

No response

Node.js Version

v18.12.1

OS

Amazon Linux2

Language

Typescript

Language Version

No response

Other information

No response

@JiaTingYefei JiaTingYefei added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 7, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Aug 7, 2023
@peterwoodworth
Copy link
Contributor

You aren't defining the public subnets in fromVpcAttributes, so it thinks there are no public subnets. Either include them in this import, or use fromLookup() instead to actually fetch the information from your account

@peterwoodworth peterwoodworth added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. bug This issue is a bug. labels Aug 7, 2023
@github-actions
Copy link

github-actions bot commented Aug 7, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants