Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ecsPatterns.ApplicationLoadBalancedFargateService: targetGroup cannot be declared. #30151

Closed
ZenergyBryson opened this issue May 10, 2024 · 3 comments
Labels
@aws-cdk/aws-ecs-patterns Related to ecs-patterns library closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. documentation This is a problem with documentation. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@ZenergyBryson
Copy link

Describe the issue

This is my first submission, so try not to rake me over the coals too harshly if this is a bug and not a documentation issue.

In the documentation, targetGroup shows up in the Properties table, along with loadBalancer, certificate, and other properties that CAN be assigned. I have verified I'm using CDK v2.141.0 on my local, and am reading the docs for 2.141.0, but when I try to run diff, synth, or deploy I get this:
error TS2345: Argument of type '{ loadBalancer: cdk.aws_elasticloadbalancingv2.IApplicationLoadBalancer; targetGroup: cdk.aws_elasticloadbalancingv2.IApplicationTargetGroup; publicLoadBalancer: false; ... 14 more ...; openListener: false; }' is not assignable to parameter of type 'ApplicationLoadBalancedFargateServiceProps'.
Object literal may only specify known properties, and 'targetGroup' does not exist in type 'ApplicationLoadBalancedFargateServiceProps'.
179 targetGroup: jenkinsTargetGroup,

Links

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs_patterns.ApplicationLoadBalancedFargateService.html

@ZenergyBryson ZenergyBryson added documentation This is a problem with documentation. needs-triage This issue or PR still needs to be triaged. labels May 10, 2024
@github-actions github-actions bot added the @aws-cdk/aws-ecs-patterns Related to ecs-patterns library label May 10, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels May 10, 2024
@khushail
Copy link
Contributor

khushail commented May 10, 2024

Hi @ZenergyBryson , thanks for reaching out. I tested the above scenario with this code and it worked fine for me. Sharing the code and snippet of synthesized template with mentioned properties as well -

   const cluster= new ecs.Cluster(this, 'Cluster', {
      vpc: new ec2.Vpc(this, 'Vpc', {
        maxAzs: 2,
        subnetConfiguration: [
          {
            name: 'public',
            subnetType: ec2.SubnetType.PUBLIC,
          },
          {
            name: 'private',
            subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS
          },
        ],
      }),
    }); 

    const loadBalancedFargateService = new ecsPatterns.ApplicationLoadBalancedFargateService(this, 'Service', {
      cluster,
      memoryLimitMiB: 1024,
      desiredCount: 1,
      cpu: 512,
      taskImageOptions: {
        image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
      },
      taskSubnets: {
        subnets: [ec2.Subnet.fromSubnetId(this, 'subnet', 'VpcISOLATEDSubnet1Subnet80F07FA0')],
      },
      loadBalancerName: 'application-lb-name',
    });

    const listner = loadBalancedFargateService.loadBalancer.addListener('listener', {
      port: 80,
    });

    const targetGroup = listner.addTargets('Fleet', { port: 80 });
"ServiceLBPublicListener46709EAA": {
   "Type": "AWS::ElasticLoadBalancingV2::Listener",
   "Properties": {
    "DefaultActions": [
     {
      "TargetGroupArn": {
       "Ref": "ServiceLBPublicListenerECSGroup0CC8688C"
      },
      "Type": "forward"
     }
    ],
    "LoadBalancerArn": {
     "Ref": "ServiceLBE9A1ADBC"
    },
    "Port": 80,
    "Protocol": "HTTP"
   },
   "Metadata": {
    "aws:cdk:path": "PatternIssueStack/Service/LB/PublicListener/Resource"
   }
  },
  "ServiceLBPublicListenerECSGroup0CC8688C": {
   "Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
   "Properties": {
    "Port": 80,
    "Protocol": "HTTP",
    "TargetGroupAttributes": [
     {
      "Key": "stickiness.enabled",
      "Value": "false"
     }
    ],
    "TargetType": "ip",
    "VpcId": {
     "Ref": "Vpc8378EB38"
    }

I am not sue why you are facing this error. Plese feel free to correct me if you are trying to do something else . Also Could you please share the minimum reproducible code.

@khushail khushail added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels May 10, 2024
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 13, 2024
@github-actions github-actions bot added closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels May 18, 2024
@aws-cdk-automation
Copy link
Collaborator

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
@aws-cdk/aws-ecs-patterns Related to ecs-patterns library closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. documentation This is a problem with documentation. 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

3 participants