Git Product home page Git Product logo

dynamodb-local-helm-chart's Introduction

DynamoDB Local - Kubernetes Setup Steps

Clone Helm Chart

$ cd ~/Workspace
$ git clone github.com/jittakal/dynamodb-local-helm-chart

Install Helm Chart

$ helm install aws ./dynamodb-local-helm-chart
$ kubectl port-forward -n default svc/aws-dynamodb-local 8000:8000

Download & Install NoSQL Workbench

$ cd tmp
$ wget -o WorkbenchDDBLocal-mac.zip https://s3.amazonaws.com/nosql-workbench/WorkbenchDDBLocal-mac.zip # Only for Mac

Refer Installation Steps

Add Localhost Connection

  • Go to Operational Builder
  • Add Connection for Localhost -- Host: 127.0.0.1 -- Port: 8000
  • Import Sample DynamoDB Tables

Note: DynamoDB Local Running within Kubernetes - Microk8s

NoSQL Workbench

NoSQL Workbench

DynamoDB Local - K8S

DynamoDB Local K8S

Using AWS CLI

$ # Create Table
$ aws dynamodb create-table --table-name Orders --attribute-definitions AttributeName=orderId,AttributeType=S --key-schema AttributeName=orderId,KeyType=HASH --billing-mode PAY_PER_REQUEST --endpoint-url http://localhost:8000 --region us-east-1
$ # List Tables
$ aws dynamodb list-tables --endpoint-url http://localhost:8000 --region us-east-1

Using Go

func NewDynamoDBLocalClient(ctx context.Context) (*dynamodb.Client, error) {
	cfg, err := config.LoadDefaultConfig(ctx,
		config.WithRegion("us-east-1"),
		config.WithEndpointResolverWithOptions(aws.EndpointResolverWithOptionsFunc(
			func(service, region string, options ...interface{}) (aws.Endpoint, error) {
				return aws.Endpoint{URL: "http://localhost:8000"}, nil
			})),
		config.WithCredentialsProvider(credentials.StaticCredentialsProvider{
			Value: aws.Credentials{
				AccessKeyID: "AKID", SecretAccessKey: "SECRET",
				Source: "Hard-coded credentials; values are irrelevant for local DynamoDB",
			},
		}),
	)
	if err != nil {
		slog.Error("Error While getting connection")
		return nil, err
	}

	return dynamodb.NewFromConfig(cfg), nil
}
func TestListTables(t *testing.T) {
	ctx := context.Background()

	client, err := NewDynamoDBLocalClient(ctx)

	if err != nil {
		t.Errorf("Error while creating local dynamodb connection - %s", err)
	}

	listTableOutput, err := client.ListTables(ctx, &dynamodb.ListTablesInput{
		ExclusiveStartTableName: aws.String("Order"),
	})

	if err != nil {
		t.Errorf("Error while listing tables from local dynamodb connection - %s", err)
	}

	if len(listTableOutput.TableNames) == 0 {
		t.Errorf("List of tables should not be empty")
	}
}

dynamodb-local-helm-chart's People

Contributors

jittakal avatar emily-57blocks avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.