<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Cloudfront on NetDevAiCloud[...]Ops</title><link>https://www.blog.francoispro.com/tags/cloudfront/</link><description>Recent content in Cloudfront on NetDevAiCloud[...]Ops</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Mon, 05 Oct 2026 10:05:00 +0200</lastBuildDate><atom:link href="https://www.blog.francoispro.com/tags/cloudfront/index.xml" rel="self" type="application/rss+xml"/><item><title>How this blog is built and deployed</title><link>https://www.blog.francoispro.com/posts/how-this-blog-is-deployed/</link><pubDate>Mon, 05 Oct 2026 10:05:00 +0200</pubDate><guid>https://www.blog.francoispro.com/posts/how-this-blog-is-deployed/</guid><description>&lt;p&gt;I wanted to create a simple static HTML blog. Among many technologies, I rapidly settled for Hugo&amp;rsquo;s ease of use and large user base. Architecture-wise, this site is a set of static files generated by Hugo, stored in a private S3 bucket and served through CloudFront. Publishing a post means pushing a Markdown file to GitHub, and launching a CI/CD pipeline ; everything after that is handled automatically.&lt;/p&gt;
&lt;h2 id="why-a-static-site"&gt;Why a static site&lt;/h2&gt;
&lt;p&gt;I used to have a VPS at Infomaniak. While I like their sustainability approach, I wanted ot try out the ease-of-use of the serverless framework without having to rent a dedicated VM.&lt;br&gt;
A blog does not need a server. Every page can be generated ahead of time, which leaves nothing to patch, nothing to scale and almost nothing to pay for. I wanted three things:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the source in Git: every change is versioned (I am a big proponent of versioning and declarative approaches in general) ;&lt;/li&gt;
&lt;li&gt;reduce friction: deployment on commit, so writing is the only manual step: I can write an article anywhere and have it posted from anywhere ;&lt;/li&gt;
&lt;li&gt;hosting on AWS managed services, with no machine to look after.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="the-pieces"&gt;The pieces&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Piece&lt;/th&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hugo, with the TeXify3 theme&lt;/td&gt;
&lt;td&gt;Turns Markdown into HTML&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GitHub&lt;/td&gt;
&lt;td&gt;Stores the source code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GitHub Actions&lt;/td&gt;
&lt;td&gt;Builds and deploys on every push&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Amazon S3&lt;/td&gt;
&lt;td&gt;Stores the generated files in a private bucket&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Amazon CloudFront&lt;/td&gt;
&lt;td&gt;Serves the site over HTTPS from edge locations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AWS Certificate Manager&lt;/td&gt;
&lt;td&gt;Provides the TLS certificate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AWS IAM&lt;/td&gt;
&lt;td&gt;Lets GitHub Actions deploy without stored access keys&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare DNS&lt;/td&gt;
&lt;td&gt;Points the domain at CloudFront&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="how-a-page-reaches-a-visitor"&gt;How a page reaches a visitor&lt;/h2&gt;
&lt;div class="mermaid"&gt;flowchart LR
V["Visitor"] --&gt;|"DNS lookup"| CF["Cloudflare DNS"]
V --&gt;|"HTTPS request"| CDN["CloudFront"]
CDN --&gt; FN["CloudFront Function&lt;br/&gt;adds index.html"]
FN --&gt; S3["Private S3 bucket"]
ACM["ACM certificate"] -.-&gt; CDN
&lt;/div&gt;
&lt;p&gt;CloudFront is the only service allowed to read from the S3 bucket, through an origin access control and a bucket policy that names this one distribution.&lt;/p&gt;
&lt;p&gt;That choice has a side effect. Hugo writes each page as a folder with an &lt;code&gt;index.html&lt;/code&gt; inside, such as &lt;code&gt;/posts/hello/index.html&lt;/code&gt;. A private S3 origin does not resolve &lt;code&gt;/posts/hello/&lt;/code&gt; to that file by itself, so a small CloudFront Function rewrites the request on the way in:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-javascript" data-lang="javascript"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;handler&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;event&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;var&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;request&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;event&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;request&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;var&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;uri&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;request&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;uri&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; (&lt;span style="color:#a6e22e"&gt;uri&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;endsWith&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;/&amp;#39;&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;request&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;uri&lt;/span&gt; &lt;span style="color:#f92672"&gt;+=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;index.html&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; } &lt;span style="color:#66d9ef"&gt;else&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; (&lt;span style="color:#f92672"&gt;!&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;uri&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;split&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;/&amp;#39;&lt;/span&gt;).&lt;span style="color:#a6e22e"&gt;pop&lt;/span&gt;().&lt;span style="color:#a6e22e"&gt;includes&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;.&amp;#39;&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;request&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;uri&lt;/span&gt; &lt;span style="color:#f92672"&gt;+=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;/index.html&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;request&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The certificate comes from AWS Certificate Manager and it has to be requested in the &lt;code&gt;us-east-1&lt;/code&gt; region for CloudFront to accept it, whatever the region in which the bucket lives in, and it is validated with a single DNS record.&lt;/p&gt;
&lt;h2 id="how-a-post-gets-published"&gt;How a post gets published&lt;/h2&gt;
&lt;div class="mermaid"&gt;sequenceDiagram
participant Me
participant GitHub
participant Actions as GitHub Actions
participant IAM as AWS IAM
participant S3
participant CloudFront
Me-&gt;&gt;GitHub: git push to main
GitHub-&gt;&gt;Actions: start workflow
Actions-&gt;&gt;Actions: build site with Hugo
Actions-&gt;&gt;IAM: present OIDC token
IAM--&gt;&gt;Actions: temporary credentials
Actions-&gt;&gt;S3: sync generated files
Actions-&gt;&gt;CloudFront: invalidate cache
&lt;/div&gt;
&lt;p&gt;The workflow installs Hugo, Dart Sass and the theme&amp;rsquo;s PostCSS dependencies, builds the site, copies the output to the bucket and clears the CloudFront cache. A full run takes less than a minute.&lt;/p&gt;
&lt;h2 id="deploying-without-stored-keys"&gt;Deploying without stored keys&lt;/h2&gt;
&lt;p&gt;No AWS access key is saved in the repository. GitHub Actions proves its identity to AWS with a short-lived OpenID Connect token, and IAM exchanges it for temporary credentials tied to one role.&lt;/p&gt;
&lt;div class="mermaid"&gt;flowchart TD
T["OIDC token from GitHub"] --&gt; C{"Trust policy:&lt;br/&gt;right repository&lt;br/&gt;and branch?"}
C --&gt;|"yes"| R["Assume deploy role"]
C --&gt;|"no"| D["Access denied"]
R --&gt; P["Allowed actions only"]
P --&gt; A["Write to one S3 bucket"]
P --&gt; B["Invalidate one distribution"]
&lt;/div&gt;
&lt;p&gt;The role can do two things: write to this bucket and invalidate this distribution. If the workflow were ever compromised, that is the limit of the damage.&lt;/p&gt;
&lt;h2 id="cost"&gt;Cost&lt;/h2&gt;
&lt;p&gt;For a site this size the bill should stay close to zero. Storage is a few megabytes, each deploy uploads a couple of hundred small files, and the only part that grows with usage is traffic through CloudFront.&lt;/p&gt;
&lt;h2 id="whats-next"&gt;What&amp;rsquo;s next&lt;/h2&gt;
&lt;p&gt;More articles coming soon now that publishing is one commit away!&lt;br&gt;
I might also redeploy this website through Terraform in the near future.&lt;/p&gt;</description></item></channel></rss>