Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create an EC2 instance from a Launch Configuration via command line interface or API?

Amazon AWS allows you to create Launch Configurations to be used with auto scaling groups. However how can you spin-up up an individual instance instance based on a launch configuration?

like image 619
adrian7 Avatar asked Oct 07 '14 17:10

adrian7


People also ask

Which does Amazon EC2 use for access to the command line interface?

You can access the features of Amazon Elastic Compute Cloud (Amazon EC2) using the AWS Command Line Interface (AWS CLI).

Do EC2 instances come with AWS CLI?

Launch an EC2 instance using an Amazon Linux Amazon Machine Image (AMI). Linux AMIs come with the AWS CLI installed.


1 Answers

You will have to create an ASG in order to create an instance from a launch config, following is the command. Change min, max and desired capacities as per your needs. Refer the doc.

aws autoscaling create-auto-scaling-group --auto-scaling-group-name my-auto-scaling-group --launch-configuration-name my-launch-config --min-size 0 --max-size 1 --desired-capacity 1 --vpc-zone-identifier subnet-41767929c

once the instance is launched you can detached the instance and delete the ASG.

aws autoscaling detach-instances --instance-ids i-2a2d8978 --auto-scaling-group-name my-asg --should-decrement-desired-capacity

to delete the ASG

aws autoscaling delete-auto-scaling-group --auto-scaling-group-name my-asg

However pls check your requirement again and this is NOT a recommended way to do things in AWS. Use a service like Cloud formation instead.

like image 145
Upul Doluweera Avatar answered Sep 18 '22 13:09

Upul Doluweera