Showing posts with label Amazon. Show all posts
Showing posts with label Amazon. Show all posts

Tuesday, January 11, 2022

How to Create and Hosting Static Website with AWS

S3 is one of the oldest and most popular services provided by AWS with high availability, durability, security, and scalability. S3 can be used to store a backup of the database, Big Data Analytics, media, and much more. It provides an object storage mechanism with an abstraction of Buckets, folders, and files. The abstraction is what makes S3 easy to use.

With S3 (a storage mechanism), there is no need to perform the capacity planning and to specify the initial capacity. As we put more data and delete data, S3 will shrink and expand automatically. S3 provides different storage classes to store different types of data (old/new, frequently/infrequently accessed) and the data can be moved from one storage class to another using S3 Object Life Cycle Management. Or else use the AWS S3 Intelligent Tiering to let AWS decide when to move the data from one storage class to another. AWS CloudFront which is a CDN (Content Distribution Network) can optionally be used to make the website load faster to the end-user.

S3 with the free tier provides 5GB of storage, 20,000 Get Requests, 2,000 Put Requests for free every month for the first year and beyond at on a pay-on-usage model. In this article, we would be creating a static website on S3.



Hosting Static Website with AWS S3


Here is the full tutorial video based on "How to Create and Host a static website in Amazon S3" and S3 C.O.R.S. 👇👇



Step 1: Creating Bucket in S3


Go to the S3 Management Console and click on “Create Bucket”


Enter the Bucket name. Note that the Bucket name should be unique. Add something at the end to get a unique Bucket name. Select the Region where the data must be stored. Click on Create and the Bucket should be created as shown below. A Bucket is a container for storing folders and files.



Step 2: Giving the public permissions to the S3 Bucket


Any folder/file in the Bucket would only be visible to the owner who created it. For a website, the Bucket should be given public access for the rest of the world to access it as a webpage. Click on the Properties tab, make sure the “Block public access” is selected, and click on the Edit button. Unselect “Block all public access” and click on Save. Type the word confirm and click on the “Confirm” button.

This step doesn’t give the public permission to the S3 Bucket but will allow us to make the Bucket and its content public later in the next step. AWS has introduced these additional steps and hoops, as there had been a good number of incidents where sensitive data has been put in the S3 Bucket and without the proper settings it was made public for everyone to access the sensitive data.




Now is the time to make the Bucket public. Click on the “Bucket Policy” and enter the below policy, make sure to change the Bucket name to what was created in Step 1. Click on Save to make the Bucket public. Note that AWS will let us know three times that the Bucket has been made public, just to make sure that we don’t make in public accidentally.
1
2
3
4
5
6
7
8
9
10
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadGetObject",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::my-pictures-website/*"]
}]
}



Step 3: Enabling Static website hosting and uploading the website to S3

Now is the time to enable “Static website hosting” for S3. Notice that by default, it is disabled. Click on the card and select “Use this Bucket to host a website”. Enter the Index document as index.html and the Error document as error.html. Make sure to note down the Endpoint, this is the URL used to access the S3 website. Click on Save.

Note that the “Static website hosting” would be enabled by now. The Index document is the default HTML to be displayed and the Error document is the HTML to be displayed when the HTML page which we are trying to access is not there in S3.








Now is the time to upload the index.html and error.html. Go to the Overview tab and click on Upload. Click on “Add Files” and then Upload. The same steps must be repeated for index.html and the error.html pages.




Here is the content of index.html and error.html.





Step 4: Access the webpage hosted in S3

Open the URL got from “Step 5” to get the index.html displayed. To the end of the URL, anything besides the index.html and the error page would be displayed. The URL is not user-friendly, a user-friendly URL can be created using AWS Route53.







Monday, January 3, 2022

Amazon Routing Policies

What Is Amazon Route 53?

Amazon Route 53 (Route 53) is a scalable and highly available Domain Name System (DNS) service. Released on December 5, 2010, it is part of Amazon.com's cloud computing platform, Amazon Web Services (AWS). The name is a possible reference to U.S. Routes, and "53" is a reference to the TCP/UDP port 53, where DNS server requests are addressed. In addition to being able to route users to various AWS services, including EC2 instances, Route 53 also enables AWS customers to route users to non-AWS infrastructure and to monitor the health of their application and its endpoints. Route 53's servers are distributed throughout the world. Amazon Route 53 supports full, end-to-end DNS resolution over IPv6. Recursive DNS resolvers on IPv6 networks can use either IPv4 or IPv6 transport to send DNS queries to Amazon Route 53.


What is Policy-Based Routing?

In computer networking, policy-based routing (PBR) is a technique used to make routing decisions based on policies set by the network administrator.

When a router receives a packet it normally decides where to forward it based on the destination address in the packet, which is then used to lookup an entry in a routing table. However, in some cases, there may be a need to forward the packet based on other criteria. For example, a network administrator might want to forward a packet based on the source address, not the destination address. This permits routing of packets originating from different sources to different networks even when the destinations are the same and can be useful when interconnecting several private networks.


Here is the full video based on AWS Routing policies👇👇





Routing policies are used to: 

  • Manipulate route attributes (the attribute depends on the routing protocol) 
  • Decide which routes go into the routing table 
  • Decide which routes to advertise to neighbors 
  • Redistribute routes



Route 53 Routing Policies


Simple

