Software Integration Series: Spring Boot and Amazon S3 Integration

Swathi Prasad
5 min readApr 2

A detailed guide on integrating Spring Boot and Amazon S3 with a sample application and Infrastructure-as-Code templates.

Spring Boot and S3 integration

Welcome to my first article in the Software Integration Series. In this series, I will deep dive into various topics using Java tech stack, AWS cloud and many more. Without further ado let’s get started.

Amazon Simple Storage Service (Amazon S3) is a scalable, secure, and performant object storage service. It provides management features so that we can optimize, organize, and configure access to our data to meet specific business and compliance requirements.

This article walkthrough is a step-by-step guide about how to integrate Amazon S3 with a Spring Boot application.

Creating an Amazon S3 bucket using IaC tools

We will use Infrastructure-as-Code (IaC) template to create a S3 bucket. You can find two sample templates using both CloudFormation and Terraform tools in my GitHub repository. Use the tool of your choice and create a S3 bucket using the template.

The CloudFormation template creates IAM user, access key and outputs the values of access key and secret in the console. As a security best practice, it is not recommended to use IAM access keys when making API calls from applications. It is recommended to use IAM roles which use AWS Security Token Service (STS) to create temporary, limited-privilege credentials. It is also not recommended to output values of access key and secret in CloudFormation stacks especially when you are working in a team.

If you are using Terraform, create IAM access key via AWS console. The access key, secret and bucket name are passed as variables when applying the template.

Creating an Amazon S3 bucket and IAM access key using console

Login to your AWS account and search for S3 using search bar. Once you are in S3 console, click on “Create Bucket” button.

Provide a bucket name of your choice. The bucket name must be unique across AWS, not just your account.

Leave the rest of the settings with default values and click on “Create Bucket”…

Swathi Prasad

Software architect and developer living in Germany. Sharing my opinion and what I learn.