How to create a VM/Instance in AWS via CLI

Install AWS CLI

curl "https://d1vvhvl2y92vvt.cloudfront.net/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux-mac.html

Configure AWS CLI

aws configure

https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html

Create a key-pair

aws ec2  create-key-pair --key-name MyVMKey

The output is an ASCII version of the private key and key fingerprint. You need to save the key to a file.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html

Create a security group

aws ec2 create-security-group --group-name MySecurityGroup --description "My security group"

Configure security group to allow SSH traffic


aws ec2 authorize-security-group-ingress --group-name MySecurityGroup --protocol tcp --port 22 --cidr 0.0.0.0/0

Create an instance

aws ec2 run-instances --image-id ami-061eb2b23f9f8839c --key-name Nasohi-VM-Key --count 1 --instance-type t2.micro --security-group-ids sg-0cc957a1de76c844c 

https://docs.aws.amazon.com/cli/latest/userguide/cli-services-ec2-instances.html

Login to VM/Instance

ssh -i "MyVMKey.pem" ubuntu@ec2-10-20-30-40.ap-southeast-1.compute.amazonaws.com




Komentar

Postingan populer dari blog ini

Pembahasan IT Network Systems Administration Module A DNS (Forward Zone, Reverse Zone, CNAME, MX, Split View)

Cara restart / stop windows service (services.msc) dengan bat / cmd

How to convert VMDK to OVA