avatarRichard Taujenis

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

3338

Abstract

class="hljs-attr">"Statement"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span> <span class="hljs-punctuation">{</span> <span class="hljs-attr">"Sid"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"PublicReadGetObject"</span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"Effect"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Allow"</span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"Principal"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">""</span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"Action"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span> <span class="hljs-string">"s3:PutObject"</span><span class="hljs-punctuation">,</span> <span class="hljs-string">"s3:PutObjectAcl"</span><span class="hljs-punctuation">,</span> <span class="hljs-string">"s3:GetObject"</span><span class="hljs-punctuation">,</span> <span class="hljs-string">"s3:GetObjectAcl"</span><span class="hljs-punctuation">,</span> <span class="hljs-string">"s3:DeleteObject"</span> <span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"Resource"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"arn:aws:s3:::quiz-vue-app/"</span> <span class="hljs-punctuation">}</span> <span class="hljs-punctuation">]</span> <span class="hljs-punctuation">}</span></pre></div><p id="b2e6">In <i>Action </i>section I needed Put, Get etc Objects. You can read more about it <a href="https://docs.amazonaws.cn/en_us/IAM/latest/UserGuide/reference_policies_examples_s3_rw-bucket-console.html">here</a>. The <i>Resource </i>section in the value set your <b>S3</b> bucket name as mine is defined <b>quiz-vue-app.</b> For more info regarding permission's check <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteAccessPermissionsReqd.html">here</a>.</p><p id="8fb1"><b>Identity and Access Management (IAM)</b></p><p id="808f">Last up <a href="https://us-east-1.console.aws.amazon.com/iamv2/home?region=eu-central-1#/home"><b>IAM</b></a><b> </b>I followed a guide about <b>S3 </b>deployment but it omitted <b>IAM</b> here is why it’s essential to set it up as well.</p><blockquote id="975d"><p>Loading data from an Amazon Simple Storage Service (Amazon S3) bucket <b>requires an AWS Identity and Access Management (IAM) role that has access to the bucket</b>.</p></blockquote><figure id="6899"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*VoUFHreCCESoe_u1XJhkUA.png"><figcaption></figcaption></figure><p id="fc53">I have set my users as <b>GithubDeploy </b>for automatic deployment with<b> Github Actions </b>but more on that on the next article. IAM gets really powerfull in cases like these. The Action section in the above bucket policy is in relation to <b>IAM</b> for more about it it can be read <a href="https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Integrating.Authorizing.IAM.S3CreatePolicy.html">here</a>. After all is done in the <b>S3</b> bucket bott

Options

om of the properties you will see a external link that should work.</p><figure id="593a"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*gJWA_rd83ANIccGnnMHq7A.png"><figcaption></figcaption></figure><p id="07e7">And that’s how it’s done there are other options like <a href="https://aws.amazon.com/amplify/"><b>AWS Amplify</b></a> but decided to start simple and slowly increase my knowledge about <b>AWS</b>, <b>DevOps</b> and share it with the community. I plan to get a book to get more insight on <b>AWS</b> as it has fast amount of services and want to simplify it as much as posible. Bellow you can my <b>S3</b> bucket and luckily its free of charge(for now)!</p><div id="21f0" class="link-block"> <a href="http://quiz-vue-app.s3-website.eu-central-1.amazonaws.com/"> <div> <div> <h2>quiz-vue</h2> <div><h3>Edit description</h3></div> <div><p>quiz-vue-app.s3-website.eu-central-1.amazonaws.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/)"></div> </div> </div> </a> </div><h1 id="2153">Related Stories</h1><div id="c60e" class="link-block"> <a href="https://readmedium.com/why-you-should-learn-programming-through-books-672f1148abbb"> <div> <div> <h2>Why you Should Learn Programming through Books</h2> <div><h3>Books in our modern era are overshadowed, even if it reaps huge benefits in the long term.Here i explain why you should…</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*XhMc-r3HY9fgxVQunNhb0w.jpeg)"></div> </div> </div> </a> </div><div id="f87d" class="link-block"> <a href="https://python.plainenglish.io/dockerize-your-flask-and-mongodb-app-c2b2faf3e50"> <div> <div> <h2>Dockerize Your Flask & MongoDB App</h2> <div><h3>A simple tutorial on how to deploy your Python’s Flask & MongoDB app in a Docker container.</h3></div> <div><p>python.plainenglish.io</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*CXtLmFn7k3L_nOMBZl_Rng.jpeg)"></div> </div> </div> </a> </div><div id="b0fd" class="link-block"> <a href="https://readmedium.com/3-reasons-i-am-learning-devops-as-a-developer-ee72bdd6d806"> <div> <div> <h2>3 Reasons I am learning DevOps as a developer</h2> <div><h3>As a developer programming shouldn’t be your only focus on as requirements increase so does the essentials of knowing…</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*J9O2YzO8WlS5GFHnsB2u_Q.jpeg)"></div> </div> </div> </a> </div></article></body>

How to deploy your web framework or library to AWS S3 bucket

As you may know AWS S3 buckets can be used for hosting static websites. Setting up such a bucket via the AWS web console takes in retrospect few minutes but there are few steps to take into consideration that sometimes get’s omitted into typical guide thus I hope this guide helps you.

My example is with VueJS but the framework/library you choose plays no difference as all of them have npm build command for deployment and you should get a build or dist directory.

Creating a S3 bucket

If you haven’t created your AWS account yet register here the first year it is free of charge.

Luckily the search bar is quite helpful as there are a LOT of AWS services

For configurations it’s dead simple:

  1. Name your bucket
  2. Select your region
  3. Object ownership ACL(enable you to manage access to S3 buckets and objects) disable.
  4. Block Public Access uncheck it

Objects & Properties

Ones created go to your React, Vue, Angular, Svelte etc web app and run npm build and upload or drag the files in the Objects section.

Next up in properties in the far bottom the index document add index.html.

Permissions

The app will run without setting up permissions but most likely you will run into something like this. 👇

To solve it permission section should be adjusted.

  1. In the permission section Block public access (bucket settings) unmark it.
  2. Bucket policy has to be edited based on your bucket name etc and adding allow settings. My S3 bucket policy looks like this.
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:PutObject",
                "s3:PutObjectAcl",
                "s3:GetObject",
                "s3:GetObjectAcl",
                "s3:DeleteObject"
            ],
            "Resource": "arn:aws:s3:::quiz-vue-app/*"
        }
    ]
}

In Action section I needed Put, Get etc Objects. You can read more about it here. The Resource section in the value set your S3 bucket name as mine is defined quiz-vue-app. For more info regarding permission's check here.

Identity and Access Management (IAM)

Last up IAM I followed a guide about S3 deployment but it omitted IAM here is why it’s essential to set it up as well.

Loading data from an Amazon Simple Storage Service (Amazon S3) bucket requires an AWS Identity and Access Management (IAM) role that has access to the bucket.

I have set my users as GithubDeploy for automatic deployment with Github Actions but more on that on the next article. IAM gets really powerfull in cases like these. The Action section in the above bucket policy is in relation to IAM for more about it it can be read here. After all is done in the S3 bucket bottom of the properties you will see a external link that should work.

And that’s how it’s done there are other options like AWS Amplify but decided to start simple and slowly increase my knowledge about AWS, DevOps and share it with the community. I plan to get a book to get more insight on AWS as it has fast amount of services and want to simplify it as much as posible. Bellow you can my S3 bucket and luckily its free of charge(for now)!

Related Stories

AWS
DevOps
Web Development
Cloud Computing
Cloud Services
Recommended from ReadMedium