<?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>Forem: Carlos Lopez</title>
    <description>The latest articles on Forem by Carlos Lopez (@celopez3).</description>
    <link>https://forem.com/celopez3</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%2F2456382%2F63f81771-bd10-484f-82ae-ab642e3489bd.jpg</url>
      <title>Forem: Carlos Lopez</title>
      <link>https://forem.com/celopez3</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/celopez3"/>
    <language>en</language>
    <item>
      <title>Using Pulumi for Rapid Deployment</title>
      <dc:creator>Carlos Lopez</dc:creator>
      <pubDate>Mon, 31 Mar 2025 02:14:58 +0000</pubDate>
      <link>https://forem.com/celopez3/using-pulumi-for-rapid-deployment-5d95</link>
      <guid>https://forem.com/celopez3/using-pulumi-for-rapid-deployment-5d95</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/pulumi"&gt;Pulumi Deploy and Document Challenge&lt;/a&gt;: Fast Static Website Deployment&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;Hello Dev Community! Here's hopefully the first of many posts and attempts at these kinds of challenges. The project I built is in C# and leverages the Google Bucket Storage to rapidly prototype static websites by simply dropping the compiled site into a folder.&lt;/p&gt;

&lt;h2&gt;
  
  
  Live Demo Link
&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://storage.googleapis.com/bucket-site1-9e13468/index-48A01530.html" rel="noopener noreferrer"&gt;http://storage.googleapis.com/bucket-site1-9e13468/index-48A01530.html&lt;/a&gt;&lt;br&gt;
&lt;a href="http://storage.googleapis.com/bucket-site2-ee21e84/index-90BB84EE.html" rel="noopener noreferrer"&gt;http://storage.googleapis.com/bucket-site2-ee21e84/index-90BB84EE.html&lt;/a&gt;&lt;br&gt;
&lt;a href="http://storage.googleapis.com/bucket-site3-f0559b4/index-88A85004.html" rel="noopener noreferrer"&gt;http://storage.googleapis.com/bucket-site3-f0559b4/index-88A85004.html&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Project Repo
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/celopez3" rel="noopener noreferrer"&gt;
        celopez3
      &lt;/a&gt; / &lt;a href="https://github.com/celopez3/MyFirstPulumi" rel="noopener noreferrer"&gt;
        MyFirstPulumi
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      My first Pulumi project for the DEV competition
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Creating Static Websites Using Pulumi Infrastructure as Code&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;This project was created for entry into the DEV Challenge sponsored by Pulumi. The main function of this project leverages the Pulumi .NET SDK to create index.html driven websites in the form of Google Cloud Bucket Storage allowing for rapid static website deployments from a single folder.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Pre-Requisites &amp;amp; Requirements&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;This project is in C# and will require&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;1. Visual Studio Code (although any Visual Studio will work)
2. Pulumi CLI
3. Google CLI
4. Google Cloud &amp;lt;project-id&amp;amp;gt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Once you have installed the clients, you will need to make sure you have your Google Cloud Project ID. If you're new to Pulumi I would recommend reading my &lt;a href="https://dev.to/celopez3/using-pulumi-for-rapid-deployment-5d95" rel="nofollow"&gt;article&lt;/a&gt; on Dev.to which covers the basic installation experience or you can get it straight from &lt;a href="https://www.pulumi.com/docs/iac/get-started/gcp/" rel="nofollow noopener noreferrer"&gt;Pulumi&lt;/a&gt;.&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;git clone https://github.com/celopez3/MyFirstPulumi.git
&lt;span class="pl-c1"&gt;cd&lt;/span&gt; MyFirstPulumi
&lt;span class="pl-smi"&gt;$env&lt;/span&gt;:GCP_PROJECT_ID=&lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;&amp;lt;project-id&amp;gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Deployment&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;To deploy this project run&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;pulumi&lt;/pre&gt;…
&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/celopez3/MyFirstPulumi" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  My Journey
&lt;/h2&gt;

&lt;p&gt;Since this was my first time working with Pulumi I decided it best that I start with the documentation and creating an account. I quickly learned that installing the Pulumi CLI was a necessary first step.&lt;/p&gt;

&lt;p&gt;I followed the steps in &lt;a href="https://www.pulumi.com/docs/iac/get-started/gcp/" rel="noopener noreferrer"&gt;Getting Started with Pulumi and Google Cloud&lt;/a&gt;. I usually have chocolatey installed but at the time of doing this I had to settle for the   &lt;a href="https://www.pulumi.com/docs/iac/download-install/" rel="noopener noreferrer"&gt;AMD64 MSI package&lt;/a&gt;. Afterwards running&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%2F3q8wvwgmnd6ond12qoae.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%2F3q8wvwgmnd6ond12qoae.png" alt="Console commands: pulimi version"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;from a Powershell will verify that the installation was successful. I already had &lt;a href="https://dotnet.microsoft.com/en-us/download" rel="noopener noreferrer"&gt;.NET8&lt;/a&gt; installed but the guide has a link if you need to install it. &lt;/p&gt;

&lt;p&gt;Finally, I needed to choose a cloud framework, and typically by choosing C# you'd probably expect me to choose Azure, but I ran into issues getting my Azure account setup because of my phone number. I submitted a ticket and did get it resolved but not until after I decided to move forward with Google Cloud Platform and install the &lt;a href="https://cloud.google.com/sdk/docs/install" rel="noopener noreferrer"&gt;GCloud CLI&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;At this point you should create a project for yourself using the Google Console. If you aren't familiar, check out &lt;a href="https://cloud.google.com/resource-manager/docs/creating-managing-projects#creating_a_project" rel="noopener noreferrer"&gt;Google's documentation&lt;/a&gt; and use the Manage Resources button as a shortcut.&lt;/p&gt;

