Skip to content

Instantly share code, notes, and snippets.

@carloshmir
Last active June 6, 2018 10:24
Show Gist options
  • Select an option

  • Save carloshmir/c4e00074a1da1325371d to your computer and use it in GitHub Desktop.

Select an option

Save carloshmir/c4e00074a1da1325371d to your computer and use it in GitHub Desktop.

Before starting readings

Command line steps

  1. 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.
  1. 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.
  1. 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"}".
  1. Get the instance IP: aws ec2 describe-instances --instance-ids [ids] --query 'Reservations[0].Instances[0].PublicIpAddress'

  2. Log in to instance using: ssh -i keyname.pem ubuntu@IP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment