<?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: Caleb Frieze</title>
    <description>The latest articles on DEV Community by Caleb Frieze (@calebfrieze).</description>
    <link>https://dev.to/calebfrieze</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%2F579826%2F912f8192-f5d3-4405-906c-c6ca14d05c5e.png</url>
      <title>DEV Community: Caleb Frieze</title>
      <link>https://dev.to/calebfrieze</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/calebfrieze"/>
    <language>en</language>
    <item>
      <title>Deploying Go To AWS using CDK in 2024</title>
      <dc:creator>Caleb Frieze</dc:creator>
      <pubDate>Sat, 09 Mar 2024 18:09:06 +0000</pubDate>
      <link>https://dev.to/calebfrieze/deploying-go-to-aws-using-cdk-in-2024-41ah</link>
      <guid>https://dev.to/calebfrieze/deploying-go-to-aws-using-cdk-in-2024-41ah</guid>
      <description>&lt;p&gt;With go.1x being a deprecated runtime in AWS, we need to start using the &lt;code&gt;PROVIDED_AL2023&lt;/code&gt; runtime. There are quite a few tutorials out there that go over deploying Go lambdas, so I wont cover the extreme detail. (I followed this one by Melkey btw ;)) This is meant to fill in the gap if you are getting this pesky error at runtime:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Error: Couldn&lt;span class="s1"&gt;'t find valid bootstrap(s): [/var/task/bootstrap /opt/bootstrap]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's say you have a lambda function defined like this with CDK:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myTestFunction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;myTestFunction&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// This points to where your Go lambda lives&lt;/span&gt;
      &lt;span class="na"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Code&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromAsset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;lambdas&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="na"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;main&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;runtime&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Runtime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PROVIDED_AL2023&lt;/span&gt; &lt;span class="c1"&gt;// Because GO_1_X is now deprecated&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(this is also assuming your file structure follows Melkey's video)&lt;/p&gt;

&lt;p&gt;If you were to just build your lambda like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;GOOS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;linux &lt;span class="nv"&gt;GOARCH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;amd64 go build &lt;span class="nt"&gt;-o&lt;/span&gt; main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will encounter the pesky bootstrap error. This is because AWS lambda looks for a bootstrap in the folder that you defined in your code block.&lt;/p&gt;

&lt;p&gt;Simply change the out file to &lt;code&gt;bootstrap&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;GOOS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;linux &lt;span class="nv"&gt;GOARCH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;amd64 go build &lt;span class="nt"&gt;-o&lt;/span&gt; bootstrap 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;AWS Lambda will now be able to see your built Go function and your function will be invoked properly.&lt;/p&gt;

&lt;p&gt;There might be better ways to do this, but currently I'm new to Go and this worked for me! Hopefully this helps someone out!&lt;/p&gt;

</description>
      <category>go</category>
      <category>aws</category>
      <category>errors</category>
      <category>lambda</category>
    </item>
    <item>
      <title>TurboRepo Next.js Build Error</title>
      <dc:creator>Caleb Frieze</dc:creator>
      <pubDate>Fri, 25 Aug 2023 17:36:53 +0000</pubDate>
      <link>https://dev.to/calebfrieze/turborepo-nextjs-build-error-47mf</link>
      <guid>https://dev.to/calebfrieze/turborepo-nextjs-build-error-47mf</guid>
      <description>&lt;p&gt;I was converting an existing NextJs app into a repo that is managed by TurboRepo to give the ability to add more apps to our frontend system. Everything went great and was super smooth until I tried actually running the build scripts. I copied the configuration settings exactly from the docs and a couple sample repos that I found, yet still I had a unique problem.&lt;br&gt;
Here is a snippet of the error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app:build: - info Creating an optimized production build...
app:build: - info Compiled successfully
app:build: - info Collecting page data...
app:build: TypeError: Cannot read properties of undefined (reading 'P')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I followed the stack trace and noticed that it was trying to do a webpack import of a component that I created in a UI package. That should be fine, however upon further investigation, I hadn't realized I exported the story from Storybooks. At this time, I don't really have a need to explicitly export stories from &lt;code&gt;ui&lt;/code&gt; into any other project, so I just removed it. That seemed to fix the error. Now webpack builds NextJs just fine, and the app functions the same as it did before I made it a monorepo.&lt;/p&gt;

&lt;p&gt;Hopefully this helps someone else!&lt;/p&gt;

</description>
      <category>turborepo</category>
      <category>nextjs</category>
      <category>errors</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
