-
VPC Pricing. It's free!
-
VPCs and CIDR routing.
- Setting up VPC
- Create a VPC:
aws ec2 create-vpc --cidr-block 50.10.0.0/16. For help see create-vpc. - Allow DNS support:
aws ec2 modify-vpc-attribute --vpc-id [vpc id here] --enable-dns-support "{\"Value\":true}". See link. - Create a subnet:
aws ec2 create-subnet --vpc-id [vpc id here] --cidr-block 50.10.1.0/24. For help see link. - Allow auto public IP:
aws ec2 modify-subnet-attribute --subnet-id [subnet-#####] --map-public-ip-on-launch. See link. - Create internet gateway:
aws ec2 create-internet-gateway. Attach internet gateway to vpc:aws ec2 attach-internet-gateway --internet-gateway-id igw-3853575d --vpc-id [vpc id here]. See link and link. - Link route table to internet gateway:
aws ec2 create-route --route-table-id [id] --destination-cidr-block 0.0.0.0/0 --gateway-id [id]. See link.
- Create security group.
- Create group:
aws ec2 create-security-group --group-name [group name] --description "any text" --vpc-id [vpc-#####]. - Open ports: (SSH)
aws ec2 authorize-security-group-ingress --group-id [group id] --protocol tcp --port 22 --cidr 0.0.0.0/0, (HTTPS)aws ec2 authorize-security-group-ingress --group-id [group id] --protocol tcp --port 443 --cidr 0.0.0.0/0, (8888)aws ec2 authorize-security-group-ingress --group-id [group id] --protocol tcp --port 8888 --cidr 0.0.0.0/0. See link.
- Launch an instance.
- Without volume specs
aws ec2 run-instances --image-id [ami-e5b6788e] --count 1 --instance-type t1.micro --key-name [keyname] --security-group-ids [security group id] --subnet-id [subnet-#####]. - Or with volume specs:
aws ec2 run-instances --image-id [ami-e5b6788e] --count 1 --instance-type t1.micro --key-name [name] --security-group-ids [ids] --subnet-id [ids] --b ""DeviceName"="/dev/sda1","Ebs"={"VolumeSize"=30,"DeleteOnTermination"=true,"VolumeType"="gp2"}".
-
Get the instance IP:
aws ec2 describe-instances --instance-ids [ids] --query 'Reservations[0].Instances[0].PublicIpAddress' -
Log in to instance using:
ssh -i keyname.pem ubuntu@IP