<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: David Meadows</title>
    <description>The latest articles on DEV Community by David Meadows (@dmeadows8585).</description>
    <link>https://dev.to/dmeadows8585</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1022110%2Fea06e6dd-f50d-4b2b-b355-6bb4a18d1498.jpeg</url>
      <title>DEV Community: David Meadows</title>
      <link>https://dev.to/dmeadows8585</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dmeadows8585"/>
    <language>en</language>
    <item>
      <title>Explain Forward and Reverse proxies Like I'm Five</title>
      <dc:creator>David Meadows</dc:creator>
      <pubDate>Sat, 25 Mar 2023 04:06:41 +0000</pubDate>
      <link>https://dev.to/dmeadows8585/explain-forward-and-reverse-proxies-like-im-five-28ip</link>
      <guid>https://dev.to/dmeadows8585/explain-forward-and-reverse-proxies-like-im-five-28ip</guid>
      <description></description>
      <category>explainlikeimfive</category>
    </item>
    <item>
      <title>Hosting a static website in AWS</title>
      <dc:creator>David Meadows</dc:creator>
      <pubDate>Mon, 20 Feb 2023 02:29:31 +0000</pubDate>
      <link>https://dev.to/dmeadows8585/hosting-a-static-reactjs-app-in-aws-5769</link>
      <guid>https://dev.to/dmeadows8585/hosting-a-static-reactjs-app-in-aws-5769</guid>
      <description>&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;It is easy to forget how overwhelming software developing can be. Let's say you are a frontend developer who is passionate about creating a website and getting it out in front of users. The journey of learning how to code a frontend and all that goes with it is already a long journey. &lt;/p&gt;

&lt;p&gt;However, it does not stop there, you realize that your wonderful website does no good to anybody unless you deploy it. The reality is that frontend developers can benefit from having at least some knowledge of deploying and maintaining a backend.&lt;/p&gt;

&lt;p&gt;In this post, I will detail how to set up and deploy a static website using an AWS S3 bucket.&lt;/p&gt;

&lt;h2&gt;
  
  
  Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create Bucket&lt;/li&gt;
&lt;li&gt;Update Bucket Permissions&lt;/li&gt;
&lt;li&gt;Enable Static Website Hosting&lt;/li&gt;
&lt;li&gt;Upload the Website Files&lt;/li&gt;
&lt;li&gt;Summary&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Create Bucket &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Fist navigate to the service S3 and click on the &lt;strong&gt;Create bucket&lt;/strong&gt; button to provision your bucket.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F677ypwsfk6m4eo834s18.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F677ypwsfk6m4eo834s18.png" alt="S3 service" width="800" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will enter a bucket name and then go with the default/recommended configuration options for now. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb0db8f2uy9bgspvysh31.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb0db8f2uy9bgspvysh31.png" alt="General configuration" width="800" height="473"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: Bucket names need to be unique across all accounts for all AWS regions within a particular partition.&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingBucket.html" rel="noopener noreferrer"&gt;AWS documentation - Buckets overview&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When finished selecting the desired configurations, click the &lt;strong&gt;Create bucket&lt;/strong&gt; button and wait for the bucket to be provisioned.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6xm9pdf4iunac1o9ghd1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6xm9pdf4iunac1o9ghd1.png" alt="Success" width="800" height="313"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Update Bucket Permissions &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Next, navigate to the &lt;strong&gt;Permissions&lt;/strong&gt; tab and update the public access settings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbvnre7anhleo7uxr9cgr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbvnre7anhleo7uxr9cgr.png" alt="Permissions" width="800" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Uncheck the &lt;strong&gt;Block all public access&lt;/strong&gt; checkbox. This should uncheck all of the checkboxes beneath. Save changes and continue.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3si5pamnga6x22151ko7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3si5pamnga6x22151ko7.png" alt="Edit Block public access" width="800" height="689"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will be warned and asked to confirm.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr8l1swoy6g3i7omxlwym.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr8l1swoy6g3i7omxlwym.png" alt="Edit Block public access confirm" width="603" height="307"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next update the Bucket policy. This will provide access to the files that are uploaded to the bucket.&lt;/p&gt;

