Closed fogfish closed 5 years ago
You seem to be asking for selection of individual subnets, is that right?
Yes, for selection of individual subnets, which are created within same template as ASG. What do you think about option 2? I do have a strong feeling that it suites other use-cases.
I love option 2. I need the case where I want to launch an ASG in only one zone. This could be solved with the same approach.
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 :rocket: Feature Request