? How to create an EC2 from CLI?
Tudor Ionut Elian
?Senior Software Engineer | ??3x Certified AWS (latest - SysOps Administrator | ?? Ready for a DevOps Role | #?? C# Enthusiast
Don't be scared of CLI, let's do it:
? First, let's see what we need first:
?an image id (can be taken from UI or if you use terraform, you can use the data resource type. Not the case now)
?the instance type (we will use the t2.micro
?key-name (you need to create it)
?security-group-id (we will use default one, it's only for learning)
aws ec2 create-key-pair --key-name MyKeyPair --query 'KeyMaterial'
aws ec2 describe-security-groups
aws ec2 run-instances --image-id ami-0de02246788e4a354 --instance-type t2.micro --key-name MyKeyPair --security-group-ids sg-0868ea57c075e6db1
aws ec2 create-tags --resources i-0184fbaa8ba5aacdb --tags Key=Name,Value=devops-ec2