This is the default routing policy. Use this only when you have exactly one resource such as one EC2 web server. This policy can contain multiple values but it returns one resource. This policy is not recommended for production sites.


Weighted

This one is fantastic for new deployments or release testing new versions. It’s based on a numerical value ranging from 0 to 255. If you specify a value of 0 for all regions then it’s routed equally.


Failover

Allows creating two records for the same name. This starts like a simple policy but with a health check. If that single web server is unhealthy then you can point elsewhere. That next pointer can be another web server or possibly an error.html page hosted in AWS S3.


Geolocation

Use this when you want to serve your site based on the location of the client or user.


Geoproximity

This is somewhat complicated so I would like to point to original documentation for the full explanation.


Latency

When you have multiple resources in multiple regions, this policy routes the user, not to the closest resource necessarily but the resource that responds the fastest or lowest latency


Multivalue answer

This one lets your return multiple values for each of your resources. The client or user browser randomly chooses one. Optionally you can add health checks. If any value becomes unhealthy then the client chooses another value to resolve. This is not an alternative solution to load balancing, it’s an enhancement.



Wednesday, December 29, 2021

What is DNS TTL (Time To Live)?

What is time-to-live (TTL)?

Time-to-live (TTL) is a value for the period of time that a packet, or data, should exist on a computer or network before being discarded.

The meaning of TTL, or packet lifetime, depends on the context. For example, TTL is a value in an Internet Protocol (IP) packet that tells a network router when the packet has been in the network too long and should be discarded.


Here's the full video along with a hands-on demo that's based on TTL (time-to-live)👇👇




How Does TTL Work?

TTL's basic function revolves around managing information packets in relation to DNS requests. When one of these packets is created and transmitted through the internet, there is a chance that it will pass, continuously, from router to router forever. To prevent this from happening, each packet has a specific TTL or hop limit. It is also possible to examine the TTL log of a data packet to obtain information on how it has moved through the internet over the course of its travels.

Within each packet, there is a specified place where the TTL value is stored. This is a numerical value, and it indicates how much longer the packet should move around the internet. When a router receives a data packet, it takes away one unit from the TTL count before sending it on to the next destination within the network. This continues to happen until the TTL count within the packet drops all the way down to zero.


What is time-to-live in HTTP?

In Hypertext Transfer Protocol (HTTP), time-to-live describes the number of seconds it takes for cached web content to return before the webserver has to check again to ensure that the content is "fresh."

Settings on the webserver define a default value. Still, cache-control tags, which define the kinds of servers, if any, can cache the data, or expired tags, which represent a date and time when the content is stale, can override it in the HyperText Markup Language page headers.

What Are TTL Values?

When you set TTL values for your website, you choose a value in seconds. For example, a TTL value of 600 is the equivalent of 600 seconds or ten minutes.

The minimum available TTL is usually 30, equivalent to 30 seconds. You could theoretically set a TTL as low as one second. However, most sites use a default TTL of 3600 (one hour). The maximum TTL that you can apply is 86,400 (24 hours).

Technically, you can set any TTL value between the minimum and maximum parameters. Later in this article, we’ll discuss how you can choose the best time to live value for your site.


How Should You Choose a TTL?

Deciding on a suitable TTL for your needs can be challenging. Fortunately, there are some general guidelines that you can follow to see what fits your site best.

We recommend a TTL of 1-24 hours for most sites. Remember that TTL values are measured in seconds, so this is the equivalent of 3,600 to 86,400 seconds.

This TTL value can reduce loading time, which improves the user experience for your visitors and can decrease your bounce rate. The longer the better is a general rule, but remember to schedule any website maintenance accordingly.





Monday, December 27, 2021

How to Setup EC2 Instance

What is Amazon EC2 Instance?

Amazon EC2 provides a wide selection of instance types optimized to fit different use cases. Instance types comprise varying combinations of CPU, memory, storage, and networking capacity and give you the flexibility to choose the appropriate mix of resources for your applications. Each instance type includes one or more instance sizes, allowing you to scale your resources to the requirements of your target workload.

The instance will be charged per hour with different rates based on the type of instance chosen. AWS provides multiple instance types for the respective business needs of the user.
Thus, you can rent an instance based on your own CPU and memory requirements and use it as long as you want. You can terminate the instance when it’s no more used and save on costs. This is the most striking advantage of an on-demand instance- you can drastically save on your CAPEX.



Here is the full dedicated video-based upon "How to Create Amazon EC2 Instance"👇👇




Steps to Create Amazon EC2 Instance


1.    In EC2 go to the Instances





2.    And after that Click on Launch the Instance.




3.    Choose the Machine Image (AMI) you want.




4.    Choose the Instance Type you want.




5.    Configure the Instance Details




6.    Add Storage




7.    Add tags




8.    Configure Security Group




9.    Review and Launch, Here you can see the Detail of your Instance.




10.    If you are done with the Review, Now you can Simply launce the Instance



11.    Then your instance will start the launching







Sunday, December 26, 2021

How to create Records in AWS Route53

what is Route53?

Amazon Route 53 is a highly available and scalable Domain Name System (DNS) web service. You can use Route 53 to perform three main functions in any combination: domain registration, DNS routing, and health checking.


Amazon Route 53 pricing and billing

Top ChatGPT Prompts for DevOps Engineers

  As a DevOps engineer, your role involves juggling complex tasks such as automation, infrastructure management, CI/CD pipelines, and troubl...