Maria Livia Chiorean
Software Developer @ Sky
@MariaLiviaCh
The Developer ^-^
A
B
C
Account 1
Account 2
Credentials for account 1;
Credentials for account 2;
Create testing resources for 2 DynamoDB tables, 2 S3 buckets and 1 Kinesis;
Add some test data;
Start app C;
Start app B;
Start app A.
Docker container
with Localstack image
...
Application
> brew cask install docker
> brew install docker-compose
version: "3.7"
services:
localstack:
image: localstack/localstack
ports:
- "4569:4569"
- "4572:4572"
environment:
- SERVICES=dynamodb,s3
addSbtPlugin("com.tapad" % "sbt-docker-compose" % "1.0.34")
lazy val root = (project in file("."))
.enablePlugins(DockerComposePlugin)
.settings(
name := "localstack-example"
)
Or simply run:
> docker-compose -d up
> sbt dockerComposeUp
Spin up docker:
> brew install awscli
> aws s3api
create-bucket
--endpoint-url=http://localhost:4572
--bucket Config
AWSTemplateFormatVersion: "2010-09-09"
Resources:
ConfigBucket:
DeletionPolicy: "Retain"
Type: "AWS::S3::Bucket"
Properties:
BucketName: "Config"
import software.amazon.awssdk.core.sync.RequestBody
import software.amazon.awssdk.services.s3.S3Client
import software.amazon.awssdk.services.s3.model.PutObjectRequest
val client = S3Client.builder()
.endpointOverride(URI.create("http://localhost:4572"))
.build()
val request = PutObjectRequest.builder()
.bucket("Config")
.key("application")
.build()
client.putObject(request, RequestBody.fromString("config data"))
Old World :(
Install Docker and Docker Compose
Write docker-compose.yml
Spin up Docker
Create resources
Update client to use endpoint-url
Run app
New World :)
Install Docker and Docker Compose
Run plugin command
Update client to use endpoint-url
Run app
Spins up a docker container with localstack running.
Only starts up the requested AWS services.
Automatically creates AWS CLI resource creation commands form available cloudformation.
Performs cloudformation substitutions.
Commands for start, stop and printing out the commands.
At the moment only works with DynamoDB resources.
Only supports yml cloudformation.
Localstack: https://github.com/localstack/localstack
sbt-local-aws: https://github.com/marialivia16/sbt-local-aws
Slides: @MariaLiviaCh on Twitter
Special thanks to @OscarTheLargeCat (Instagram)