&lt;p&gt;When the GCloud CLI is finsihed it will open a command prompt for the following steps to be completed:&lt;/p&gt;

&lt;p&gt;1) sign in with your Google Account&lt;br&gt;
2) select a project. &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%2Fehqcnl21e8dzetgw9y8r.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%2Fehqcnl21e8dzetgw9y8r.png" alt="Successful installation of the GCloud CLI as displayed in a console window"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you have authenticated your projects will be listed and you'll select which project should be used in my case I create a project named "pulumi".&lt;/p&gt;

&lt;p&gt;Now that we've got our environment set up, we should open a Powershell console and navigate to wherever you want the code created and run the following commands:&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%2F5egd5baj4a77a1sr0cgg.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%2F5egd5baj4a77a1sr0cgg.png" alt="Console Commands: mkdir quickstart, pulumi new aws-csharp"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first command creates a folder quickstart and navigates into it. The second command calls the pulumi cli to create an aws-csharp project, except in my case I ran&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pulumi new gcp-csharp&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If this is your first time executing pulumi you will be prompted to login and setup the connection between Pulumi Cloud and the CLI. Following the rest of the guide will get you to being able to deploy a static website to Google Buckets. This was a really cool start, but I wanted to expand on it.&lt;/p&gt;

&lt;p&gt;My project addresses three scenarios for streamlining rapid prototypes to Google Buckets as static webpages. The &lt;a href="http://storage.googleapis.com/bucket-site1-9e13468/index-48A01530.html" rel="noopener noreferrer"&gt;first scenario&lt;/a&gt; is a default html template probably setup by hand.&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%2Fhef9b4b9lamah42l4l0t.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%2Fhef9b4b9lamah42l4l0t.png" alt="HTML header showcasing minimal CDN inclusions and one local script"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; tag you can see a minimal Bootstrap5 and a local style.css. The body was setup from the &lt;a href="https://getbootstrap.com/docs/5.0/examples/" rel="noopener noreferrer"&gt;Boostrap5 Templates&lt;/a&gt;, specifically the Blog template.&lt;/p&gt;

&lt;p&gt;The &lt;a href="http://storage.googleapis.com/bucket-site2-ee21e84/index-90BB84EE.html" rel="noopener noreferrer"&gt;second scenario&lt;/a&gt; is a Next.js or post compiled project, basically one a static website that was exported. I first downloaded a &lt;a href="https://github.com/NextJSTemplates/startup-nextjs" rel="noopener noreferrer"&gt;Startup Next.js template from GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I added this line to the next.config.js:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;output: 'export'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Which basically compiles your Next.js project into a folder called 'out' when you run:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm run build&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Finally, the &lt;a href="http://storage.googleapis.com/bucket-site3-f0559b4/index-88A85004.html" rel="noopener noreferrer"&gt;third scenario&lt;/a&gt; is simply downloading a free html template, extracting and launching the files.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Pulumi
&lt;/h2&gt;

&lt;p&gt;You'll find all the primary work for my submission in the Program.cs file.  I first created a directory called websites and for purposes of rapidly deploying sites I created 3 folders, site1, site2, and site3. Each folder contained files related to each scenario listed above.&lt;/p&gt;

&lt;p&gt;I then use pulumi to create buckets for each site.&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%2Fuqmai82ssktqfb22flv3.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%2Fuqmai82ssktqfb22flv3.png" alt="C# code using Pulumi to create a Google Cloud Bucket"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the buckets were created, I loop through each site directory and create &lt;a href="https://www.pulumi.com/registry/packages/gcp/api-docs/storage/bucketobject/" rel="noopener noreferrer"&gt;Bucket Objects&lt;/a&gt; for each file, including subdirectories.&lt;/p&gt;

&lt;p&gt;Running &lt;code&gt;pulumi up&lt;/code&gt; from the folder containing Program.cs results in, &lt;strong&gt;specifically the index.html&lt;/strong&gt; file being uploaded and the auto deployed site  urls being displayed.&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%2Fhubwz8tixfvg1a9jtmk8.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%2Fhubwz8tixfvg1a9jtmk8.png" alt="Results of running console command: pulumi up"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is important to note that the code within my repo is hard coded to leverage index.html, however it could easily be adapted to accommodate any html files.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons Learned &amp;amp; Conclusions
&lt;/h2&gt;

&lt;p&gt;I definitely learned a lot throughout this process. I went down quite a few rabbit holes before I decided on this submission. I wouldn't say that my experience with Pulumi felt easy, but I never felt stuck or unable to find an answer. Their online documentation and the availability of examples really helped accelerate my overall experience. Most importantly, now that I have this project I'll be able to rapidly prototype website templates by simply dropping them into a folder.&lt;/p&gt;

&lt;p&gt;I see a lot of potential in Pulumi and look forward to the next project. If I had more time I'd like to submit a docker deployment solution through Pulumi, but I doubt I'd get it done before the April 6th deadline.&lt;/p&gt;

&lt;p&gt;Let me know if you have thoughts or questions in the comments and thank you for your consideration.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>pulumichallenge</category>
      <category>github</category>
      <category>api</category>
    </item>
  </channel>
</rss>