&lt;p&gt;Here is the JSON object I used for the bucket policy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::devto-example-bucket/*"
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu6rfy5g9v5eoae68to1u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu6rfy5g9v5eoae68to1u.png" alt="Updating Bucket policy" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Enable Static Website Hosting &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Next navigate to the &lt;strong&gt;Properties&lt;/strong&gt; tab where the Static website hosting can be enabled.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkxexz0coxx7mzn5gyqok.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkxexz0coxx7mzn5gyqok.png" alt="static website hosting" width="800" height="90"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select &lt;em&gt;Enable&lt;/em&gt; Static website hosting and other options will appear. I will stick with the default settings except for the &lt;strong&gt;Index document&lt;/strong&gt;. The index document is where you can specify the default page for the website. I will choose index.html and leave the Error document field empty.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frtukku0m2hdkdgthcrs4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frtukku0m2hdkdgthcrs4.png" alt="Edit static website hosting" width="800" height="700"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the changes are saved there will now be a Bucket website endpoint.&lt;br&gt;
This endpoint is the url used to access the website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F78dt8b9zoqu2o72actke.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F78dt8b9zoqu2o72actke.png" alt="Bucket website endpoint" width="800" height="173"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Upload the Website Files &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Next, we can upload the files into the bucket that are needed for the website. In this example, I will only upload the index.html file.&lt;br&gt;
Click on the &lt;strong&gt;Objects&lt;/strong&gt; tab and then click on the &lt;strong&gt;Upload&lt;/strong&gt; button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F01h4zb7pkrsqjce6girs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F01h4zb7pkrsqjce6girs.png" alt="Objects tab view" width="800" height="327"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will select my index.html file that I made for this website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F70xmv64djq9y16w40aa6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F70xmv64djq9y16w40aa6.png" alt="upload index.html" width="800" height="656"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the contents of my simple index.html:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
        &amp;lt;title&amp;gt;My example Webpage&amp;lt;/title&amp;gt;
    &amp;lt;/head&amp;gt;
    &amp;lt;body&amp;gt;
        &amp;lt;h1&amp;gt;Hello There!&amp;lt;/h1&amp;gt;
    &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fta3sfqria6bmobt64qke.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fta3sfqria6bmobt64qke.png" alt="Upload succeeded" width="800" height="327"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That is it! Now use the endpoint that was created earlier in the &lt;strong&gt;Enable Static Website Hosting&lt;/strong&gt; step to navigate to the website. The Bucket website endpoint can be found under the &lt;strong&gt;Properties&lt;/strong&gt; tab.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F79audtgclw5s4mf1xwt5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F79audtgclw5s4mf1xwt5.png" alt="Testing website endpoint" width="665" height="239"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;In this post I summarized how to create a S3 bucket and then configure it as a static website. Although this example is extremely simple, using S3 in this way can be powerful. Imagine hosting a dynamic application built with React or Vue. Also adding a code pipeline for ease of build and deployment with a CDN distribution in front of the bucket. The sky is the limit to what can be built around this S3 static website bucket.&lt;/p&gt;

&lt;p&gt;If you run into any issues (particularly access issues), please refer to the section &lt;strong&gt;Update Bucket Permissions&lt;/strong&gt;. Permission issues are usually the main culprit for issues.&lt;/p&gt;

</description>
      <category>announcement</category>
      <category>devto</category>
      <category>web3</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>Explain CORS Like I'm Five</title>
      <dc:creator>David Meadows</dc:creator>
      <pubDate>Tue, 14 Feb 2023 02:10:24 +0000</pubDate>
      <link>https://dev.to/dmeadows8585/explain-cors-like-im-five-5420</link>
      <guid>https://dev.to/dmeadows8585/explain-cors-like-im-five-5420</guid>
      <description>&lt;p&gt;At a basic level, I think I understand CORS. I've read the wiki and have seen the diagrams. I have even been able to solve a couple of CORS issues I have had. However, I would love to hear simple explanations on the subject to get a different perspective. This will also help me explain the subject to other people who may not be familiar with the issues that arise with it.&lt;/p&gt;

</description>
      <category>explainlikeimfive</category>
    </item>
    <item>
      <title>Creating a code pipeline for your S3 static website</title>
      <dc:creator>David Meadows</dc:creator>
      <pubDate>Fri, 10 Feb 2023 04:35:09 +0000</pubDate>
      <link>https://dev.to/dmeadows8585/creating-a-code-pipeline-for-your-s3-static-website-4d8c</link>
      <guid>https://dev.to/dmeadows8585/creating-a-code-pipeline-for-your-s3-static-website-4d8c</guid>
      <description>&lt;p&gt;Having the ability to create a code pipeline to automate certain tasks is truly a gift. This is my attempt to summarize the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how to create a code pipeline in AWS &lt;/li&gt;
&lt;li&gt;how to use an existing GitHub repository as the code source&lt;/li&gt;
&lt;li&gt;how to build a static NextJS site&lt;/li&gt;
&lt;li&gt;how to sync the static files to an existing S3 bucket&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This summary does &lt;strong&gt;NOT&lt;/strong&gt; detail how to create a static website with S3. &lt;br&gt;
I detailed how to do that in the following post: &lt;a href="https://dev.to/dmeadows8585/hosting-a-static-reactjs-app-in-aws-5769"&gt;Hosting a static website in AWS&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create a CodePipeline in AWS&lt;/li&gt;
&lt;li&gt;Add Source Stage&lt;/li&gt;
&lt;li&gt;Create a connection&lt;/li&gt;
&lt;li&gt;Add Build Stage&lt;/li&gt;
&lt;li&gt;Run the pipeline&lt;/li&gt;
&lt;li&gt;Summary&lt;/li&gt;
&lt;li&gt;Troubleshooting a failed stage&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Create a CodePipeline in AWS &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;First log into AWS console and go to service &lt;strong&gt;CodePipeline&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5uyjxna1807b32vdy227.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5uyjxna1807b32vdy227.png" alt="Navigating to CodePipeline in the AWS console"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, click on the &lt;strong&gt;Create pipeline&lt;/strong&gt; button. For this pipeline, I am going to use my NextJS portfolio application as the code source. So I will simply name the pipeline &lt;em&gt;my-portfolio-app&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Note: Check the box to allow AWS CodePipeline to create a service role for this new pipeline.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3kwwbuh9vamyxa0ge32h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3kwwbuh9vamyxa0ge32h.png" alt="Choose pipeline settings"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Add Source Stage &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Next, this is where a code source is connected as an input to the pipeline. The drop down menu for the "Source provider" will have a few options to select from. In this case, I will select GitHub.&lt;/p&gt;

&lt;p&gt;There are two options to choose here (Version 1 &amp;amp; 2). Choose whichever option to connect to GitHub that suites you best.&lt;/p&gt;

&lt;p&gt;Note: In the AWS documentation version 2 is recommended.&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/codepipeline/latest/userguide/update-github-action-connections.html" rel="noopener noreferrer"&gt;GitHub source action&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgoschdx4u9yugiobag9j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgoschdx4u9yugiobag9j.png" alt="Add source stage"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Create a connection &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw7hmrlyb26murabbjeoj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw7hmrlyb26murabbjeoj.png" alt="Create a connection"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once a connection has been made to GitHub, you will be able to access your existing repositories. Choose the desired one from the drop down menu.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fszrbudcqdq51mmsp2jhj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fszrbudcqdq51mmsp2jhj.png" alt="Adding a source stage"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Add Build Stage &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Next is the build stage. This stage is optional, however a pipeline needs more than one stage. So I will add a build stage and skip the Deploy stage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnm1e8vowocghm1e6kl6m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnm1e8vowocghm1e6kl6m.png" alt="Adding the build stage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you do not have an existing build project you want to use, then click on the &lt;strong&gt;Create project&lt;/strong&gt; button.&lt;/p&gt;
&lt;h3&gt;
  
  
  Create build project
&lt;/h3&gt;

&lt;p&gt;For the &lt;strong&gt;Environment&lt;/strong&gt; configuration, I choose the following options:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fexdhbnxjg5rf2zr6f4x5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fexdhbnxjg5rf2zr6f4x5.png" alt="Environment configuration"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the &lt;strong&gt;Buildspec&lt;/strong&gt; option I selected &lt;em&gt;Use a buildspec file&lt;/em&gt; and left the Buildspec name empty.&lt;/p&gt;

&lt;p&gt;The rest I left as defaults.&lt;/p&gt;
&lt;h3&gt;
  
  
  Here is my buildspec.yml as an example
&lt;/h3&gt;

&lt;p&gt;Note: There are many ways to set up your buildspec file to successfully build a NextJS or ReactJS app. This is a very simplistic version.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: 0.2
phases:
  pre_build:
    commands:
      # install npm
      - echo Performing a npm install...
      - npm install
  build:
    commands:
      # run build script
      - npm run build
  post_build:
    commands:
      - aws s3 sync out &amp;lt;s3 bucket name&amp;gt;

artifacts:
  # include all files required to run application
  #    name: BuildArtifact
  files:
    - '**/*'
  base-directory: out
  discard-paths: no
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that for the build stage there is a command "npm run build"&lt;/p&gt;

