<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Lambda on The Edge Cases</title>
    <link>https://www.kylestratis.com/tags/lambda/</link>
    <description>Recent content in Lambda on The Edge Cases</description>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>© 2025</copyright>
    <lastBuildDate>Fri, 18 Sep 2026 22:38:55 -0400</lastBuildDate>
    <atom:link href="https://www.kylestratis.com/tags/lambda/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Building Docker Images on M1 Mac for Other Platforms</title>
      <link>https://www.kylestratis.com/notes/building-docker-images-on-m1-mac-for-other-platforms/</link>
      <pubDate>Sat, 19 Sep 2026 02:10:03 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/building-docker-images-on-m1-mac-for-other-platforms/</guid>
      <description>&lt;p&gt;In order to build Docker images for Lambda functions with CDK on ARM or other non-Intel platforms, but want the Lambda to be on an x86_64 platform, use the &lt;code&gt;platform&lt;/code&gt; parameter with the &lt;code&gt;from_image_asset()&lt;/code&gt; function.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;_lambda&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;DockerImage_function(&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;...&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    code&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;_lambda&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;DockerImageCode&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;from_image_asset(  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        directory&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;./lambda&amp;#34;&lt;/span&gt;,  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        file&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;./myservice/Dockerfile&amp;#34;&lt;/span&gt;,  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        platform&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;ecr_assets&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;Platform&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;LINUX_AMD64,  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ),&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;...&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;ecr_assets&lt;/code&gt; is a CDK package that also needs to be imported from the main &lt;code&gt;aws_cdk&lt;/code&gt; package.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Fixing Runtime Exited Without a Reason Errors in AWS Lambda</title>
      <link>https://www.kylestratis.com/notes/fixing-runtime-exited-without-a-reason-errors-in-aws-lambda/</link>
      <pubDate>Thu, 25 May 2023 18:47:46 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/fixing-runtime-exited-without-a-reason-errors-in-aws-lambda/</guid>
      <description>&lt;p&gt;This happens sometimes with Dockerized Lambdas. I have no idea why, but fixing it usually consists of rebuilding and re-pushing the docker image, redeploying it to the Lambda, and re-running it.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Deploying an Updated Image to Lambda Function</title>
      <link>https://www.kylestratis.com/notes/deploying-an-updated-image-to-lambda-function/</link>
      <pubDate>Wed, 04 Jan 2023 18:24:48 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/deploying-an-updated-image-to-lambda-function/</guid>
      <description>&lt;p&gt;Redeploying a CDK stack with a Lambda function that relies on a Docker image in ECR won&amp;rsquo;t necessarily update the function with a newly pushed image. Instead, use the Lambda console&amp;rsquo;s &amp;ldquo;Deploy new image&amp;rdquo; button to push the ECR image to the function.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Raising Exceptions from Lambda to API Gateway Caller</title>
      <link>https://www.kylestratis.com/notes/raising-exceptions-from-lambda-to-api-gateway-caller/</link>
      <pubDate>Wed, 05 Oct 2022 17:09:29 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/raising-exceptions-from-lambda-to-api-gateway-caller/</guid>
      <description>&lt;p&gt;You can send exception feedback from a Lambda to an API Gateway API either by raising a Python exception and handling it via a mapping template, or return a specific set of values from the main handler function.&lt;/p&gt;&#xA;&lt;h2 id=&#34;returning-from-the-handler-function&#34;&gt;Returning from the Handler Function&lt;/h2&gt;&#xA;&lt;p&gt;You can return a dictionary that includes at least:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;the desired status code&lt;/li&gt;&#xA;&lt;li&gt;the message body (JSONified)&lt;/li&gt;&#xA;&lt;li&gt;and whether or not the body is base64 encoded&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; {  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;statusCode&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;404&lt;/span&gt;,  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;body&amp;#34;&lt;/span&gt;: simplejson&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;dumps(  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#e6db74&#34;&gt;f&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;User &lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;{&lt;/span&gt;username&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; not found&amp;#34;&lt;/span&gt;  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ),  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;isBase64Encoded&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;False&lt;/span&gt;,  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;raising-an-exceptions&#34;&gt;Raising an Exceptions&lt;/h2&gt;&#xA;&lt;p&gt;Using a &lt;a href=&#34;https://aws.amazon.com/blogs/compute/error-handling-patterns-in-amazon-api-gateway-and-aws-lambda/&#34;&gt;mapping template&lt;/a&gt; allows you to simply use regex to associate an error message from a plain Python exception with a certain HTTP code. I don&amp;rsquo;t have any examples because I haven&amp;rsquo;t done it, preferring the &lt;a href=&#34;https://www.kylestratis.com/notes/raising-exceptions-from-lambda-to-api-gateway-caller/#returning-from-the-handler-function&#34;&gt;previous method&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Including Assets from Parent Directories in Dockerized Lambda Functions with CDK</title>
      <link>https://www.kylestratis.com/notes/including-assets-from-parent-directories-in-dockerized-lambda-functions-with-cdk/</link>
      <pubDate>Tue, 04 Oct 2022 17:31:19 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/including-assets-from-parent-directories-in-dockerized-lambda-functions-with-cdk/</guid>
      <description>&lt;p&gt;If you have a Docker based Lambda that is defined in some directory and there are assets that the Lambda needs in the parent directory, &lt;code&gt;from_image_asset()&lt;/code&gt; takes &lt;code&gt;directory&lt;/code&gt; and &lt;code&gt;file&lt;/code&gt; parameters, so you can select the parent directory as well as the specific Dockerfile that describes the environment for the Lambda.&lt;/p&gt;&#xA;&lt;p&gt;Here is an example folder structure:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CDK_infrastructure/&#xA;    lambdas/&#xA;        lambda_one.py&#xA;        lambda_two.py&#xA;        lambda_pkg/&#xA;            ...&#xA;        docker_lambda/&#xA;            Dockerfile&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And here is how you would set this up in your stack definition:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Asynchronous Lambda Invocation</title>
      <link>https://www.kylestratis.com/notes/asynchronous-lambda-invocation/</link>
      <pubDate>Tue, 30 Aug 2022 18:57:17 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/asynchronous-lambda-invocation/</guid>
      <description>&lt;p&gt;In order to invoke a Lambda asynchronously, pass &lt;code&gt;InvocationType=&amp;quot;Event&amp;quot;&lt;/code&gt; to the &lt;code&gt;invoke&lt;/code&gt; call. This is useful for, among other things, a hub/message routing Lambda that calls other ones in a fire-and-forget manner. &lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;source&#34;&gt;Source&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html&#34;&gt;Lambda API Invoke AWS Documentation&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;This is likely not an ideal architecture, there are usually better alternatives&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;</description>
    </item>
    <item>
      <title>AWS Lambda Return Values for API Triggering</title>
      <link>https://www.kylestratis.com/notes/aws-lambda-return-values-for-api-triggering/</link>
      <pubDate>Mon, 07 Feb 2022 21:41:05 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/aws-lambda-return-values-for-api-triggering/</guid>
      <description>&lt;p&gt;A Lambda triggered by an API has to return a dictionary with certain keys and values in order to not cause an error in execution (e.g. &amp;ldquo;malformed lambda proxy response&amp;rdquo;). These are the status code, body (JSONified), and if it&amp;rsquo;s base64 encoded. Headers can also be added to this structure, but they don&amp;rsquo;t seem required.&lt;/p&gt;&#xA;&lt;h2 id=&#34;code-example&#34;&gt;Code Example&lt;/h2&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; {  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;statusCode&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;200&lt;/span&gt;,  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;body&amp;#34;&lt;/span&gt;: json&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;dumps(&lt;span style=&#34;color:#e6db74&#34;&gt;f&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;User &lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;{&lt;/span&gt;username&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; not found&amp;#34;&lt;/span&gt;),  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;isBase64Encoded&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;False&lt;/span&gt;  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;sources&#34;&gt;Sources&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://aws.amazon.com/premiumsupport/knowledge-center/malformed-502-api-gateway/&#34;&gt;https://aws.amazon.com/premiumsupport/knowledge-center/malformed-502-api-gateway/&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.onlinetutorialspoint.com/aws/fixed-malformed-lambda-proxy-response-status-502.html&#34;&gt;https://www.onlinetutorialspoint.com/aws/fixed-malformed-lambda-proxy-response-status-502.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
    </item>
    <item>
      <title>Passing Secrets into Lambdas in CDK</title>
      <link>https://www.kylestratis.com/notes/passing-secrets-into-lambdas-in-cdk/</link>
      <pubDate>Mon, 07 Feb 2022 18:43:52 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/passing-secrets-into-lambdas-in-cdk/</guid>
      <description>&lt;p&gt;same: &lt;a href=&#34;https://www.kylestratis.com/notes/aws-lambda-return-values-for-api-triggering/&#34;&gt;AWS Lambda Return Values for API Triggering&lt;/a&gt;, &lt;a href=&#34;https://www.kylestratis.com/notes/to-build-a-lambda-from-a-dockerfile-in-cdk/&#34;&gt;To Build a Lambda from a Dockerfile in CDK&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;passing-secrets-into-lambdas-in-cdk&#34;&gt;Passing Secrets into Lambdas in CDK&lt;/h2&gt;&#xA;&lt;p&gt;Do not pass Secret Manager values via environment variables in your CDK Stack! This is a problem for two reasons:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;This exposes the Secret in the generated CF templates.&lt;/li&gt;&#xA;&lt;li&gt;This only pulls the Secret value at deploy time &lt;strong&gt;only if&lt;/strong&gt; the Secrets construct or Lambda in question will be rebuilt upon deploy or synthesis. If the keys are rotated, and the constructs in the CDK stack aren&amp;rsquo;t changed, this won&amp;rsquo;t be picked up by the app.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;To address this, handle Secret Manager secrets in the following way:&lt;/p&gt;</description>
    </item>
    <item>
      <title>To Build a Lambda from a Dockerfile in CDK</title>
      <link>https://www.kylestratis.com/notes/to-build-a-lambda-from-a-dockerfile-in-cdk/</link>
      <pubDate>Wed, 27 Oct 2021 19:24:41 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/to-build-a-lambda-from-a-dockerfile-in-cdk/</guid>
      <description>&lt;h2 id=&#34;creating-the-dockerfile&#34;&gt;Creating the Dockerfile&lt;/h2&gt;&#xA;&lt;p&gt;To set up a Dockerfile for a Lambda function that relies on non-AWS base images, you have to include the Python package &lt;code&gt;awslambdaric&lt;/code&gt; in your requirements and install it. Then, do the following in the Dockerfile:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-dockerfile&#34; data-lang=&#34;dockerfile&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;ENTRYPOINT&lt;/span&gt; [ &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/usr/local/bin/python&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;-m&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;awslambdaric&amp;#34;&lt;/span&gt; ]  &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;CMD&lt;/span&gt; [&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;lambda_code.function_name&amp;#34;&lt;/span&gt;]&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-dockerfile&#34; data-lang=&#34;dockerfile&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;ARG&lt;/span&gt; FUNCTION_DIR&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/function&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;  &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;FROM&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; tensorflow/tensorflow:2.4.3 as DEV  &lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;ARG&lt;/span&gt; FUNCTION_DIR  &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;RUN&lt;/span&gt; mkdir -p &lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;FUNCTION_DIR&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;## copies python code into container&amp;#39;s FUNCTION_DIR&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;COPY&lt;/span&gt; lambda_code.py &lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;FUNCTION_DIR&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;## copies lambda_requirements.txt into container&amp;#39;s requirements.txt&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;COPY&lt;/span&gt; lambda_requirements.txt ./requirements.txt  &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;## copies dataset into container&amp;#39;s FUNCTION_DIR/dataset/&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;COPY&lt;/span&gt; dataset &lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;FUNCTION_DIR&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;/dataset/  &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;RUN&lt;/span&gt; pip install --no-cache-dir --upgrade pip &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\ &lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;    pip install -r requirements.txt --target &lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;FUNCTION_DIR&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;  &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;WORKDIR&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; ${FUNCTION_DIR}  &lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;ENTRYPOINT&lt;/span&gt; [ &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;python&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;-m&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;awslambdaric&amp;#34;&lt;/span&gt; ]  &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;CMD&lt;/span&gt; [&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;lambda_code.function_name&amp;#34;&lt;/span&gt;]&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;setting-up-the-lambda-in-cdk&#34;&gt;Setting Up the Lambda in CDK&lt;/h2&gt;&#xA;&lt;p&gt;To create a Lambda from a Dockerfile in CDK, use  &lt;code&gt;cdk.aws-lambda.DockerImageFunction&lt;/code&gt; when defining your Lambda:&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
