Skip to content

Resource: awsAutoscalingAttachment

Provides an Auto Scaling Attachment resource.

\~> NOTE on Auto Scaling Groups and ASG Attachments: Terraform currently provides both a standalone awsAutoscalingAttachment resource (describing an ASG attached to an ELB or ALB), and an awsAutoscalingGroup with loadBalancers and targetGroupArns defined in-line. These two methods are not mutually-exclusive. If awsAutoscalingAttachment resources are used, either alone or with inline loadBalancers or targetGroupArns, the awsAutoscalingGroup resource must be configured to ignore changes to the loadBalancers and targetGroupArns arguments within a lifecycle configuration block.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.autoscalingAttachment.AutoscalingAttachment(
  this,
  "asg_attachment_bar",
  {
    autoscalingGroupName: "${aws_autoscaling_group.asg.id}",
    elb: "${aws_elb.bar.id}",
  }
);
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.autoscalingAttachment.AutoscalingAttachment(
  this,
  "asg_attachment_bar",
  {
    autoscalingGroupName: "${aws_autoscaling_group.asg.id}",
    lbTargetGroupArn: "${aws_lb_target_group.test.arn}",
  }
);

With An AutoScaling Group Resource

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsAutoscalingGroupAsg = new aws.autoscalingGroup.AutoscalingGroup(
  this,
  "asg",
  {}
);
awsAutoscalingGroupAsg.addOverride("lifecycle", [
  {
    ignore_changes: ["${load_balancers}", "${target_group_arns}"],
  },
]);
new aws.autoscalingAttachment.AutoscalingAttachment(
  this,
  "asg_attachment_bar",
  {
    autoscalingGroupName: awsAutoscalingGroupAsg.id,
    elb: "${aws_elb.test.id}",
  }
);

Argument Reference

The following arguments are supported:

  • autoscalingGroupName - (Required) Name of ASG to associate with the ELB.
  • elb - (Optional) Name of the ELB.
  • albTargetGroupArn - (Optional, Deprecated use lbTargetGroupArn instead) ARN of an ALB Target Group.
  • lbTargetGroupArn - (Optional) ARN of a load balancer target group.

Attributes Reference

No additional attributes are exported.