Abhay Singh Book a discovery call

February 11, 2023 · 1 min read

Automating EC2 Instance Creation with AWS CLI Script – A Step-by-Step Guide

AWS EC2 Mastering, interview preparation, essential questions, answers, components, scaling, security, monitoring.
aws ec2

Here is an AWS CLI script that creates an EC2 instance with a subnet in the “us-east-1a” availability zone, in a security group, and with an Ubuntu 20.04 t2.small instance type:

aws ec2 run-instances \
  --image-id ami-0c55b159cbfafe1f0 \
  --instance-type t2.small \
  --key-name MyKeyPair \
  --security-group-ids sg-49d61617 \
  --subnet-id subnet-049df61146f127901 \
  --placement "AvailabilityZone=us-east-1a" \

ALSO READ  10 Secret Features of AWS EC2 You Must Know Today!