1
votes

When creating an EC2 autoscaling group, it's possible to specify multiple subnets in different availability zones, so that the autoscaling group can start instances where there is capacity.

Is there a way to do a similar thing when using EC2 launch templates to launch instances from scratch? I would like to be able to specify a list of subnets, and then ask EC2 to launch an instance based on my launch template in whichever subnet has spare capacity for the type of instance in question.

However, because launch templates seem to require you to specify network interfaces, I can't see an obvious way of achieving this.

1
Could you please clarify the use case? Why would you use a launch template in this case? Maybe you need a Beanstalk type of service or even a CloudFormation template?Fabio Manzano
I'm launching GPU instances on demands to do some calculations. I don't really care which of my subnets they end up in, as long as they run.samfrances
What about AWS Batch? aws.amazon.com/batchFabio Manzano

1 Answers

1
votes

Go via te auto-scaling menu rather than via the launch template menu.

When building an EC2 auto-scaling group, you can specify to use an EC2 instance. But you can also specify to use a launch configuration or launch template. The last case is what you seem to need.

In the auto-scaling group you select the option to launch from an existing launch template. So make sure to have the required launch template first. In the auto-scaling group options you can also specify the list of subnets to use in your auto-scaling group, as long as they are in the same VPN.

Link to the documentation here: https://docs.aws.amazon.com/autoscaling/ec2/userguide/create-asg-launch-template.html