Photo of the ocean from a beach

How to host a static website on Amazon’s AWS with SSL using S3, Certificate Manager, CloudFront, and Route53

So you have a static website and need to host it somewhere, there are many places to host your site but since you also want your site to have a security certificate, and you want all of this at a reasonable price, your options are limited.

Last year, I tried Azure Storage to host a static website, but at the time, the options to get and apply a security certificate to a site hosted on Azure storage was complicated, it was very confusing.

This time I decided to give AWS a try, and it turns out, hosting a static website using AWS’s S3 storage service works really well for static websites.

AWS also has a somewhat simple way to set up your new static website with a free security certificate. Below I will show you the steps to accomplish this.

These are the services you’ll need to configure to host your static website and an SSL certificate with Amazon’s AWS:

  • S3
  • CloudFront
  • Certificate Manager
  • Route53

The instructions below assume that you’ve already signed up for a AWS account.

S3 – Create and change the properties of your static website bucket

After you login to your AWS Console, search for S3 and create a new bucket for your static website. When creating the new bucket, you only need to give it a unique name, and then uncheck the Block all public access options under permissions. Don’t change any of the other default values or options.

Properties tab

After you’ve created a new bucket to hold your website files, click on the bucket name and then on the properties tab. From here, select the Static Website Hosting, it should look like the screenshot below.

In this window, you want to put the name of your main page (i.e. index.html), an optional error page, and any redirection rules, also optional.

Image of static website hosting properties in AWS S3

Before you move on to the next step, copy the Endpoint value from the Static website hosting window and save it, you’ll need it for the CloudFront Distribution section below. In the example above, the endpoint is the URL: http://solopractica.s3-website-us-west-2.amazonaws.com

Permissions tab

Make sure the Block all public access option is unchecked. Now go to the Bucket Policy option and click on Policy Generator.

