EC2 instances are a basic building block of AWS services. In this video, learn how to create your first EC2 instance to see how easy it is to start a new server in the cloud.
- [Instructor] When you create a new EC2 server you're ordering a virtual server with the specifications you select that's delivered directly to your AWS account with one-minute shipping. Soon, Amazon will have figured out how to get me a roll of toilet paper that fast. From within the AWS Console click on the Services pulldown, and type EC2 into the Services search bar, and click on the entry that autocompletes. Click the Launch Instance button. Virtual machine images in AWS are called AMIs, or Amazon Machine Images. On this screen you can select from any number of AMI images that Amazon has already created. So, you can start with a blank server that includes Linux or Windows Server, and it's already set up for you. Select the Ubuntu Server 18.04 image and click Select. On the Instance Type screen you'll select what kind of hardware you want allocated to your virtual machine. We'll get more into the instance types in the next video, so for now select t2.micro. Click on the Review and Launch button, and this will skip us straight to the final step of the wizard with all of the defaults selected. If AWS won't let you click on the Review and Launch button you may need to recreate your default VPC. So, check the AWS Docs for steps on how to do this. Click the Launch button. To connect to the instance either through SSH on the terminal for Linux instances such as this one, or Remote Desktop Protocol, or RDP, for your Windows Server instances you'll need to create a key pair which will become the password for accessing this instance. In the first pulldown select Create a new key pair. And for Key pair name type awsdemo, and click the Download Key Pair button. Now click the Launch Instances button. Then click the View Instances button, and you can see now it's starting our EC2 instance. On the Name column on your EC2 instance, if you hover over it you'll see a little pencil and you can click on it to edit the name. Type webserver1 and click the check mark. When your instance goes into a running state make sure it's selected, and then click the Connect button. This model will give you some instructions on how to connect to your running instance. Now, if you're using Windows on your PC you can click the connect using PuTTY link to view instructions on how to connect to this Linux instance using PuTTY. For macOS open a Terminal window. The .pem file I downloaded should be in my local user's Downloads folder, unless you customized this setting in your browser. So type cd for change directory space ~/Downloads/ and hit Enter. Type ls to list all the files and there's my awsdemo.pem file. If you want to see what's inside here type cat space awsdemo.pem and hit Enter. And you'll see an encoded private key. Now, the associated public key is already installed on your instance for you. Now, keep in mind this awsdemo.pem file is the only copy there is. You can't get it from AWS later if you lose the file. If you have a team you'll need to share this file with them securely so they can connect to your instances. I usually take the contents of this file and I paste it into my team's encrypted password store such as LastPass or 1Password, and only share it with the people who need it. If you lose your key pair there's no way to recover it, but you can go through a pretty complicated procedure that's listed in the AWS Docs to create a new key pair and install that new public key on an image of your affected instance and then relaunch it. But to avoid all of this just don't lose the key pair. I usually move the .pem file into my user's hidden .ssh folder because that's where my other keys are for GitHub and my other servers, but this step is optional if you don't have a .ssh folder yet. So type mv for move space ~/Downloads/ awsdemo.pem space and now I'm going to move it into ~/.ssh and hit Enter. And then following the instructions on the EC2 Console, I need to set the permissions on my awsdemo.pem file. So in my terminal I'm going to type chmod space 400 space ~/.ssh/awsdemo.pem and hit Enter. This set the permissions on my private key to only be readable by my local user. Then copy the example ssh command from the EC2 launch window. And I'm going to paste this into my Terminal window. Use the arrow keys to move inside of the double quotes, and I need to tell this command the exact path to where my aws.pem file is, which is now ~/.ssh/ and then the rest will stay the same, awsdemo.pem, and now hit Enter. Since this is the first time we're connecting to this instance, type yes to accept the fingerprint and hit Enter. Great, now we're on our EC2 instance that's running in AWS. Sweet!
- Proper security for the AWS root account
- Identity and Access Management (IAM)
- Regions and availability zones
- Creating an EC2 instance web server
- Editing security groups
- Storing and serving files from AWS
- Scaling with Elastic Load Balancer (ELB)
- Hosting databases within AWS
- Running containers on AWS
- Machine learning services within AWS
- DevOps with AWS
- Security on AWS