&lt;p&gt;The build script I used to build my NextJs app is the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"build": "next build  &amp;amp;&amp;amp; next export"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will build the application in a directory named "out".&lt;/p&gt;

&lt;p&gt;In order to sync the built files that are in the "out" directory to a S3 bucket, I used the "aws s3 sync out " command.&lt;/p&gt;

&lt;p&gt;Note: To use the aws s3 sync command, make sure the codeBuild service role has the proper permissions (s3:ListBucket).&lt;/p&gt;

&lt;h3&gt;
  
  
  Add Deploy Stage
&lt;/h3&gt;

&lt;p&gt;For this particular pipeline example I skipped this stage.&lt;/p&gt;

&lt;p&gt;Next, review all steps and configurations. Click &lt;strong&gt;Create pipeline&lt;/strong&gt; button to continue.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run the pipeline &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The pipeline will automatically run for the first time. This particular pipeline is simple and hopefully will not have any issues.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fomikp2x4g17l907d8caq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fomikp2x4g17l907d8caq.png" alt="Results of running the pipeline"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Troubleshooting a failed stage &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;If the build stage fails, here are two common causes: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the buildspec.yml file has an error (typo, incorrect command, etc.)&lt;/li&gt;
&lt;li&gt;role permissions are incorrect (check specific policies attached to the codeBuild service role)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Once the pipeline has been created, each commit that is made to the selected repository branch ("main" in my case) should trigger the pipeline to build and sync the files to the specified S3 bucket. That means no more manually copying the built files over to a S3 bucket. 🎉🎉&lt;/p&gt;

&lt;p&gt;I hope this is helpful to someone. Good luck out there 👋&lt;/p&gt;

</description>
      <category>aws</category>
      <category>react</category>
      <category>github</category>
      <category>nextjs</category>
    </item>
  </channel>
</rss>
