Tech Junkie Blog - Real World Tutorials, Happy Coding!

Latest Posts

Monday, October 26, 2020

 In the previous post  we created a public and private subnet in our VPC.  In this post we are going to create a NAT gateway so that our private instances can access the internet.  That's useful when there's a need to update the instance.  For example if we ping google.com right now there will be 100% package lost in our private instance because we cannot get to the internet.  After we attach the instance to the NAT gateway we will be able to ping google.

It would go on for a while but eventually it would say the package is lost.

Now let's create our NAT Gateway, it is important that we delete the NAT Gateway if it's not in use because you have to pay for it.

Monday, October 19, 2020

 In most scenarios you don't want to expose all of your servers to be public facing.  You probably want to configure your network so that only the server that is hosting your web application is public facing.  What you want to do is put your web application on the public subnet and your backend servers on the private subnet.  This private subnet can access the internet through a NAT gateway for software updates and other functions that require internet access.  However, the outside world cannot establish a connection to servers in the private subnet.  The NAT gateway resides in the public subnet, acting as a bridge between the public subnet and private subnet.


Wednesday, October 14, 2020

 In the previous post we associated our Elastic IP with an instance directly.  In this post we are going to take another approach to assign our Elastic IP to our instance.  In this approach we will create an Elastic Network Interface and associate it with our instance instead.  In the first approach the Elastic IP replaces the public IP because we associate it directly to the instance. But if we create an Elastic Network Interface we are essentially adding a second interface in our instance with two IPs, eth0 is the main network interface and eth1 will be the second interface.  It's like having two network interface in the physical world but this time it's virtualized in AWS.


Here are the steps to create a network interface:

1. Create an Elastic IP, follow this post if you don't know how.

If you look at the instance description you will see that there's no Elastic IP address assignment, so if you stop and start the instance you will get a new public IP, and there's only one network interface (eth0). By the time we are finish with this post the instance will have tow network interfaces and an Elastic IP.


Tuesday, October 13, 2020

 In the last post we created our ACME Bank database in MySQL, the next step is to get the values from the Values table in the Asp.Net Core WebApi controller.  

Let's create some test data so that we could retrieve the values from the database.  The Values table could contain anything.  So I am going to store famous philosophers throughout history.  These philosophers are so famous that they only have one name: 

You can run the SQL insert statement below to seed the data in MySQL:

 

INSERT INTO acmebank.Values (
    Name
)
VALUES
    (
        'Socrate'
    ),
    (
        'Plato'
    ),
    (
        'Spock'
    ),
    (
	'Thanos'
    );

So your Values table should look like this when you executed the insert query










Monday, October 12, 2020

 When an instance is created in AWS a public and private IP is assigned to the instance.  The private IP does not change, but the public IP address changes each time the instance reboot or is stopped.  On reboot you might be lucky enough to grab the same public IP, but it's not guaranteed.  But on stoppage you will definitely be assigned a new public IP.

That's probably not a good thing a real world situation, that's where an Elastic IP comes into play.  An Elastic IP is a static IP that when assigned does not change.  However, there's no free lunch so you will be charged for it.  So only create one if you really need it.  I would recommend that you use the public DNS instead when you are not in production.  Say the development and test environment.  You might want to spend some money on the staging environment to mirror production as close as possible.

In the following section I will show you how to create an Elastic IP and assign it to an instance.  You probably want to delete it after you create it if you do not want to pay.  Only keep it if you want to use it.

Tuesday, October 6, 2020

 In this post we are going to create our first Entity Framework migration and creating an actual database in MySQL. 

In order to do that we need to add a few NuGet packages to our Asp.Net Core project including the Entity Framework Core package.  But, before we do that we want to find out what what version of .NET Core we are running.  Obviously I have it memorized, but for the rest of you, you can type the command dotnet --version to figure out what the version is :)  It's always a good idea to try and match the package version with the .NET Core runtime you have.  It's one of the more annoying thing with Angular and Asp.Net Core, it's changing constantly. So as you can see my version 3.1.xxx so I should try to install packages that are made for 3.1.x.

The first package we are going to install is the Microsoft.EntityFrameworkCore.  So open the ACMEBank.API project with Visual Studio Code.  Press Ctrl+Shift+P and type NuGet and select

Monday, October 5, 2020

 CloudWatch is a service on AWS that is used to monitor services on AWS via metrics.  In addition to monitoring resources.  CloudWatch can be used to set alarms and perform some actions on the instance when a certain condition is met.  In this post we are going to set an alarm on our instance if CPU utilization gets to a certain threshold.  Which is a typical safeguard that most environments have, there are several actions that you can take when the threshold is met, in our case we are going to terminate the instance if the CPU utilization reaches 75%. 

The following shows you how to set a CloudWatch alarm on our Linux instance:

1. Click on "Monitoring" tab in the "Instances" page, then click on the "Create Alarm" button

Tuesday, September 29, 2020

 In this post we are going to install MySQL Workbench on Fedora.  MySQL Workbench is a great GUI database management tool for MySQL.  Even though we can do everything we need with MySQL on the terminal it's nice sometime to see the tables and data visually.

Here are the steps to install MySQL Workbench:

1, Go to the yum repository for MySQL at https://dev.mysql.com/downloads/repo/yum/ select the Fedora repository, and click "Download"

Monday, September 28, 2020

 User Data in an instance allows you run commands while your instance boots up.  In the previous posts we just plain vanilla instances so far.  But in this post we are going to install the Apache Httpd service when we create our instance using User Data.

Here are the steps to create an instance with User Data:

In this blog we are going to start our journey into AWS infrastructure with the creation of an EC2 instance which is probably the most common task you'll ever do. 

 Here are the steps to create an EC2 instance on AWS:

1. Log into AWS and on the "Find Services" search box type EC2 and press enter 

2. You will be taken to EC2 screen, then click on "Instances"

2. Click on "Launch Instance"

An instance metadata is data about your instance that you can use to configure your instances.  They are divided into categories.  Anyone who have access to the instance can view the metadata, therefore you should not store anything sensitive that could be accessed such as "User Data"

You can get more information here at Amazon's website:

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html

You can access your metadata with this URL http://169.254.169.254/latest/meta-data/

Here are the steps to retrieve your instance data:

 1.  Connect to your AWS Linux instance and type curl http://169.254.169.254/latest/meta-data/


Search This Blog