{"componentChunkName":"component---src-templates-blog-post-js","path":"/gatsby-gitlab-aws/","result":{"data":{"markdownRemark":{"html":"<p>Gatsby is an open-source web framework that lets you build really fast and secure websites. I love because it gives me a lot of control without a lot of complexity. This replaced Wordpress for any of my personal projects.</p>\n<p>I've used and deployed Gatsby before using <a href=\"https://www.netlify.com/\">Netlify</a>. It provided a lot of features without a lot of effort such as built-in CI/CD, domain and DNS management, and even automated previews of every commit to your Git repo. The best part: they provide these features on the free tier!</p>\n<p>I wanted to replicate some of that here. I will provide a walkthrough of how to deploy your <a href=\"https://www.gatsbyjs.org/\">GatsbyJS</a> site to <a href=\"https://aws.amazon.com/s3/\">AWS S3</a> using <a href=\"https://about.gitlab.com/\">GitLab</a> CICD pipelines.</p>\n<h1>Prerequisites</h1>\n<ul>\n<li>You have an AWS account. <a href=\"https://aws.amazon.com/\">Create an account here</a></li>\n<li>You have your code hosted on GitLab. <a href=\"https://gitlab.com/users/sign_up\">Create an account here</a></li>\n<li>A Gatsby site. If you don't have one already, you can create one quickly from a <a href=\"https://www.gatsbyjs.org/docs/quick-start\">starter template</a>.</li>\n</ul>\n<h3>Steps</h3>\n<p>The walkthrough is didvided into two parts: the AWS and GitLab setup</p>\n<h4>AWS Setup</h4>\n<ul>\n<li>Step 1: Create the S3 bucket</li>\n<li>Step 2: Configure the bucket for static website hosting</li>\n<li>Step 3: Attach new policy</li>\n<li>Step 4: Create new policy for new IAM user</li>\n<li>Step 5: Create IAM User</li>\n</ul>\n<h4>GitLab Setup</h4>\n<ul>\n<li>Step 1: Add CI/CD Variables</li>\n<li>Step 2: Create and configure .gitlab-ci.yml</li>\n</ul>\n<h1>AWS Setup</h1>\n<h2>Step 1: Create the S3 bucket</h2>\n<p>Create a new S3 bucket that is publicly accessible. </p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; box-shadow: 0px 0px 8px 0px rgba(0,0,0,0.6) !important; max-width: 800px;\"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 31.666666666666664%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAIAAABM9SnKAAAACXBIWXMAAAsSAAALEgHS3X78AAAAq0lEQVQY041PyxLCIAzs//+letE+oCXhGRIM7dhRx4M7O0sgkF0G771zThURVYmo/odCNDgHl+ttmmZmbq2xyIt8FOdBE2lv0PtDTAkQHQCgxxB8CKApdsIexmIaXeeMacJyTuiP1dlYqxlyzillLSqzpuKunVSlVMmVE1Vi+XDW8ffHaOw6L2Yxtn+7UjmgK9GuJZccY2xNTqjBsKq19xvAQd3abftJbX3xCUYcXI3wNsrXAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"General Configuration\"\n        title=\"General Configuration\"\n        src=\"/static/d375a5e7fcb9e097f3896283adcff033/5a190/s3-bucket-general-configuration.png\"\n        srcset=\"/static/d375a5e7fcb9e097f3896283adcff033/5a46d/s3-bucket-general-configuration.png 300w,\n/static/d375a5e7fcb9e097f3896283adcff033/0a47e/s3-bucket-general-configuration.png 600w,\n/static/d375a5e7fcb9e097f3896283adcff033/5a190/s3-bucket-general-configuration.png 800w\"\n        sizes=\"(max-width: 800px) 100vw, 800px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<ol>\n<li>Once you are at the <a href=\"https://s3.console.aws.amazon.com/\">S3 console</a> in AWS and click Create bucket</li>\n<li>Name the bucket</li>\n<li>Select a region</li>\n</ol>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; box-shadow: 0px 0px 8px 0px rgba(0,0,0,0.6) !important; max-width: 800px;\"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 84.33333333333333%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAARCAIAAABSJhvpAAAACXBIWXMAAAsSAAALEgHS3X78AAACDElEQVQ4y12T2babMAxF+f+/60v70IYZbDBTEmymkHTLzs26raJoadkafQ5R25rLJc7yPE6SNM0wOFmWK6XWt2yi/P6Vfd8jY/o4SZM0w0qy15RiRal0o5QWrZXWGlNWdV1z0FS1cs5F/TAWZVVVigs0y8uirLkjOcsLbJzXP5PyUqi2bbVuydRN2xhjrY2cW6435H693u73+TPnsq6LuJtb9/uyue04z8d/Eu3H0bSGVkzTdX3YR5K23a+6hWKLiBS2ThwMS0fnec7WhpnZhw3YgoGxzIyKV6tKAuS8HwbSKEiiJFOPNVh+mq7jR8dJ1DtccTl4h5PpesMyW/TwnaneNC1jt8awRSuKGA6HYeQteJQJGUdyXl8iydY6JVg0hDKC/iCkNKtwbExH0R4ZBhp0XQdOkszYPPh7Z4lWaICUEYgn2ogi5I6hEBvKaz+fT6D6/edCQ4L8wKbzDnG+VSdOPwQLotySIp358+5VrRcPj+i+B/4JWh62ANLyJuvmnY2u0UH75xO0haxexDmOt+9JvO1vOn9iEIEKyOyvH0WaeoaHr6KA3peYr0WIK2gLT0UhP99MHCdlWR2PI6LFOvS1NuF5w5vDN1iBD0gBJ9Qt7viaCIeRI6Y+zpeebKO1klRBi0eGkFDfs3IBDnwSX98EjKPZOnBGoIr19j7Ps6St4dvwXF4Dnwn4rn8Bxgq7Uis2MsIAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Bucket Public Access\"\n        title=\"Bucket Public Access\"\n        src=\"/static/82eb5c6faf2c6db09a9e4a33bdc4bfc9/5a190/s3-bucket-public-access.png\"\n        srcset=\"/static/82eb5c6faf2c6db09a9e4a33bdc4bfc9/5a46d/s3-bucket-public-access.png 300w,\n/static/82eb5c6faf2c6db09a9e4a33bdc4bfc9/0a47e/s3-bucket-public-access.png 600w,\n/static/82eb5c6faf2c6db09a9e4a33bdc4bfc9/5a190/s3-bucket-public-access.png 800w\"\n        sizes=\"(max-width: 800px) 100vw, 800px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<ol start=\"4\">\n<li>Uncheck \"Block all public access\"</li>\n<li>Acknowledge the warning by checking the box</li>\n<li>Then click \"Create bucket\"</li>\n</ol>\n<h2>Step 2: Configure the bucket for static website hosting</h2>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; box-shadow: 0px 0px 8px 0px rgba(0,0,0,0.6) !important; max-width: 420px;\"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 112.33333333333333%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAWCAIAAABPIytRAAAACXBIWXMAAAsSAAALEgHS3X78AAACeElEQVQ4y31Uy04UQRSdrzNq3PgE3fiKJiQGE9DEsNKNX+HOBBJAYhwhyhh1Ie6MiRvFdmBgGKWbHrqq6/3q8VY1MDM9oyc3lXsrdeqeOlXdtam15vnFaPJl82q9da2+PbkcTSxHV5aiiaWozMu4tPjz4kBcWIxur3yv3ahvnZqPzi5E55a3Lq+1p9fbU6s7N1+17r3Zhbjzeufu6s702/ateuv0fHRm4SgmVravv9isPfnUud/oPPjw+9FGPPc5fvi+M9vYnW20q/GuPbPuk5mGT2C7ufVfNSlEr3BGcmu0sIUwBdeFsE6GHCIkvpTGMe0gV8b1ej1KSE1JiZnoxCmlNCEypSrO5QFRh1x3qdpDcp/qlJsuN0hYGDNhc2mBTIDcM/JHQr/u4UIxSnJGsKBE0JxTwnCWIJIwA6shiqLoBZSJ78w5D7WTEk4glRRJLpH0wo7WDqM4JpMTsnOOMQbKOYxCCmWs8dBmBNaWu/TJ1tokOYjjJMuQ0bpUMRqcCxirZOgsApTgexnD3pLCFWNwon+InOc5QhhsANlSaZCtx4j2GCM7TbugPMg2KkAruMchBHHjZBOwizEoYRb6Z5i0MhmsrWquug21DjiW5jOljXN2MGABtBnT+WT2P/Ci5Yhs6AzkEWvdIKCGkw2RYTM4gRcKDgXZMGCh4TEY66wd4ldlAxkYcPk490AYHSLUznVXOPgkqB7zTvuGebLWQA5MjHO/CcEY5v91chfIeUmGIqjV/fuUEsRXnpT3IERfNjTLECrJg0tHAd/zH6KJcs+/dZ9uxM39rAYiwXBgwpOyFX+OAbPw0uE/EaU8ZerZl/jxx85mJ/0LMUrJ03xUFO0AAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Static Hosting\"\n        title=\"Static Hosting\"\n        src=\"/static/a20d629e2b6be80ac68a7abc8fe5c5ff/d10fb/s3-bucket-static-hosting.png\"\n        srcset=\"/static/a20d629e2b6be80ac68a7abc8fe5c5ff/5a46d/s3-bucket-static-hosting.png 300w,\n/static/a20d629e2b6be80ac68a7abc8fe5c5ff/d10fb/s3-bucket-static-hosting.png 420w\"\n        sizes=\"(max-width: 420px) 100vw, 420px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<ol>\n<li>Go to your newly created bucket and go to properties</li>\n<li>Click on Static website hosting</li>\n<li>Select \"User this bucket to host a website</li>\n<li>Use \"index.html\" for both the Index and Error document.</li>\n</ol>\n<h2>Step 3: Attach new policy</h2>\n<p>Attach a new policy to the bucket that allows public access.</p>\n<ol>\n<li>Go to permisssions</li>\n<li>Select \"Bucket policy\"</li>\n<li>\n<p>Copy and paste the policy below to allow the public to read files from this bucket</p>\n<pre><code>{\n\"Version\": \"2012-10-17\",\n\"Statement\": [\n    {\n        \"Sid\": \"PublicReadGetObject\",\n        \"Effect\": \"Allow\",\n        \"Principal\": \"*\",\n        \"Action\": \"s3:GetObject\",\n        \"Resource\": \"arn:aws:s3:::mydomain.com/*\"\n    }\n]\n}\n</code></pre>\n<p>At this point, you can host your Gatsby site by copying the contents of the \"public\" directory to this S3 bucket after you've run <code>npm run build</code> on your local machine. However, I'm sure you're reading this for the CI/CD part. Keep reading!</p>\n</li>\n</ol>\n<h2>Step 4: Create new policy for new IAM user</h2>\n<p>Here, you are creating a new policy to use for a new user we will be creating in Step 5. The policy provides seeing what buckets are available as well as read and write permissions on the specified S3 bucket.</p>\n<ol>\n<li>Go to the IAM console and select \"Policies\" on the left navigation</li>\n<li>Click create policy</li>\n<li>Select the JSON tab</li>\n<li>Copy &#x26; paste the policy below</li>\n<li>Click \"Review Policy\"</li>\n<li>Name the policy</li>\n<li>\n<p>Click \"Create policy\"</p>\n<pre><code>{\n\"Version\": \"2012-10-17\",\n\"Statement\": [\n    {\n        \"Sid\": \"VisualEditor0\",\n        \"Effect\": \"Allow\",\n        \"Action\": [\n            \"s3:PutAccountPublicAccessBlock\",\n            \"s3:GetAccountPublicAccessBlock\",\n            \"s3:ListAllMyBuckets\",\n            \"s3:HeadBucket\"\n        ],\n        \"Resource\": \"*\"\n    },\n    {\n        \"Sid\": \"VisualEditor1\",\n        \"Effect\": \"Allow\",\n        \"Action\": \"s3:*\",\n        \"Resource\": [\n            \"arn:aws:s3:::mydomain.com/*\",\n            \"arn:aws:s3:::mydomain.com\"\n        ]\n    }\n]\n}\n</code></pre>\n</li>\n</ol>\n<h2>Step 6: Create IAM User</h2>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; box-shadow: 0px 0px 8px 0px rgba(0,0,0,0.6) !important; max-width: 800px;\"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 46.333333333333336%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAIAAAC9o5sfAAAACXBIWXMAAAsSAAALEgHS3X78AAAA1klEQVQoz42QiQ6CMBBE+/+fSUAqxNqT3uCwNQSNGl9I2aZ7zA4zxiilhBAppe0nIVcfy7atBwzFUkoUowXixQFLJ0U+ulAqpbYW6wlWCUTWWqX0XZn5Jt0S8pOSSz1y3rSw8wWvd5eFSdqX7Q9YW1gStHZFE3wYVV6BhFzXF9nNMK015yO/XiehLuM4DAPnXBPtFX9tnLQh5vxB9j6qws+Eyr7v53k2BGyLMYYQYorBe8SfdwZQjsqu6zB5miZMRLb3nrxfEED/1+JDRbP32Hz3nTh7/gB9mQ4LKm7g8gAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Create User\"\n        title=\"Create User\"\n        src=\"/static/92dcae671a590099ec6e8f79f0fd150a/5a190/iam-add-user-1.png\"\n        srcset=\"/static/92dcae671a590099ec6e8f79f0fd150a/5a46d/iam-add-user-1.png 300w,\n/static/92dcae671a590099ec6e8f79f0fd150a/0a47e/iam-add-user-1.png 600w,\n/static/92dcae671a590099ec6e8f79f0fd150a/5a190/iam-add-user-1.png 800w\"\n        sizes=\"(max-width: 800px) 100vw, 800px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<ol>\n<li>Name the user</li>\n<li>Check \"Programmatic Access\"</li>\n<li>Click \"Next: Permissions\"</li>\n<li>Select \"Attach existing policies directly\"</li>\n<li>In the search box, type in the name of the policy you created above</li>\n<li>Click \"Next: Tags\"</li>\n<li>Click \"Next: Review\"</li>\n<li>Click \"Create User\"</li>\n<li>You will be brought to a page to get the Access Key ID and Secret Access Key. Don't close this window yet, you will need this for the next step.</li>\n</ol>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; box-shadow: 0px 0px 8px 0px rgba(0,0,0,0.6) !important; max-width: 800px;\"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 9.333333333333334%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAACCAIAAADXZGvcAAAACXBIWXMAAAsSAAALEgHS3X78AAAAT0lEQVQI122LOwoAIQxEvf8ZgxiEkI/uhmCh3WZ7p3rzmClE1Hs3M70lfQ4AoLWWLCIJtVZEFNVCrww1d9+3nHPWWvlh5ojIOudk/sV4/AMil26yMT3MowAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"AccessKey\"\n        title=\"AccessKey\"\n        src=\"/static/60cc260be20673831eb48de503e265f2/5a190/iam-access-info.png\"\n        srcset=\"/static/60cc260be20673831eb48de503e265f2/5a46d/iam-access-info.png 300w,\n/static/60cc260be20673831eb48de503e265f2/0a47e/iam-access-info.png 600w,\n/static/60cc260be20673831eb48de503e265f2/5a190/iam-access-info.png 800w\"\n        sizes=\"(max-width: 800px) 100vw, 800px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<h1>GitLab</h1>\n<h2>Step 1: Add CI/CD Variables</h2>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; box-shadow: 0px 0px 8px 0px rgba(0,0,0,0.6) !important; max-width: 800px;\"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 46.666666666666664%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAIAAAC9o5sfAAAACXBIWXMAAAsSAAALEgHS3X78AAABLElEQVQoz41Qy27DIBD0n/dD+hU9Vuqpt0q9VlFvSfzCCQ6ODQbWeOlgrKi9dbRazOzM7uJCSnk+l6dzWVU1oq7bqm6Qa+SmrRtRNaJtBb6Rmy0T0ZrAhdHjcJNDf1X9pb+0t6tQMoXsGlyVGuRNTVo7c3fz5J1xVq9hiRuK6O/RXaPvee54LNd7Ch6rLcownGiojBKkjmwEmwtkMcy72TnnvbfWBewRIzODYI68lT1RKnuctCzLNE3I0Oxm75y1Vms9jiN5D2ohAplFeBmYnOG3dgaPebsZFBrPgDHbTEYZZAgh23KLzFsosMvD7DEG/yEBdgMRbND9npn3BB+IcEF5N69/sUmT+vGwDGzmZ/f6/fH09vxZHlJfXov4P9BCHNZDd3z5ej8pkdf5AT1qB3eXmya8AAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"CICD Variables\"\n        title=\"CICD Variables\"\n        src=\"/static/531b7d4e8269b3758844f20baff4bbc1/5a190/gitlab-cicd-variables.png\"\n        srcset=\"/static/531b7d4e8269b3758844f20baff4bbc1/5a46d/gitlab-cicd-variables.png 300w,\n/static/531b7d4e8269b3758844f20baff4bbc1/0a47e/gitlab-cicd-variables.png 600w,\n/static/531b7d4e8269b3758844f20baff4bbc1/5a190/gitlab-cicd-variables.png 800w\"\n        sizes=\"(max-width: 800px) 100vw, 800px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<ol>\n<li>Go to your repository in GitLab</li>\n<li>Select settings and CI/CD</li>\n<li>Expand the Variables section</li>\n<li>Add the key \"AWS_ACCESS_KEY_ID\" and \"AWS_SECRET_ACCESS_KEY\" and their values from the previous step</li>\n</ol>\n<h2>Step 2: Create and configure .gitlab-ci.yml</h2>\n<ol>\n<li>Create a file called <code>.gitlab-ci.yml</code> at the root of your repository</li>\n<li>Copy and past the following code</li>\n<li>Change the bucket name variable with yours</li>\n</ol>\n<pre><code>variables:\n  BUCKET_NAME_PRODUCTION: mydomain.com\n\nstages:\n  - build\n  - deploy\n\n# This folder is cached between builds\n# http://docs.gitlab.com/ce/ci/yaml/README.html#cache\ncache:\n  paths:\n    - node_modules/\n\nbuild-assets:\n  image: node:latest\n  stage: build\n  artifacts:\n    paths:\n      - public/\n  script:\n    - npm install\n    - npm run build\n\ndeploy-s3:\n  stage: deploy\n  image: python:3.8\n  before_script:\n    - pip3 install awscli --upgrade\n  script:\n    - aws s3 sync public s3://$BUCKET_NAME_PRODUCTION/ --delete\n  environment: production\n  only:\n    - master\n</code></pre>\n<p><code>variables</code> allows you to define values that you can use throughout your CICD configuration file. Here, we are specifying the bucket name</p>\n<pre><code>cache:\n  paths:\n    - node_modules/\n</code></pre>\n<p>We will be building our Gatsby site and we will need to grab all of our dependencies. This allows us to specify folders or files to cache in between runs</p>\n<pre><code>build-assets:\n  image: node:latest\n  stage: build\n  artifacts:\n    paths:\n      - public/\n  script:\n    - npm install\n    - npm run build\n</code></pre>\n<ul>\n<li>We are specifying a job called <code>build-assets</code>. This can be named anything you want.</li>\n<li>We specify this job is part of the build <code>stage</code></li>\n<li><code>image</code> specifies the docker image to use for the job. In this case, we are using the <code>node:latest</code>. See <a href=\"https://hub.docker.com/_/node?tab=tags\">https://hub.docker.com/_/node?tab=tags</a></li>\n<li><code>artifacts</code> are files and directories that are created by a job once it finishes. Here, we are specifying that we are creating a directory called \"public\"</li>\n<li>The <code>script</code> section describes what scripts will run. These are the same scripts that you'd be running locally on your computer.</li>\n<li>We are running <code>npm install</code> to install all of our dependencies</li>\n<li>When done, we run <code>npm run build</code> which Gatsby will generate the production version of our website. This will output to the \"public\" directory</li>\n</ul>\n<h2>Step 3: Commit and Push Code</h2>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; box-shadow: 0px 0px 8px 0px rgba(0,0,0,0.6) !important; max-width: 1000px;\"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 35%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAIAAACHqfpvAAAACXBIWXMAAAsSAAALEgHS3X78AAABOUlEQVQY05WP/UvCYBDH9///C77UTLJ8AdPQMXW6ptUMLSshEQyiMJhrotue556XPZ2N6Oc+HMeXO+7ue1pZr5dOTf24VdAvdd04yjdymXo+e5HNXOTzzeJJq1qxKpX++VmnVrbKpV6xYBT0VrVqN5vXWr89bLdvDMO1+veWNe32JmbnrtOd2FePtj0bjubueOG6L2N3YdqTmukM7Jk9mI1Gz47zoHFGhAClEgQYqEQoJX/iD5kkmG8/nnLTBhM0kVwpwRjRfN+P4xgAKKEkioEC5xwOMMb4IVAdNJNC4s60iISEaEGwDUMUOEgJSH8XEEolmgGIoogLEVOOOb0vk19HnO1WS20+f12vPzcbb7sL90QuvbcYCHZxeBsEFNieCDys0sdScFEUfrmOtlq9o3PP26B59R8owDc0SXiM1xgGHQAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"CICD Pipelines\"\n        title=\"CICD Pipelines\"\n        src=\"/static/d29278f5fb182e7177a627712b50fda8/00d43/gitlab-pipelines.png\"\n        srcset=\"/static/d29278f5fb182e7177a627712b50fda8/5a46d/gitlab-pipelines.png 300w,\n/static/d29278f5fb182e7177a627712b50fda8/0a47e/gitlab-pipelines.png 600w,\n/static/d29278f5fb182e7177a627712b50fda8/00d43/gitlab-pipelines.png 1000w\"\n        sizes=\"(max-width: 1000px) 100vw, 1000px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<ul>\n<li>Commit your changes and push to GitLab</li>\n<li>Go to your repository on GitLab and select CI/CD. If there were no issues with your <code>.gitlab-ci.yml</code> file, you should see a pipeline active with two jobs</li>\n</ul>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; box-shadow: 0px 0px 8px 0px rgba(0,0,0,0.6) !important; max-width: 420px;\"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 112.33333333333333%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAWCAIAAABPIytRAAAACXBIWXMAAAsSAAALEgHS3X78AAACeElEQVQ4y31Uy04UQRSdrzNq3PgE3fiKJiQGE9DEsNKNX+HOBBJAYhwhyhh1Ie6MiRvFdmBgGKWbHrqq6/3q8VY1MDM9oyc3lXsrdeqeOlXdtam15vnFaPJl82q9da2+PbkcTSxHV5aiiaWozMu4tPjz4kBcWIxur3yv3ahvnZqPzi5E55a3Lq+1p9fbU6s7N1+17r3Zhbjzeufu6s702/ateuv0fHRm4SgmVravv9isPfnUud/oPPjw+9FGPPc5fvi+M9vYnW20q/GuPbPuk5mGT2C7ufVfNSlEr3BGcmu0sIUwBdeFsE6GHCIkvpTGMe0gV8b1ej1KSE1JiZnoxCmlNCEypSrO5QFRh1x3qdpDcp/qlJsuN0hYGDNhc2mBTIDcM/JHQr/u4UIxSnJGsKBE0JxTwnCWIJIwA6shiqLoBZSJ78w5D7WTEk4glRRJLpH0wo7WDqM4JpMTsnOOMQbKOYxCCmWs8dBmBNaWu/TJ1tokOYjjJMuQ0bpUMRqcCxirZOgsApTgexnD3pLCFWNwon+InOc5QhhsANlSaZCtx4j2GCM7TbugPMg2KkAruMchBHHjZBOwizEoYRb6Z5i0MhmsrWquug21DjiW5jOljXN2MGABtBnT+WT2P/Ci5Yhs6AzkEWvdIKCGkw2RYTM4gRcKDgXZMGCh4TEY66wd4ldlAxkYcPk490AYHSLUznVXOPgkqB7zTvuGebLWQA5MjHO/CcEY5v91chfIeUmGIqjV/fuUEsRXnpT3IERfNjTLECrJg0tHAd/zH6KJcs+/dZ9uxM39rAYiwXBgwpOyFX+OAbPw0uE/EaU8ZerZl/jxx85mJ/0LMUrJ03xUFO0AAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Static Hosting\"\n        title=\"Static Hosting\"\n        src=\"/static/a20d629e2b6be80ac68a7abc8fe5c5ff/d10fb/s3-bucket-static-hosting.png\"\n        srcset=\"/static/a20d629e2b6be80ac68a7abc8fe5c5ff/5a46d/s3-bucket-static-hosting.png 300w,\n/static/a20d629e2b6be80ac68a7abc8fe5c5ff/d10fb/s3-bucket-static-hosting.png 420w\"\n        sizes=\"(max-width: 420px) 100vw, 420px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<ul>\n<li>Once the jobs are done, go to your S3 bucket and open the URL for your endpoint. Click on \"Static website hosting\" inside the Properties tab to get the URL.</li>\n</ul>\n<h1>Summary!</h1>\n<ul>\n<li>We created an S3 bucket and configured it for static website hosting</li>\n<li>We created a user account that GitLab can use to put files into your S3 bucket, your GatsbyJS generated files.</li>\n<li>We created a GitLab CI/CD configuration file, <code>.gitlab-ci.yml</code>, that generates GatsbyJS files from your code, then uploads it to your S3 bucket</li>\n</ul>\n<p>Checkout the source code on <a href=\"https://gitlab.com/eebalo/gatsby-starter-hello-world-cicd-aws\">GitLab</a></p>\n<h1>What's Next</h1>\n<p>Stay tuned for Part II where we use a custom domain for your website and setup a staging environment to test prior to going to production</p>","fields":{"slug":"/gatsby-gitlab-aws/"},"frontmatter":{"title":"Part I: Deploying Gatsby to AWS S3","description":"Use GitLab's CI/CD to deploy a Gatsby site to AWS S3","date":"2020-07-20T12:32:00.000Z","featuredImage":{"childImageSharp":{"fluid":{"base64":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAYAAAAIy204AAAACXBIWXMAAAsSAAALEgHS3X78AAABnklEQVQoz2NgAILmyDWMDGigwG8j438zBP+BoyYTjL3XVhdDPRw0hK4CK0wznmE8IXvr0v6sLXOq/Zcrww1y1VR84KypAGY7a8rdd9FUBbH9TSzYVPVteYGYSVnPjlndwJbXytKcFazJhbVJcnL+9lf9ybv/T0jZ+7/YZeFFbwYnbpDcQ3vN7kcumjUgNpCufGCv2Q9i6xnYugIN6QTibCCuVdO3LZbUdLQFG5hhOitgRceJ/+VeS77k28//MTFn6/8YpclGILnvLerXP8er/b1no3nyc5zanx8tardB4hp6Ni6cim5uLPLuTsxy7m4iak7mng7GvmADzRkqpRe3HHy3f8mt/4tqTvyfXrLzGjNDACdI7u9ateLfDWr//wXq/P8DoteqloPE/89k0P43g8Hp/yoG5f+bGOQ+TWJ2A4oFMbQnrAcHcKb5bPP2+PVrgHhhuEK/GkisRHUVWO73TDWbT9nqO39PV7OHhe3/xWyMQAM0/kxnCP49nTHw/xygwbMZmMGSk/K2YcayKyTmf/eoMSGL/wHy/58WxxnJADbcln+caIuUAAAAAElFTkSuQmCC","aspectRatio":2.985074626865672,"src":"/static/c95d8439318a54049791aaafc01d9cbc/ee604/gatsby-gitlab-aws.png","srcSet":"/static/c95d8439318a54049791aaafc01d9cbc/69585/gatsby-gitlab-aws.png 200w,\n/static/c95d8439318a54049791aaafc01d9cbc/497c6/gatsby-gitlab-aws.png 400w,\n/static/c95d8439318a54049791aaafc01d9cbc/ee604/gatsby-gitlab-aws.png 800w,\n/static/c95d8439318a54049791aaafc01d9cbc/f3583/gatsby-gitlab-aws.png 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}}}}},"pageContext":{"slug":"/gatsby-gitlab-aws/"}}}