• Stars
    star
    76
  • Rank 420,374 (Top 9 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Go Wrapper for using localstack

go-localstack

Test codecov CodeQL Go Report Card PkgGoDev License

Go Wrapper for using localstack in go testing

Installation

Please make sure that you have Docker installed.

go get github.com/elgohr/go-localstack

Usage

With SDK V2

func ExampleLocalstackWithContextSdkV2() {
    ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
    defer cancel()
    
    l, err := localstack.NewInstance()
    if err != nil {
        log.Fatalf("Could not connect to Docker %v", err)
    }
    if err := l.StartWithContext(ctx); err != nil {
        log.Fatalf("Could not start localstack %v", err)
    }
    
    cfg, err := config.LoadDefaultConfig(ctx,
        config.WithRegion("us-east-1"),
        config.WithEndpointResolverWithOptions(aws.EndpointResolverWithOptionsFunc(func(_, _ string, _ ...interface{}) (aws.Endpoint, error) {
            return aws.Endpoint{
			    PartitionID:       "aws", 
			    URL:               l.EndpointV2(localstack.SQS), 
			    SigningRegion:     "us-east-1", 
			    HostnameImmutable: true,
		    }, nil
        })),
        config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider("dummy", "dummy", "dummy")),
    )
    if err != nil {
        log.Fatalf("Could not get config %v", err)
    }
    
    myTestWithV2(cfg)
}

With SDK V1

func TestWithLocalStack(t *testing.T) {
    ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
    defer cancel()

    l, err := localstack.NewInstance()
    if err != nil {
        log.Fatalf("Could not connect to Docker %v", err)
    }
    if err := l.StartWithContext(ctx); err != nil {
        log.Fatalf("Could not start localstack %v", err)
    }

    myTestWith(&aws.Config{
        Credentials: credentials.NewStaticCredentials("not", "empty", ""),
        DisableSSL:  aws.Bool(true),
        Region:      aws.String(endpoints.UsWest1RegionID),
        Endpoint:    aws.String(l.Endpoint(localstack.SQS)),
    })
}

More Repositories

1

Publish-Docker-Github-Action

A Github Action used to build and publish Docker images
Shell
778
star
2

Github-Release-Action

Publish Github releases in an action
Shell
166
star
3

ecr-login-action

A Github Action which can be used to authenticate with AWS ECR
Shell
39
star
4

cf-jetbrains-license-server

JetBrains License Server for Cloud Foundry
Shell
32
star
5

gcloud-login-action

A Github Action which can be used to authenticate with Google Cloud Container Registry
Shell
22
star
6

Github-Hub-Action

Interacting with Github in an action
Dockerfile
14
star
7

stop-and-go

Testing helper for concurrency
Go
10
star
8

concourse-sonarqube-notifier

Concourse CI Resource for getting results from Sonarqube.
Go
8
star
9

concourse-blackduck

This is a Concourse resource for Blackduck
Go
6
star
10

mqtt-to-influxdb

Bridge to write MQTT to InfluxDB
Go
5
star
11

EPEX-DE-History

This repository contains historic data from EPEX spot market for Germany, gotten by awattar.de
Python
5
star
12

github-globe

Python
3
star
13

asdf-build-action

Uses ASDF to provide a configurable build environment for Github Actions
Dockerfile
3
star
14

semv

Working with semvers
Go
2
star
15

go-map-ttl

A map where elements expire after time
Go
2
star
16

acr-login-action

Logs into Azure Container Registry and provides Docker credentials
Shell
2
star
17

go-test-it-yourself

Content for a 42Wolfsburg Workshop
Go
2
star
18

DataInspector

Publishes the metadata of Spring Boot Entities to an endpoint
Groovy
1
star
19

elgohr

Profile Readme
1
star
20

git-docker

Everything you need for Github/Git
Dockerfile
1
star
21

go-cryptotokenkit

Go wrapper for Apple CryptoTokenKit
Go
1
star
22

tinygo-wasm

A WASM bootstrap with tinygo
JavaScript
1
star
23

go-stream

A collection of Go Readers and Writers for working with big amounts of data.
Go
1
star
24

gron-docker

Make JSON greppable in Docker
Dockerfile
1
star