All Projects → sivalabs → localstack-spring-boot-starter

sivalabs / localstack-spring-boot-starter

Licence: MIT license
SpringBoot Starter for Localstack

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to localstack-spring-boot-starter

testing-spring-boot-applications-masterclass
🍃 Everything You Need to Know About Testing Spring Boot Applications
Stars: ✭ 185 (+386.84%)
Mutual labels:  testcontainers, localstack
Riptide
Client-side response routing for Spring
Stars: ✭ 169 (+344.74%)
Mutual labels:  spring-boot-starter
Disruptor Spring Boot Starter
starter for disruptor
Stars: ✭ 83 (+118.42%)
Mutual labels:  spring-boot-starter
Grpc Spring Boot Starter
Spring Boot starter module for gRPC framework.
Stars: ✭ 1,829 (+4713.16%)
Mutual labels:  spring-boot-starter
Wicket Spring Boot
Spring Boot starter for Apache Wicket
Stars: ✭ 117 (+207.89%)
Mutual labels:  spring-boot-starter
Grpc Spring Boot Starter
Spring Boot starter module for gRPC framework.
Stars: ✭ 2,190 (+5663.16%)
Mutual labels:  spring-boot-starter
Spring Higher Order Components
⚡️ Preconfigured components to speedup Spring Boot development
Stars: ✭ 65 (+71.05%)
Mutual labels:  spring-boot-starter
mongodb-replica-set
Run MongoDB Atlas locally for testing
Stars: ✭ 42 (+10.53%)
Mutual labels:  testcontainers
Tutorial Soap Spring Boot Cxf
Tutorial how to create, test, deploy, monitor SOAP-Webservices using Spring Boot and Apache CXF
Stars: ✭ 167 (+339.47%)
Mutual labels:  spring-boot-starter
Spring Backend Boilerplate
The modularized backend boilerplate based on Spring Boot Framework, easy to get started and add your business part.
Stars: ✭ 134 (+252.63%)
Mutual labels:  spring-boot-starter
Jasypt Spring Boot
Jasypt integration for Spring boot
Stars: ✭ 1,948 (+5026.32%)
Mutual labels:  spring-boot-starter
Logback Access Spring Boot Starter
Spring Boot Starter for Logback-access
Stars: ✭ 118 (+210.53%)
Mutual labels:  spring-boot-starter
Cas Client Autoconfig Support
Annotation-based configuration support for Apereo CAS Java clients
Stars: ✭ 153 (+302.63%)
Mutual labels:  spring-boot-starter
Handlebars Spring Boot Starter
Spring Boot auto-configuration for Handlebars
Stars: ✭ 102 (+168.42%)
Mutual labels:  spring-boot-starter
Rocketmq Spring Boot Starter
rocketmq-spring-boot-starter
Stars: ✭ 178 (+368.42%)
Mutual labels:  spring-boot-starter
Telegram Spring Boot Starter
Telegram Bot API Spring Boot Starter
Stars: ✭ 79 (+107.89%)
Mutual labels:  spring-boot-starter
Bucket4j Spring Boot Starter
Spring Boot Starter for Bucket4j
Stars: ✭ 127 (+234.21%)
Mutual labels:  spring-boot-starter
Justauth Spring Boot Starter
Spring Boot 集成 JustAuth 的最佳实践~
Stars: ✭ 143 (+276.32%)
Mutual labels:  spring-boot-starter
weixin-sdk
www.docs4dev.com/
Stars: ✭ 19 (-50%)
Mutual labels:  spring-boot-starter
Graphql Spqr Spring Boot Starter
Spring Boot 2 starter powered by GraphQL SPQR
Stars: ✭ 187 (+392.11%)
Mutual labels:  spring-boot-starter

localstack-spring-boot-starter

Build Maven Central License

Localstack-spring-boot-starter is a SpringBoot starter for LocalStack auto-configuration. This starter will spin up the Localstack docker container using Testcontainers and auto-configure beans such as AmazonS3, AmazonSQSAsync, etc.

Motivation

LocalStack provides an easy-to-use test/mocking framework for developing AWS based Cloud applications. We can use Testcontainers to spin up a Localstack docker container, but we need to configure Amazon service clients like AmazonS3, AmazonSQSAsync which is typical boilerplate that we copy-paste from project to project. Instead of copy-pasting the code snippets, creating a SpringBoot starter which autoconfigures the Amazon service clients is a better approach and less error prone. Hence, the birth of localstack-spring-boot-starter :-)

Requirements

  • JDK 8+
  • Tested with SpringBoot 2.3.3.RELEASE, should work fine with any SpringBoot 2.x versions

How to use?

Add dependencies

Maven

<dependencies>
    <dependency>
        <groupId>io.github.sivalabs</groupId>
        <artifactId>localstack-spring-boot-starter</artifactId>
        <version>0.0.1</version>
    </dependency>
    <dependency>
        <groupId>org.testcontainers</groupId>
        <artifactId>localstack</artifactId>
        <version>1.14.3</version>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk</artifactId>
        <version>1.11.852</version>
    </dependency>
</dependencies>

Gradle

implementation 'io.github.sivalabs:localstack-spring-boot-starter:0.0.1'
implementation 'org.testcontainers:localstack:1.14.3'
implementation 'com.amazonaws:aws-java-sdk:1.11.852'

Enable LocalStack AutoConfiguration

You can enable LocalStack AutoConfiguration by adding @EnableLocalStack annotation to either main entrypoint class or any @Configuration class.

package com.sivalabs.demo;

import io.github.sivalabs.localstack.EnableLocalStack;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.sqs.AmazonSQSAsync;
import org.springframework.beans.factory.annotation.Autowired;

@SpringBootApplication
@EnableLocalStack
public class LocalStackStarterDemoApplication {
    
    @Autowired
    private AmazonS3 amazonS3;

    @Autowired
    private AmazonSQSAsync amazonSQS;

    public static void main(String[] args) {
        SpringApplication.run(LocalStackStarterDemoApplication.class, args);
    }
}

How to use only for Integration Tests?

You may want to use localstack-spring-boot-starter only for testing. In that case, you can add @EnableLocalStack annotation combined with @Profile("integration-test") annotation so that the Localstack AutoConfiguration is only activated while running integration tests.

@Configuration
@EnableLocalStack
@Profile("integration-test")
public class TestConfig {
}

You can activate integration-test profile using @ActiveProfiles as follows:

@SpringBootTest
@ActiveProfiles("integration-test")
class SomeIntegrationTest {
    @Autowired
    private AmazonS3 amazonS3;
    
    @Autowired
    private AmazonSQSAsync amazonSQS;

    @Test
    void someTest() {

    }
} 

Configuration

The following configuration properties are available to customize the default behaviour.

Property Required Default Value
localstack.enabled no true
localstack.edgePort no 4566
localstack.defaultRegion no us-east-1
localstack.hostname no localhost
localstack.hostnameExternal no localhost
localstack.dockerImage no localstack/localstack:0.11.2
localstack.useSsl no false
localstack.services no ""

You can customize which AWS services to enable/disable as follows:

Property Value Default Value
localstack.services SQS, S3, SNS, DYNAMODB, DYNAMODBSTREAMS, KINESIS, IAM, LAMBDA, CLOUDWATCH, SECRETSMANAGER ""
localstack.s3.enabled false true
localstack.sqs.enabled true true
localstack.sns.enabled false true
localstack.dynamodb.enabled true true
localstack.dynamodbstreams.enabled false true
localstack.kinesis.enabled true true
localstack.iam.enabled false true
localstack.secretsmanager.enabled true true
localstack.lambda.enabled false true
localstack.cloudwatch.enabled true true

Examples

Want to Contribute?

You can contribute to localstack-spring-boot-starter project in many ways:

Credits

The implementation of localstack-spring-boot-starter is inspired by testcontainers-spring-boot. The testcontainers-spring-boot also provides localstack support, but it only spins up the docker container, and you will have to configure the beans like AmazonS3, AmazonSQSAsync etc by yourself.

License

License

Developer Notes

Procedure for deploying to Maven Central https://central.sonatype.org/pages/apache-maven.html

Set version to SNAPSHOT (ex: 1.0.0-SNAPSHOT)

Deploy SNAPSHOT version to https://oss.sonatype.org/content/repositories/snapshots/

localstack-spring-boot-starter> ./mvnw clean deploy -Prelease

Deploy release version to Maven Central

localstack-spring-boot-starter> ./mvnw release:clean release:prepare -Prelease
localstack-spring-boot-starter> ./mvnw release:perform -Prelease

Search for release artifacts on https://oss.sonatype.org/#nexus-search;quick~sivalabs

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].