Part 1 of AWS EC2 for Beginners: Creating An Instance To Host A Customized Website

Part 1 of AWS EC2 for Beginners: Creating An Instance To Host A Customized Website

And we are back this week with another tutorial, and this time we're diving into AWS EC2! Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the Amazon Web Services (AWS) Cloud, eliminating the need to invest in hardware. Simply put, you can leverage AWS EC2 to set up your very own Linux instance (virtual computing environments/servers), can be used to serve as your own virtual network, and you can secure EC2 such as by using key pairs and/or security groups, to name a few. Now that you have a high-level overview of AWS EC2, let's get into the tutorial of launching an AWS EC2 instance, and using BASH scripts to create new users and a customized website!< /p>

Resources/PreReqs:

  • As always, Confidence to get it done!
  • An AWS Account: Sign Up Here (Select the FREE Tier ccount)
  • Nano or Vim (Text Editors)
  • Basic understanding of Linux command input/output
  • MacOS Terminal, Windows Command Prompt, or Linux Shell
  • GitHub Account: Sign up here (Stay logged in!)

And we're off!

Basic Project Execution

Step 1: You should be logged into your AWS Console at this point, so we will begin with the first set of steps.

  • In the top left corner of the console, click on "Services", and select "EC2"
  • You'll then click on "Launch Instance", which will take you to the following page:
  • After naming the instance, be sure to select an OS Image that has "Free Tier" next to it, followed by "t2.mirco" as the instance type (also free)
  • While some may say this is optional, I would recommend adding a key pair as this adds additional security. Once created, the key pair will download automatically to your device. See the output of how this should look:
  • Next, we'll have to enable inbound traffic for the Apache Server (SSH and on HTTP for the IP of 0.0.0.0/0) from our IP, so scroll down to "Network Settings", and your options should look like this:
  • Now that we have enabled the traffic to the instance, we now have to add our BASH script in the "User data" field, under advanced settings, or we can use Vim later on to create a script as well. I will show both options. If you're unfamiliar with BASH scripting, refer to this blog and take a look at a previous script that I created. This is how the script should look:
**Note: When stopping your instance, it is possible that the user data will not be available when you re-start the instance if the volume is not backed up.
  • And now, let's move forward with Launching our instance, so click on "Launch Instance":

Step 2

We will now view all instances to ensure the instance state is set at "Running" and the "Status Check" shows everything has passed.

  • Since everything looks good with the instance, let's proceed with clicking on "Connect", and then clicking on it once more on the next page:
  • If the above option does not work for you, you'll have to try to ssh directly into the instance, using the commands below:

chmod 400 <YourKeyPair.pem>

ssh -i <YourPemFileName> <InstanceUserName>@instancepublicdnsname

**Install the AWS CLI and and SSH Client if necessary to execute the command

  • Now, after running the command above, the output should be successful, which means you will now be able to connect to your Instance:
  • You can use the vim text editor to create your script as mentioned earlier, by typing vim <yourscriptname>.sh (Remember to hit the "i" key to start adding text, and :wq to save the script)
  • To be sure that the script runs properly, type the following:

chmod +x <yourscriptname>.sh, followed by sudo ./<yourscriptname>.sh

**You should notice that it is being executed after typing those commands

  • Now, go back into your AWS Console and either refresh the instance and try to re-connect followin g the "Connect" option above, or simply copy and paste the IPv4 address and paste it in your browser, and it should look like this:

*Be sure to STOP your instance for the time being. You will be able to re-start the instance in Part 2 of this tutorial.*

Now that we've completed Part 1, sit tight because Part 2 is coming up next!


Part 1 of AWS EC2 for Beginners: Creating An Instance To Host A Customized Website was originally published in Towards AWS on Medium, where people are continuing the conversation by highlighting and responding to this story.

Namaste Devops is a one stop solution view, read and learn Devops Articles selected from worlds Top Devops content publishers inclusing AWS, Azure and others. All the credit/appreciations/issues apart from the Clean UI and faster loading time goes to original author.

Comments

Did you find the article or blog useful? Please share this among your dev friends or network.

An android app or website on your mind?

We build blazing fast Rest APIs and web-apps and love to discuss and develop on great product ideas over a Google meet call. Let's connect for a free consultation or project development.

Contact Us

Trending DevOps Articles

EC2 Random name Generator using Python script

Reduce your Google Cloud Spend

Approach 1-Integrating Gitlab repository with Cloud Build Triggers via webhook and creating CI/CDรข€¦

Anthos Config Management

From Cloud Chaos to Cloud Smart With Multi-Cloud Services

Popular DevOps Categories

Docker aws cdk application load balancer AWS CDK Application security AWS CDK application Application Load Balancers with DevOps Guru Auto scale group Automation Autoscale EC2 Autoscale VPC Autoscaling AWS Azure DevOps Big Data BigQuery CAMS DevOps Containers Data Observability Frequently Asked Devops Questions in Interviews GCP Large Table Export GCP Serverless Dataproc DB Export GTmetrix Page Speed 100% Google Page Speed 100% Healthy CI/CD Pipelines How to use AWS Developer Tools IDL web services Infrastructure as code Istio App Deploy Istio Gateways Istio Installation Istio Official Docs Istio Service Istio Traffic Management Java Database Export with GCP Jenkin K8 Kubernetes Large DB Export GCP Linux MSSQL March announcement MySQL Networking Popular DevOps Tools PostgreSQL Puppet Python Database Export with GCP Python GCP Large Table Export Python GCP Serverless Dataproc DB Export Python Postgres DB Export to BigQuery Sprint Top 100 Devops Questions TypeScript Client Generator anti-patterns of DevOps application performance monitoring (APM) aws amplify deploy blazor webassembly aws cdk application load balancer security group aws cdk construct example aws cdk l2 constructs aws cdk web application firewall aws codeguru reviewer cli command aws devops guru performance management aws service catalog best practices aws service catalog ci/cd aws service catalog examples azure Devops use cases azure devops whitepaper codeguru aws cli deploy asp.net core blazor webassembly devops guru for rds devops guru rds performance devops project explanation devops project ideas devops real time examples devops real time scenarios devops whitepaper aws docker-compose.yml health aware ci/cd pipeline example host and deploy asp.net core blazor webassembly on AWS scalable and secure CI/CD pipelines security vulnerabilities ci cd pipeline security vulnerabilities ci cd pipeline aws smithy code generation smithy server generator
Show more