Category Archives: AWS

Getting started with Amazon Elastic Beanstalk

In this tutorial, we are going to learn how to get started with Elastic Beanstalk.

Amazon Elastic Beanstalk is an easy-to-use service for deploying and scaling web applications created with java, .NET, Python, Golang, PHP, Node.js, and Ruby. You can quickly deploy and manage applications in the AWS cloud without worrying about the infrastructure that runs the application.

Benefits of using Amazon Elastic Beanstalk

  • It reduces management complexity. You are only required to upload your app and Elastic Beanstalk automatically handles the details of provisioning, creating a load balancer, scaling, and health monitoring via CloudWatch.
  • Every app is fully scalable because Elastic Beanstalk automatically scales every app smoothly depending on the resources allocated in every instance.
  • Developers have complete infrastructure control.
  • It’s fast and simple to deploy apps using Amazon Elastic Beanstalk.
  • It supports apps written in Go, Java, .NET, Node.js, PHP, Python, and Ruby. This shows that Elastic Beanstalk supports a large base of programming languages.
  • Elastic Beanstalk has a console where you can easily interact with the environment easily.

Getting started with Elastic Beanstalk.

To start deploying your application, follow the following steps.

Sign into your account and choose the region you will like to host your application. On the dashboard search for the Elastic Beanstalk. Click create, this will take you to Elastic Beanstalk getting started page. Input the application name, choose the platform to use, choose the way to create your application and finally click create application. Give it a few minutes for the application to be created.

As an example, we can create an Amazon Elastic Beanstalk using starter by following this link. https://console.aws.amazon.com/elasticbeanstalk/home#/gettingStarted?applicationName=getting-started-app

During creation, the following is created in the process.

  • An Amazon Elastic Compute Cloud instance is created (EC2)
  • Amazon EC2 Security group is created.
  • An Amazon S3 bucket is created.
  • Amazon CloudWatch alarms
  • Amazon CloudFormation stack
  • A domain name

If you are successful you will see something like the image below.

Elastic Beanstalk health

If your installation passes all the health checks, then if you click on the link saying getting started it will take you to the following page.

nextgentips: EBS welcome page

Deploying a new version of the application

Let’s say you have added some features to your application and you want to upgrade the running version on the AWS. This is how you can synchronize changes in your environment.

  1. Download the application that matches the platform you use at the beginning. To get those sample apps use this link https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/GettingStarted.DeployApp.html. In my case, I am using the go platform.
  2. Go to the Elastic Beanstalk console and choose Environment and select your environment. In my case, the name of the environment is called Gettingstartedapp-env.
  3. Click the name of your environment and click on the upload and deploy. Choose the file to upload and click deploy
nextgentips: EBS upload and deploy

Running a configuration change

Whenever you feel like you are not satisfied with the way the application is running, for example maybe your web application is compute intensive and you would like to reduce the resources, Elastic Beanstalk has to update its environment for changes to take effect.

Changes being made will depend, some will require you to delete the application and recreate while others will effect the changes immediately.

  1. Open Elastic Beanstalk console and click on the environments in order to locate your created
  2. Click Configuration and choose what you will like to edit, for my case let me edit capacity
  3. Choose what you will like to change and click apply.

Terminating the environment

When you are done with the environment, always terminate to avoid extra charges being billed. To delete follow the following.

  1. Go to Applications and choose the name of the app to delete.
  2. In the navigation, pane choose Application versions
  3. When on the Applications versions choose the version you will like to delete.
  4. Choose Actions and then delete
  5. Select Delete versions from Amazon S3
  6. Click delete and wait for it to complete
  7. Then we also need to terminate the environment by going to environment actions and choosing terminate, Confirm that you will like to terminate the instance and click terminate.
  8. Lastly is to delete the app. On the navigation, pane choose the name of the app, choose Actions and Delete Application, confirm that you will like to delete and click on delete button.

Congrats, we have successfully learned how to create, configure, and lastly terminate Amazon Elastic Beanstalk.

Getting started with Amazon Elastic Compute Cloud(EC2)

In this tutorial, we are going to learn about Amazon Elastic Compute Cloud(EC2).

Amazon Elastic Compute Cloud(Ec2) allows users to rent virtual machines on which to run their own computing functions. Ec2 provides a way to host your applications on the cloud at an affordable rate because data centers are much more expensive when you are not fully utilizing your services.

What makes Ec2 suitable for production?

  • Ec2 provides resizeable compute capacity in the cloud.
  • It reduces the time required to obtain and boot new server instances to minutes and allows you to scale faster.
  • You pay for what you require
  • The owner controls his own servers.
  • Ec2 is very reliable, secure, and easy to start.
  • It’s very inexpensive
  • Secure login to your instance using key pairs
  • You are provided with instance store volumes for temporary storage.
  • It provides you with elastic IP addresses for dynamic cloud computing.
  • It offers persistent storage volumes with the help of the Amazon Elastic Block store which is highly available and independent.

Prerequisites

  • Have AWS account
  • Select which region to spin your instance
  • Create key pairs for a secure connection to our instance via ssh.

Steps to Spin up EC2

1. Login to your AWS account

When you first login into your AWS account, you will be greeted with an interface like the one shown below.

nextgentips: AWS dashboard

2. Choose the region where you want to host your server. For me, I am using N.Virginia, Choose a region next to you.

3. From the search bar, search for EC2 and you will be taken to the Ec2 dashboard.

nextgentips: Ec2 dashboard

4. Create key pair for ssh login. This is critical whenever you want to log in via ssh. Go to key pair and click create key pair. Choose a name, key pair type, private key file format, .pem for Linux environment and .ppk for windows and lastly click create

nextgentips: key pair

5. Next is to create a security group that acts as a firewall for your instance to control inbound and outbound traffic. It’s easy to create, just click create input name, and description, choose VPC to use, and create different rules you want to allow.

6. Now it’s time to launch the instance. On the EC2 dashboard click on launch instance then input the name of the instance, then choose OS for that instance. Always choose free tier OS for experimentation to avoid incurring any expenses in the long run. The next thing is to choose your instance type. Select the t2.micro which is free tier eligible. Then you need to choose the key pair we created earlier. Move to network settings and choose the security group we created earlier also or you can create one if you didn’t create one at the beginning. For now, leave advance settings and click launch instance.

7. After you have successfully initiated the ec2 instance, click view all instances and you will see something like the below image.

nextgentips: Ec2 instance

8. The next step is to connect the instance so that we can do whatever we want with it. Click on the checkbox and click on connect. You will see the following being shown.

nextgentips: connect instance

I always love connecting via ssh client, this gives me an isolated environment away from the Ec2 interface. So to connect via ssh follow the procedure shown in the image above.

Always use the best way that suits you to connect to your instance. From you can start running your intended functions of the instance.

9. Terminate your instance when you are done with your instance to avoid incurring extra costs. This is done by clicking instance state and clicking terminate.

Congrats on spinning up your first instance on AWS. Happy coding!