aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

(autoscaling): Property 'attachToApplicationTargetGroup' does not exist on type 'IAutoScalingGroup'

Open andybirenzi opened this issue 5 years ago • 2 comments

I'm unable to add an autoscaling group to an ELB Targetgroup. Any thoughts? I keep getting

Property 'attachToApplicationTargetGroup' does not exist on type 'IAutoScalingGroup' or Argument of type 'IAutoScalingGroup' is not assignable to parameter of type 'IApplicationLoadBalancerTarget'. Property 'attachToApplicationTargetGroup' is missing in type 'IAutoScalingGroup' but required in type 'IApplicationLoadBalancerTarget'.ts(2345)

Reproduction Steps

import an existing ASG using AutoScalingGroup.fromAutoScalingGroupName(this,this.deployEnv+"-"+this.stackName,this.autoScalingName);

then create an application targetGroup:

const targets= new ApplicationTargetGroup (this,"entsys-"+this.deployEnv+"-standalone-TG",{ targetType:TargetType.INSTANCE, stickinessCookieDuration:Duration.days(1), healthCheck: { port:"8443", healthyHttpCodes:"302", path:"/mypath"

  },
  port:443,
  protocol:ApplicationProtocol.HTTPS,
  vpc:entsysVPC
})

Then add your ASG to the application target group:

targets.addTarget(autoScalingGroup); //this will display an error. I tried different ways with no luck. I think this might a bug but please correct me if I'm wrong

Environment

  • CDK CLI Version :
  • Framework Version: 1.78.0
  • Node.js Version:
  • OS :
  • Language (Version): Typescript

Other


This is :bug: Bug Report

andybirenzi avatar Dec 13 '20 04:12 andybirenzi

This is because attaching the scaling policy requires mutating the auto scaling group, which is not possible in an Imported autoscaling group (it is not managed by your cdk application). There more details in this issue: https://github.com/aws/aws-cdk/issues/9790 (see the comment https://github.com/aws/aws-cdk/issues/9790#issuecomment-676818726)

NetaNir avatar Dec 14 '20 16:12 NetaNir

⚠️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.

github-actions[bot] avatar Dec 14 '20 20:12 github-actions[bot]