(autoscaling): Property 'attachToApplicationTargetGroup' does not exist on type 'IAutoScalingGroup'
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
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)
⚠️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.