Attach Subnet to AutoScaleGroup #4604
Labels
@aws-cdk/aws-autoscaling
Related to Amazon EC2 Auto Scaling
feature-request
A feature should be added or improved.
in-progress
This issue is being actively worked on.
AWS AutoScaling Groups is a tool to provision EC2 instances for various workload patterns. AWS CDK allows developers to specify
vpcSubnets
subnets selection (meaning existing one) but do not allow to create Subnet and ASG within same stack.Use Case
This issue is continuation of use-cases defined in #4586. There is a need to provision backend infrastructure within own subnet. There is a stack that deploys extension to existing VPC.
It is impossible to associate ASG to subnets. There is only one ugly work around - you have to declare the subnets in own stack and then import to ASG using
subnetGroupName
. However, workaround defeats purpose of layers design (see #4586).Proposed Solution
Option 1: brute-force design
Easy to design, implement, impacts only AutoScalingGroup. I do not like it.
Enhance the property type
vpcSubnets: SubnetSelection | string[]
. Then modify following code to either pick subnets id as-is or query data from vpc.https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts#L488
Option 2: support explicit subnet definition with SubnetSelection
Give possibility to explicitly declare subnets ID as part of the subnet selection query
then support this attribute at
VPC.selectSubnets(...)
, which acts roughly as transform function which mapsISubnet
toSelectedSubnets
.I'd recommend a second approach, it allows to support subnet assignment to other classes as well. Not only too ASG.
This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: