Skip to content

Instantly share code, notes, and snippets.

@kenichi-shibata
Last active October 5, 2020 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenichi-shibata/ce6b164f2483451cf05d4aee0a2d27ee to your computer and use it in GitHub Desktop.
Save kenichi-shibata/ce6b164f2483451cf05d4aee0a2d27ee to your computer and use it in GitHub Desktop.
Demo EC2 Create

0. Login to Cloud9

Create a new IDE

Services -> Cloud9 -> Create Environment -> <yourname>-cloud-laptop -> Click on Next -> Click on Ubuntu -> Click on next step -> Confirm

Open an existing IDE

Services -> Cloud9 -> Open IDE

1. Create SSH Key Private and Public Key

$ ssh-keygen -b 2048 -t rsa -q -N ""
Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa): [Press enter]

This will create a file in

cd $HOME/.ssh
cat id_rsa #this is the private key
cat id_rsa.pub #this is the public key

Copy the public key

2. Upload the SSH Public Key to EC2 Console

Services -> EC2 -> Network and Security -> Key Pair -> Actions -> Import key pair -> <yourname>-key -> Paste the public key

3. Create EC2 Instance via Console

Services -> EC2 -> Instances -> Launch Instances -> Ubuntu 20 Select -> t2.micro -> Next: Add Storage -> Next: Add Tags -> Add Tags -> Name: <yourname>-instance-1 -> Next: Configure Security Group -> SSH Port 22 0.0.0.0/0 -> Review and Launch -> Launch -> Choose Key Pair -> your keypair -> Click on the tickbox -> Confirm

4. Login to the EC2 instance via ssh

 find the IP address of the Instance -> Services -> Ec2 -> click on the instance -> look for the private ipv4 address
go back to the cloud9 tab -> ssh ubuntu@<IPV4 Address> 

5. Do something useful (Optional)

Install NGINX

sudo apt-get install nginx

[When prompted type 'y']

Turn on NGINX

sudo systemctl start nginx

Test

curl localhost:80

Find the Public IPv4

Services -> EC2 -> Click on the Instance -> Copy the Public IPv4

Open your browser the public IPv4. It does not work

6. Open the firewall

Open the Port 80 to the world

Services -> EC2 -> Click on the Instance -> Click on the Security Tab -> Click on the security Group -> Click on the inbount rule -> Add rule -> Port: 80 Source: 0.0.0.0/0 -> Save Rules

Open your browser to the public IPv4

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