{"componentChunkName":"component---src-templates-blog-post-js","path":"/serverless-website-sam-aws/","result":{"data":{"site":{"siteMetadata":{"title":"Fabrizio Fortunato","author":"Fabrizio Fortunato","siteUrl":"https://izifortune.com"}},"markdownRemark":{"id":"1275eee2-85c4-5a2f-98b6-7f5bfa71db23","excerpt":"A website can be considered serverless when it doesn’t need, directly, any server to operate. Serverless is quickly becoming a popular choice for running your…","html":"<p>A website can be considered serverless when it doesn’t need, directly, any server to operate. Serverless is quickly becoming a popular choice for running your services and also your entire website. Adopting a serverless architecture enables you and your organisation to focus on delivering business value. Every application must have an inherent amount of irreducible complexity states the <a href=\"https://en.wikipedia.org/wiki/Law_of_conservation_of_complexity\">Law of conservation of complexity</a>, the only question is who will have to deal with it. Using serverless we are offloading this complexity to someone else can take care of this for us.</p>\n<p>Working at RyanairLabs, I have the opportunity to work with amazing people every day and to try out s<em>erverless architecture</em> for the busiest travel website in Europe. Multiple pages of the <em>Ryanair</em> website are built using serverless technologies. Check out how we are using AWS serverless technologies in my talk at <a href=\"https://www.youtube.com/watch?v=8jSu31nQi1g&#x26;feature=youtu.be\">AWS Summit London</a>.</p>\n<h2>Serverless services</h2>\n<p>AWS has a wide range of serverless services entirely managed by AWS. What we will be focusing here are the basic building blocks to deploy a serverless website. The services are:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;\"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/dist/static/a0b9dd49dd3e05654ee8ab210d71a0b9/d9278/simple-architecture.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 29.054054054054056%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAIAAABM9SnKAAAACXBIWXMAAAsSAAALEgHS3X78AAAAr0lEQVQY052Qyw6CMBBF+//f5kqDLxQFgQItjz6gQ0tbmxjdEBPjWdzN5EzuDPIrnHP+N9DA+C46wjx/zJcL00IxhFyttjUr8y6VwFFe4P0hJrQNA601Y4wLbhffViAGTXJltJVSAMAYkKPS0xlH22wT1wdUlNUluRPaBdkYE2QhuLOellBlqnmoxVjGhvENaNXLtpM0aU6IC3G9pQBfaiu7PpVNPRF4NoD+fpjz7gnrclx15WMgGQAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"AWS serverless services for a website\"\n        title=\"AWS serverless services for a website\"\n        src=\"/dist/static/a0b9dd49dd3e05654ee8ab210d71a0b9/102e5/simple-architecture.png\"\n        srcset=\"/dist/static/a0b9dd49dd3e05654ee8ab210d71a0b9/83276/simple-architecture.png 148w,\n/dist/static/a0b9dd49dd3e05654ee8ab210d71a0b9/ba02f/simple-architecture.png 295w,\n/dist/static/a0b9dd49dd3e05654ee8ab210d71a0b9/102e5/simple-architecture.png 590w,\n/dist/static/a0b9dd49dd3e05654ee8ab210d71a0b9/74549/simple-architecture.png 885w,\n/dist/static/a0b9dd49dd3e05654ee8ab210d71a0b9/7213b/simple-architecture.png 1180w,\n/dist/static/a0b9dd49dd3e05654ee8ab210d71a0b9/d9278/simple-architecture.png 1446w\"\n        sizes=\"(max-width: 590px) 100vw, 590px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n  </a>\n    </span></p>\n<p><em>Cloudfront</em>: a high available CDN delivering your content worldwide through edge locations. We will use <em>Cloudfront</em> to take advantage of the edge caching for our website assets, routing each user request through the nearest edge location, without the need of contacting back the origin each time. <em>Cloudfront</em> also ensures the first level of security for our website, establishing a secure connection with the clients and by using <a href=\"https://aws.amazon.com/waf/\">WAF</a>.</p>\n<p><em>S3</em> an object storage service designed to be easy to use and managed. A website page is just a collection of static resources glued together by HTML. While developing web applications, a popular choice is to use a single page application (SPA) frameworks to reduce server-side complexity and improve interactivity. Ryanair website, for example, is built using Angular and Angularjs. Another rising technology is Javascript API Markup (JAM), fueled by static site generators. Both those technologies share a simple approach: they produce static assets which can be easily stored and served from an S3.</p>\n<p><em>Lambda at the Edge (L@E)</em>, you can execute any function closer to the viewer to add any additional logic between the edges and the origin. <em>L@E</em> acts as a glue between <em>Cloudfront</em> and the origin(s).</p>\n<h2>SAM</h2>\n<p>We will use <a href=\"https://github.com/awslabs/aws-sam-cli\">sam-cli</a>, an open-source framework for building a serverless application by AWS to reduce the boilerplate while working with Lambda @ Edge in the next articles.</p>\n<p>The assumption is that we have already configured aws-cli and sam-cli, if that is not the case you can follow the guide <a href=\"https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html\">here</a></p>\n<h2>Basic Infrastructure template</h2>\n<p>Building an application using sam-cli we will be using <em>Cloudformation</em> templates to describe our infrastructure resources. It gives us the ability to replicate, reuse and share infrastructure between projects quickly. A <em>Cloudformation</em> template powers all the Frontend projects that we are running in RyanairLabs, treating your infrastructure enables us to understand changes quickly, version them and collaborate on the infrastructure.</p>\n<p>Working with <em>sam-cli</em> or <em>Cloudformation</em> we tend to keep all the resources of a project in a single file making it easier to manage and deploy the resources. What we are looking to generate in our first iteration is a simple infrastructure that can serve any assets.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 590px;\"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/dist/static/a0b9dd49dd3e05654ee8ab210d71a0b9/d9278/simple-architecture.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 29.054054054054056%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAIAAABM9SnKAAAACXBIWXMAAAsSAAALEgHS3X78AAAAr0lEQVQY052Qyw6CMBBF+//f5kqDLxQFgQItjz6gQ0tbmxjdEBPjWdzN5EzuDPIrnHP+N9DA+C46wjx/zJcL00IxhFyttjUr8y6VwFFe4P0hJrQNA601Y4wLbhffViAGTXJltJVSAMAYkKPS0xlH22wT1wdUlNUluRPaBdkYE2QhuLOellBlqnmoxVjGhvENaNXLtpM0aU6IC3G9pQBfaiu7PpVNPRF4NoD+fpjz7gnrclx15WMgGQAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Basic infrastructure\"\n        title=\"Basic infrastructure\"\n        src=\"/dist/static/a0b9dd49dd3e05654ee8ab210d71a0b9/102e5/simple-architecture.png\"\n        srcset=\"/dist/static/a0b9dd49dd3e05654ee8ab210d71a0b9/83276/simple-architecture.png 148w,\n/dist/static/a0b9dd49dd3e05654ee8ab210d71a0b9/ba02f/simple-architecture.png 295w,\n/dist/static/a0b9dd49dd3e05654ee8ab210d71a0b9/102e5/simple-architecture.png 590w,\n/dist/static/a0b9dd49dd3e05654ee8ab210d71a0b9/74549/simple-architecture.png 885w,\n/dist/static/a0b9dd49dd3e05654ee8ab210d71a0b9/7213b/simple-architecture.png 1180w,\n/dist/static/a0b9dd49dd3e05654ee8ab210d71a0b9/d9278/simple-architecture.png 1446w\"\n        sizes=\"(max-width: 590px) 100vw, 590px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n  </a>\n    </span></p>\n<p>Let’s start by creating the template file called <code class=\"language-text\">template.yaml</code> with some of the basic services that we will need:</p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">AWSTemplateFormatVersion</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'2010-09-09'</span>\n<span class=\"token key atrule\">Transform</span><span class=\"token punctuation\">:</span> AWS<span class=\"token punctuation\">:</span><span class=\"token punctuation\">:</span>Serverless<span class=\"token punctuation\">-</span><span class=\"token datetime number\">2016-10-31</span>\n<span class=\"token key atrule\">Description</span><span class=\"token punctuation\">:</span> <span class=\"token punctuation\">></span><span class=\"token scalar string\">\n  Serverless website</span>\n\n<span class=\"token key atrule\">Resources</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">CloudFrontOriginAccessIdentity</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">Type</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'AWS::CloudFront::CloudFrontOriginAccessIdentity'</span>\n    <span class=\"token key atrule\">Properties</span><span class=\"token punctuation\">:</span>\n      <span class=\"token key atrule\">CloudFrontOriginAccessIdentityConfig</span><span class=\"token punctuation\">:</span>\n        <span class=\"token key atrule\">Comment</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'Serverless website OA'</span>\n\n  <span class=\"token key atrule\">CloudfrontDistribution</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">Type</span><span class=\"token punctuation\">:</span> <span class=\"token string\">\"AWS::CloudFront::Distribution\"</span>\n    <span class=\"token key atrule\">Properties</span><span class=\"token punctuation\">:</span>\n      <span class=\"token key atrule\">DistributionConfig</span><span class=\"token punctuation\">:</span>\n        <span class=\"token key atrule\">Comment</span><span class=\"token punctuation\">:</span> <span class=\"token string\">\"Cloudfront distribution for serverless website\"</span>\n        <span class=\"token key atrule\">DefaultRootObject</span><span class=\"token punctuation\">:</span> <span class=\"token string\">\"index.html\"</span>\n        <span class=\"token key atrule\">Enabled</span><span class=\"token punctuation\">:</span> <span class=\"token boolean important\">true</span>\n        <span class=\"token key atrule\">HttpVersion</span><span class=\"token punctuation\">:</span> http2\n        <span class=\"token comment\"># List of origins that Cloudfront will connect to</span>\n        <span class=\"token key atrule\">Origins</span><span class=\"token punctuation\">:</span>\n          <span class=\"token punctuation\">-</span> <span class=\"token key atrule\">Id</span><span class=\"token punctuation\">:</span> s3<span class=\"token punctuation\">-</span>website\n            <span class=\"token key atrule\">DomainName</span><span class=\"token punctuation\">:</span> <span class=\"token tag\">!GetAtt</span> S3Bucket.DomainName\n            <span class=\"token key atrule\">S3OriginConfig</span><span class=\"token punctuation\">:</span>\n              <span class=\"token comment\"># Restricting Bucket access through an origin access identity</span>\n              <span class=\"token key atrule\">OriginAccessIdentity</span><span class=\"token punctuation\">:</span> \n                <span class=\"token key atrule\">Fn::Sub</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'origin-access-identity/cloudfront/${CloudFrontOriginAccessIdentity}'</span>\n        <span class=\"token comment\"># To connect the CDN to the origins you need to specify behaviours</span>\n        <span class=\"token key atrule\">DefaultCacheBehavior</span><span class=\"token punctuation\">:</span>\n          <span class=\"token comment\"># Compress resources automatically ( gzip )</span>\n          <span class=\"token key atrule\">Compress</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'true'</span>\n          <span class=\"token key atrule\">AllowedMethods</span><span class=\"token punctuation\">:</span>\n            <span class=\"token punctuation\">-</span> GET\n            <span class=\"token punctuation\">-</span> HEAD\n            <span class=\"token punctuation\">-</span> OPTIONS\n          <span class=\"token key atrule\">ForwardedValues</span><span class=\"token punctuation\">:</span>\n            <span class=\"token key atrule\">QueryString</span><span class=\"token punctuation\">:</span> <span class=\"token boolean important\">false</span>\n          <span class=\"token key atrule\">TargetOriginId</span><span class=\"token punctuation\">:</span> s3<span class=\"token punctuation\">-</span>website\n          <span class=\"token key atrule\">ViewerProtocolPolicy</span> <span class=\"token punctuation\">:</span> redirect<span class=\"token punctuation\">-</span>to<span class=\"token punctuation\">-</span>https\n\n  <span class=\"token key atrule\">S3Bucket</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">Type</span><span class=\"token punctuation\">:</span> AWS<span class=\"token punctuation\">:</span><span class=\"token punctuation\">:</span>S3<span class=\"token punctuation\">:</span><span class=\"token punctuation\">:</span>Bucket\n    <span class=\"token key atrule\">Properties</span><span class=\"token punctuation\">:</span>\n      <span class=\"token comment\"># Change bucket name to reflect your website</span>\n      <span class=\"token key atrule\">BucketName</span><span class=\"token punctuation\">:</span> &lt;YOURSWEBSITE.COM<span class=\"token punctuation\">></span>\n\n  <span class=\"token key atrule\">S3BucketPolicy</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">Type</span><span class=\"token punctuation\">:</span> AWS<span class=\"token punctuation\">:</span><span class=\"token punctuation\">:</span>S3<span class=\"token punctuation\">:</span><span class=\"token punctuation\">:</span>BucketPolicy\n    <span class=\"token key atrule\">Properties</span><span class=\"token punctuation\">:</span>\n      <span class=\"token key atrule\">Bucket</span><span class=\"token punctuation\">:</span> <span class=\"token tag\">!Ref</span> S3Bucket\n      <span class=\"token key atrule\">PolicyDocument</span><span class=\"token punctuation\">:</span>\n      <span class=\"token comment\"># Restricting access to cloudfront only.</span>\n        <span class=\"token key atrule\">Statement</span><span class=\"token punctuation\">:</span>\n          <span class=\"token punctuation\">-</span>\n            <span class=\"token key atrule\">Effect</span><span class=\"token punctuation\">:</span> Allow\n            <span class=\"token key atrule\">Action</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'s3:GetObject'</span>\n            <span class=\"token key atrule\">Resource</span><span class=\"token punctuation\">:</span>\n              <span class=\"token punctuation\">-</span> <span class=\"token tag\">!Sub</span> <span class=\"token string\">\"arn:aws:s3:::${S3Bucket}/*\"</span>\n            <span class=\"token key atrule\">Principal</span><span class=\"token punctuation\">:</span>\n              <span class=\"token key atrule\">AWS</span><span class=\"token punctuation\">:</span> <span class=\"token tag\">!Sub</span> <span class=\"token string\">\"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ${CloudFrontOriginAccessIdentity}\"</span></code></pre></div>\n<p>Going through the  template file defined we have different services listed here:</p>\n<p><code class=\"language-text\">CloudfrontOriginAccessIdentity</code><em>,</em> used to restrict access to the <em>Bucket</em> files only for requests coming through <em>Cloudfront</em>. We don’t have to make our <em>Bucket</em> public or neither enable website hosting by using an <em>OriginAccessIdentity</em>. The <em>OriginAccessIdentity</em> will be used in the <em>CloudfrontDistribution Origin</em> and the S3<em>BucketPolicy.</em></p>\n<p><code class=\"language-text\">CloudfrontDistribution</code><em>,</em> it is <em>AWS</em> <em>CDN</em> to deliver data and content with low latency globally. There are a series of attributes in the <em>DistributionConfig</em> which controls the <em>CDN.</em> I left different comments on the file to explain further if you want to have a look at a complete list of the attributes you can follow the <a href=\"%5Bhttps://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudfront-distribution.html%5D(https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudfront-distribution.html)\">User Guide</a>.</p>\n<p><code class=\"language-text\">S3Bucket</code><em>,</em> this is the <em>Bucket</em> where we will store all the assets of the website. Remember to give the <em>BucketName</em> a correct and unique identifier for example we can use the domain name of the website to help you remember which <em>Bucket</em> belongs to which website.</p>\n<p><code class=\"language-text\">S3BucketPolicy</code><em>,</em> which defines who can access and what type of operations are permitted in the <em>Bucket.</em> Using the <em>OriginAccessIdentity</em> we are restricting read access only to <em>Cloudfront</em>.</p>\n<h2>Deploying infrastructure</h2>\n<p>We can already start deploying our first serverless website only with the four resources listed before. We will host the website assets on the <em>S3Bucket,</em> Cache and serve content in <em>Cloudfront.</em> To deploy the infrastructure with sam-cli we need to generate first an <em>S3 Bucket</em> used to store the deployment package containing all the different inputs for your infrastructure.</p>\n<p>On the commands below <em>remember</em> always to substitute &#x3C;YOURSWEBSITE.COM> with the actual domain name of your website.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">aws s3 mb s3://<span class=\"token operator\">&lt;</span>YOURSWEBSITE.COM<span class=\"token operator\">></span>-sam --region<span class=\"token operator\">=</span>us-east-1</code></pre></div>\n<p>After the Bucket is created we can package the application:</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">sam package --output-template-file packaged.yaml --s3-bucket <span class=\"token operator\">&lt;</span>YOURSWEBSITE.COM<span class=\"token operator\">></span>-sam</code></pre></div>\n<p>And finally deploy the application:</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">sam deploy --template-file packaged.yaml --stack-name <span class=\"token operator\">&lt;</span>yourwebsite<span class=\"token operator\">></span> --capabilities CAPABILITY_IAM --region us-east-1</code></pre></div>\n<p>We are using <em>us-east-1</em> as a default region for our infrastructure to reduce some of the limitations that we will encounter later on while defining <em>Lambda @ Edge</em>, where they can only be deployed into that region.</p>\n<p>Creating the <em>Cloudfront</em> distribution will take some time, generally between 20-30 mins at first. The Distribution, after the deployment is completed, will have an AWS generated domain name with the format <a href=\"http://d3k1beyfkv9165.cloudfront.net/\"><code class=\"language-text\">d3k1beyfkv2133.cloudfront.net</code></a> usable for making our first request to the website.</p>\n<p>To test out that everything is working we can upload an <code class=\"language-text\">index.html</code> in the root folder of the <em>S3Bucket eg:</em></p>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre class=\"language-html\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>html</span><span class=\"token punctuation\">></span></span>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>body</span><span class=\"token punctuation\">></span></span>\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>h1</span><span class=\"token punctuation\">></span></span>Hello serverless<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>h1</span><span class=\"token punctuation\">></span></span>\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span> <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation\">=</span><span class=\"token punctuation\">\"</span>https://github.com/awslabs/serverless-application-model/blob/master/aws_sam_introduction.png<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>body</span><span class=\"token punctuation\">></span></span>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>html</span><span class=\"token punctuation\">></span></span></code></pre></div>\n<p>To upload the file we can use the <em>aws-cli</em> command:</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">aws s3 <span class=\"token function\">cp</span> index.html s3://<span class=\"token operator\">&lt;</span>YOURWEBSITE.COM<span class=\"token operator\">></span> --acl public-read</code></pre></div>\n<p>Once the file is uploaded if we now navigate to the <em>Cloudfront DomainName</em> we should be able to see:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto;  max-width: 509px;\"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/dist/static/ad25eb5c1d41a31fa5f41c7ef663e5e9/80324/hello-serverless.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 120.94594594594594%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAYCAIAAAB1KUohAAAACXBIWXMAAAsSAAALEgHS3X78AAACyUlEQVQ4y62U7U9ScRTHeVNvqhf9A/4Dvell843NsR42dWnJ8gVaPqRr+bh0rU3TfMpVw0JcPiVaQFlTUVEQuOZ1Vy4qDwpGQpcB2ZBEBdYVL1zu7Re3OUegtnX223d3O+fzO+f8du5hyWQyCIL0ej2GYTqdDqhGo0FR1O120zRNURSd2FharRaEmkwms9lsNBrtdrvBYEAQxOVyHQ0nclBUJBIhoyeSEI5EjYrGMhoOh2OCGNfRmZmgje8uRD05NSyelUud2Br1JzmVEGYwMhyWivuq87PKcq6U5lwGpyo3fZDfGvDt/P0ErIO1AR3ofJaWfK4gi13GzSzP45TnZVfmZtzjsIUvmvezxMLMlf6d7e72tvIiLvtiSntVukOYBD8/X1tWeL+QU8FNw2xr+zni9BwOhYBaTTpJ0+3gaDLWf9L37qxVckvwILc4m61f1B4G0xQJCjB8eEq0sOjuU4u1Z742n6ZfnXA0JN3MuLTucvwOiQszV6qVytKsC3BHBfq6Hu5tnO97tDTwuKMktbX+YUza2J5/eDbucK6WcDnKcYlV3mZDxDZIYJLzxe8/ejc3E742mCSgw5KBgmspgsbKDbTfOtawPcdzylscipYt29yKaXXL643hWQdr7uE1FWWming19GchbenFVAL/Uhf9pSfinF5f/0aSZPwhYWAh/8ndbHZ1wQ2DBkKmRGZoUCMTIirp0iL4fRYSjicD6zVw8fXUmvzMsbHxOdW4G365vdA3MiRSKNXBXfywCWNM1MPnNdeplAo3KtQN1dGrnebZt59gJEQQR8CMz2KxTCpUDuQNvdq1q++eV08o1TM4/vNY8N4egc5MKEYlWkgKK0amhweddmvcxRB/GQR9nmDAS5A0EQrhXhcZ2vu3TXIci1O23+9fXjaCzj0eD9hkBoPe5/Mdt2ywhgKBAI7j4AMoIInoU//nsn8BYOj5JB+BkrkAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Hello serverless page\"\n        title=\"Hello serverless page\"\n        src=\"/dist/static/ad25eb5c1d41a31fa5f41c7ef663e5e9/80324/hello-serverless.png\"\n        srcset=\"/dist/static/ad25eb5c1d41a31fa5f41c7ef663e5e9/83276/hello-serverless.png 148w,\n/dist/static/ad25eb5c1d41a31fa5f41c7ef663e5e9/ba02f/hello-serverless.png 295w,\n/dist/static/ad25eb5c1d41a31fa5f41c7ef663e5e9/80324/hello-serverless.png 509w\"\n        sizes=\"(max-width: 509px) 100vw, 509px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n  </a>\n    </span></p>\n<p>In the next articles to come, we will explore how we can serve multiple pages, secure, handle rewrites, associate a domain and finally how to correctly deploy assets on our serverless website. This is a lot to cover in a single article so don’t forget to follow me on twitter <a href=\"https://twitter.com/izifortune\">@izifortune</a> to get updates.</p>\n<p><strong>PS:  AWS CloudDevelopmentKit</strong></p>\n<p>The AWS CDK is now generally available, if you are looking to have programmatic access to create AWS resources have you can have a look at the examples below: <a href=\"https://aws.amazon.com/blogs/aws/aws-cloud-development-kit-cdk-typescript-and-python-are-now-generally-available/\">https://aws.amazon.com/blogs/aws/aws-cloud-development-kit-cdk-typescript-and-python-are-now-generally-available/</a></p>","frontmatter":{"title":"Build a serverless website with SAM on AWS","date":"July 17, 2019","description":null,"socialImage":{"childImageSharp":{"fixed":{"src":"/dist/static/311b4f8931d2415c7fb2c289e5302d42/9f2d5/serverless-website-aws.png"}}},"image":null}}},"pageContext":{"slug":"/serverless-website-sam-aws/","previous":{"fields":{"slug":"/lighthouse-architecture-demystified/"},"frontmatter":{"title":"Lighthouse architecture demystified"}},"next":{"fields":{"slug":"/share-angular-libraries-with-lerna/"},"frontmatter":{"title":"Share Angular libraries with lerna"}}}}}