Select the options as shown above, make sure the Amazon Resource Name (ARN) follows this format: arn:aws:s3:::YourBucketName/* and replace YourBucketName with the actual name of your newly created bucket.

Finally, click on Add Statement and then Generate Policy, a new window will open with your new bucket policy in JSON format. Copy the JSON document, and paste it into the Bucket Policy space back in the bucket properties page.

If you get the following error message after saving the new policy: Policy has invalid resource, make sure the bucket name value is correct, and save again.

You’ll see a warning informing you that your bucket has public access, that is fine, the bucket needs public access to host your static website.

CloudFront Distribution – Create and configure

A CloudFront distribution is required if you want to host a static site and distribute media files using HTTP or HTTPS.

To create a CloudFront distribution, go to the AWS console, and type CloudFront in the search box. When the CloudFront Service page opens, click on Create Distribution, and then select Get Started for the Web option.

CloudFront distribution properties

Do not be overwhelmed by the many options in this window, you only need to change a few of these properties. Below are basic instructions on how to fill out the Create Distribution form.

Origin Settings

  • Origin Domain Name: Select your bucket endpoint from this list.
  • Origin Path: Leave it blank.
  • Origin ID: It gets filled automatically when you select the origin domain name above.
  • Restrict Bucket Access: No.
  • Origin Custom Headers: Leave default/blank values.

Default Cache Behavior Settings

  • Path Pattern: Nothing to change here.
  • Viewer Protocol Policy: Redirect HTTP to HTTPS (but you can select any option, it is up to you).
  • Allowed HTTP Methods: GET, HEAD.
  • Field-level Encryption Config: Leave default/blank value.
  • Cached HTTP Methods: Leave default value.
  • Cache Based on Selected Request Headers: None.
  • Object Caching: Use Origin Cache Headers.
  • Minimum TTL: Leave default.
  • Maximum TTL: Leave default.
  • Default TTL: Leave default.
  • Forward Cookies: None.
  • Query String Forwarding and Caching: None.
  • Smooth Streaming: No.
  • Restrict Viewer Access: No.
  • Compress Objects Automatically: No.
  • Lambda Function Associations: Leave default/blank value.

Distribution Settings

  • Price Class: Use Only U.S., Canada and Europe (the cost of it will change based on what you select here. Click on the information icon next to this setting and make the right choice for you).
  • AWS WAF Web ACL: None.
  • Alternate Domain Names (CNAMEs): Type your domain name and any subdomains you have for the bucket hosting your static website. For example, for my site solopractica.com, I entered the following values here:
    solopractica.com
    http://www.solopractica.com
  • SSL Certificate: Custom SSL Certificate. This is where you’ll also be clicking on Request or Import a Certificate with ACM (see section below).
  • Supported HTTP Versions: HTTP/2, HTTP/1.1, HTTP/1.0
  • Logging: Off
  • Enable IPv6: Checked.
  • Distribution State: Enabled.

After you request a SSL certificate and complete all of the options, click on Create Distribution.

Certificate Manager – Request a Certificate

From the steps above, open up the window to request a new certificate by clicking on Request or Import a Certificate with ACM.

In this page, type your domain name and www version of it and then click Next. Example:

Select validation method

Choose the DNS validation option, it’s the fastest and easiest. If you don’t have access to your domain DNS settings, then you can try Email validation instead. Click Review, and then Confirm and request.

Validation

Once you go through the steps to validate your domain(s), you’ll see a window with your Request in progress and the instructions to add a CNAME record to the DNS configuration for your domain. Click Continue.

Certificates

This page will show the status of your certificate request, you can refresh the status of your request to get the status updated. The time to get your domain verified depends in part, on your domain registrar.

After your certificate has been approved, go back to your Distribution and click on it to edit it. From the edit page, make sure you have the Custom SSL Certificate option selected and then select your brand new SSL certificate from the list.

Route 53 – Create and configure

This is the last step, it will allow AWS to route your domain name and certificate to the appropriate resource.

Go to the AWS console and type Route 53 in the search box, click on the Route 53 link, and then on Hosted zones.

Hosted zones

Create a new hosted zone, enter your domain name, make sure the Public Hosted Zone is selected and click Create.

Record Sets

Two record sets are created by default when creating a new zone, a NS (Name Server), and SOA (Start of authority).

While selecting the newly created Hosted Zone, click on Create Record Set.

Use the following settings and values when creating the new record set:

  • Name: Leave the name box empty.
  • Type: A – IPv4 address.
  • Alias: Yes.
  • Alias Target: Select it from the list, you should see a value available if all of the steps above were completed successfully.
  • Routing Policy: Simple.
  • Evaluate Target Health: No.

After this, you can add another record set of type A for any additional domain names you might be using, for example, http://www.yourdomain.com.

That’s it, by now you should be able to open your browser and go to your domain, it should be available with the https protocol.

Cheers!

Photo of ocean

A simple change to my morning routine

There are many ideas and tips out there to help you become more productive and content about the work you do every day. I’ve read many books on the subject, many articles, blog posts, listened to podcasts, etc.

As you can imagine, many things in life can alter your productivity and the way you feel about yourself. With this post, I am not trying to list them all here or give you the ultimate advice about this. Instead, I want to share a simple change in my morning routine that so far, it’s working for me.

Wake up early and train your body to do it without an alarm.

This is an obvious thing to do if you want your day to last you longer. And it isn’t Just about waking up early, but In addition, to change the activities that we do after we wake up. I’ve heard about the idea of waking up at 4 in the morning, I applaud those who can do it, but that’s not me. My ideal wake up time is between 6 and 7 am.

Lately, I’ve been training myself to wake up around 6am but without the help of an alarm. I am doing this because waking up to the terrible and loud sound of a wake up alarm is not fun, and it causes me to feel anxiety just by listening to the terrible sound of my phone’s alarm.

This is what I’ve been doing, I set my alarm with a very soft sound that starts at a low volume level, and the sound increases consistently until it wakes me up. This alarm sound is very soft, even when louder, so it doesn’t make me jump out of bed as my previous alarm sound did.

In the past two weeks, my body has been adjusting to the softer sound, and slowly but surely, I’ve been waking up around 6 am, most days before the alarm goes off.

Drink water and then read for 15 to 30 minutes.

For many years, I’ve spent the first 20-30 minutes of every morning, reading social media posts and email with my phone. Another important bad habit I recently eliminated was to drink two cups of coffee or more, before drinking any water. It was bad.

Today I wake up without looking at my phone, then proceed to have at least one cup of water, and then I open my kindle and read for several minutes. After that, I shower, and then I have my first cup of coffee, a delicious, hot cup of java. In this new morning routine, my phone no longer plays an essential part of my morning, it is empowering.

Reading and drinking water before I look at my phone or computer makes me feel not only happier, but also more present and with more energy to start the day. It makes sense, the water hydrates me, and the reading stimulates my mind. Subsequently, avoiding looking at email and social media eliminates any negative feelings or anxiety.

This is not the first time I try to improve my morning routine, a few years ago I tried journaling every morning, it was the first thing I’ll do but the problem was, I used my computer to do it so opening a social media website was very easy and so I did it often.

Because of that I found journaling challenging, and so it wasn’t enjoyable. The easy access to social media sites in my computer while journaling caused me to fall into my bad habits again, undermining my efforts to avoid looking at my phone first thing every morning.

This time is different, I feel it, reading every morning is delightful to me and like I said above, having that cup of water after in the morning and before any coffee gives me the energy and concentration my body requires to do some reading every morning. It also puts me in a good state of mind to start my day.

Reading a book gives me clarity of mind and a blank palette to start my day. This is important because when I was waking up and reading social media posts, or email, it affected my state of mind, it made me feel stressed, or sad, or anxious about things that didn’t have any relation to my day.

A simple change to my morning routine with these small changes has resulted in a significant positive return. Since my morning routine change took place, my professional work output has increased, I fell less rushed every morning, and just feel more content with myself and the world around me.

Cheers.

Books wrapped by headphones

Cómo consumir libros mientras caminas, manejas o lavas los platos. Una pista: audiolibros.

La cuestión es que, por mucho que se disfrute leyendo libros de papel y también libros en el Kindle, es casi imposible y muy irresponsable hacerlo mientras caminas, lavas los platos o conduces tu automóvil, realmente no es seguro ni conveniente. Ahora, he sabido sobre audiolibros por un tiempo, pero por alguna razón, no había probado estos hasta hace poco. Sin embargo, escuchar podcasts mientras conduzco, camino, o lavo los platos, es algo que he estado haciendo durante mucho tiempo. Escuchar audio mientras realizas otras actividades físicas o muy repetitivas no solo es posible, sino que también es agradable, y sí, realmente lavo los platos a mano en casa para poder escuchar podcasts y audiolibros.

Los audiolibros cruzaron mi vida durante un viaje por carretera a Florida el año pasado, cuando experimenté escuchar un audiolibro de principio a fin mientras conducía durante varias horas desde Texas a Florida.

El audiolibro fue “Becoming” por Michelle Obama, mi esposa me había pedido que lo comprara, así que terminamos escuchándolo durante este viaje por carretera. El libro fue largo pero muy entretenido y emocionante, en general fue genial. Aprendimos mucho sobre Michelle Obama, y ​​también sobre su esposo, el presidente Obama. Pero lo que más me sorprendió fue que el formato de audio era realmente fácil de seguir, realmente lo disfrutamos. Y esto es todo lo que necesite para engancharme con los audiolibros.

Lo siguiente que hice después de eso fue comprar otro libro, Sapiens. De animales a dioses: Una breve historia de la humanidad por Yuval Noah Harari, este es un libro que quería leer desde hace ya un tiempo y desde que supe que iba a conducir desde Austin, TX a Seattle, WA, pensé que sería una excelente manera de pasar las horas manejando, escuchando este libro. Lo fue, y ahora es uno de mis libros favoritos que he escuchado o leído en este año, hasta la fecha.

Lo que pasa con los audiolibros es que, aunque no están tan pulidos como los podcasts, son una muy buena manera de consumir libros, especialmente si no puedes encontrar el tiempo para sentarte y leer. Ahora, para mí, los audiolibros no son un reemplazo de los libros en papel o Kindle, pero definitivamente son una opción cuando quieres consumir un libro mientras haces una actividad donde la lectura no es una opción.

Al final, lo que recomiendo es que consumas más libros, en forma de audio, o leyéndolos, no importa, simplemente hazlo. Elimina todas las barreras que te impiden aprender y descubrir cosas nuevas comúnmente ocultas en libros y/o audiolibros.

Recientemente escribí sobre cómo la lectura te ayuda a encontrar el éxito, la publicación está en español, pero puedes traducirla fácilmente o esperar hasta que publique una versión en inglés. Ve a leer y a escuchar más.

Anuncio: Pruebe Audible y obtenga dos audiolibros gratis