<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ofili Valentine on Medium]]></title>
        <description><![CDATA[Stories by Ofili Valentine on Medium]]></description>
        <link>https://medium.com/@valofils?source=rss-149b542d51e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*aLaEd2iY-tyZr17tRbc15g.jpeg</url>
            <title>Stories by Ofili Valentine on Medium</title>
            <link>https://medium.com/@valofils?source=rss-149b542d51e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 07:39:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@valofils/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Deploy a REST API using Spring boot on AWS Serverless service (Lambda)]]></title>
            <link>https://medium.com/@valofils/deploy-a-rest-api-using-spring-boot-on-aws-serverless-service-lambda-e8b3f464f059?source=rss-149b542d51e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8b3f464f059</guid>
            <category><![CDATA[declouds]]></category>
            <category><![CDATA[spring-boot-3]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Ofili Valentine]]></dc:creator>
            <pubDate>Mon, 17 Mar 2025 05:54:42 GMT</pubDate>
            <atom:updated>2025-03-17T06:07:04.818Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i9SZ1x3ApnsN8W16-35lvw.png" /></figure><p>Deploying a REST API using Spring Boot on AWS Lambda allows you to build scalable and cost-efficient applications without managing servers. This guide walks you through the process step by step.</p><h3>Prerequisites</h3><p>Before getting started, ensure you have the following:</p><ul><li><strong>Java 11 or later</strong> installed</li><li><strong>Spring Boot</strong> (with Spring Web)</li><li><strong>AWS Account</strong> with IAM permissions</li><li><strong>AWS SAM CLI</strong> (Serverless Application Model) or AWS Lambda console access</li><li><strong>Maven or Gradle</strong> for dependency management (i’ll be using Maven)</li></ul><h3>Step 1: Create a Spring Boot REST API</h3><p>First, create a simple Spring Boot application with a REST controller.</p><pre>@RestController<br>@RequestMapping(&quot;/api&quot;)<br>public class HelloController {<br>    @GetMapping(&quot;/hello&quot;)<br>    public String hello() {<br>        return &quot;Hello from AWS Lambda!&quot;;<br>    }<br>}</pre><p>Make sure your <strong>pom.xml</strong> includes the required dependencies for Spring Boot.</p><h3>Step 2: Add AWS Lambda Support</h3><p>To run Spring Boot on AWS Lambda, include the AWS Serverless Java container dependency:</p><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;com.amazonaws.serverless&lt;/groupId&gt;<br>    &lt;artifactId&gt;aws-serverless-java-container-springboot2&lt;/artifactId&gt;<br>    &lt;version&gt;1.6&lt;/version&gt;<br>&lt;/dependency&gt;</pre><p>Create a <strong>Handler</strong> class to process API Gateway requests:</p><pre>public class StreamLambdaHandler implements RequestStreamHandler {<br>    private static SpringBootLambdaContainerHandler&lt;AwsProxyRequest, AwsProxyResponse&gt; handler;<br>    <br>    static {<br>        try {<br>            handler = SpringBootLambdaContainerHandler.getAwsProxyHandler(Application.class);<br>        } catch (ContainerInitializationException e) {<br>            throw new RuntimeException(&quot;Could not initialize Spring Boot application&quot;, e);<br>        }<br>    }<br>    <br>    @Override<br>    public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException {<br>        handler.proxyStream(inputStream, outputStream, context);<br>    }<br>}</pre><h3>Step 3: Package and Deploy with AWS Lambda</h3><h4>Option 1: Using AWS SAM CLI</h4><ol><li><strong>Initialize an AWS SAM Template:</strong></li></ol><pre>sam init --runtime java11</pre><p><strong>2. Build the application:</strong></p><pre>mvn clean pacakge</pre><p><strong>3. Deploy to AWS:</strong></p><pre>sam deploy --guided</pre><h4>Option 2: Manually Upload JAR to AWS Lambda</h4><ol><li><strong>Package your JAR file:</strong></li></ol><pre>mvn package</pre><ol><li><strong>Create a new Lambda function</strong> in AWS Console, select <strong>Java 11 runtime</strong>.</li><li><strong>Upload the packaged JAR</strong> file.</li><li><strong>Configure the Handler</strong> as:</li></ol><pre>com.example.StreamLambdaHandler::handleRequest</pre><h3>Step 4: Expose API via API Gateway</h3><ul><li>Navigate to AWS API Gateway and create a <strong>new HTTP API</strong>.</li><li>Set the <strong>Integration Type</strong> to AWS Lambda.</li><li>Select your deployed Lambda function.</li><li>Deploy the API and get the public endpoint.</li><li>Test it by sending a request to /api/hello.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8b3f464f059" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>