aws

package
v0.0.0-...-62d34d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

README

DynamoDB Development

To test the dynamo db implementation, you have to run a local instance of dynamo db.

You can download dynamodb here.

Run command

To test the database locally after download, open the command prompt and execute

java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConnection

func GetConnection(config *aws.Config) *dynamodb.DynamoDB

GetConnection takes a configuration, creates a session and returns a connection the assoicated dynamodb

func NewMockSSM

func NewMockSSM(path string, mapItem map[string]interface{}) *mockSSM

func NewSSMSession

func NewSSMSession(region string) ssmiface.SSMAPI

Types

type DynamoDBRepo

type DynamoDBRepo struct {
	// contains filtered or unexported fields
}

DynamoDBRepo stores all entities dynamo db

func NewDynamoDBRepo

func NewDynamoDBRepo(config *aws.Config, tableName string, toStruct func(jsonString string) (interface{}, error)) *DynamoDBRepo

NewDynamoDBRepo creates a DynamoDBRepo and checks if the table exists. If not it will be created. the toStruct function allowed the internal unmarshalling

Example: For the struct

type Person struct {
	Name string
}

The ToStruct function looks like:

func (person *Person) ToStruct(jsonString string) (interface{}, error) {
	err := json.Unmarshal([]byte(jsonString), &person)
	return person, err
}

func NewStoreItemDynamoDBRepo

func NewStoreItemDynamoDBRepo(config *aws.Config, tableName string, itemTemplate serialization.Serializable) *DynamoDBRepo

NewStoreItemDynamoDBRepo creates a DynamoDBRepo and checks if the table exists. If not it will be created.

func (*DynamoDBRepo) Delete

func (repo *DynamoDBRepo) Delete(key string) error

Delete an item from the repository

func (*DynamoDBRepo) Find

func (repo *DynamoDBRepo) Find(key string) (repository.KeyValuePair, error)

Find retrieves and item from the repository

func (*DynamoDBRepo) FindAll

func (repo *DynamoDBRepo) FindAll() ([]repository.KeyValuePair, error)

FindAll items

func (*DynamoDBRepo) Overwrite

func (repo *DynamoDBRepo) Overwrite(key string, in interface{}) (repository.KeyValuePair, error)

Save one item

func (*DynamoDBRepo) Save

func (repo *DynamoDBRepo) Save(key string, in interface{}) (repository.KeyValuePair, error)

Save one item

type SSMParameterStoreRepo

type SSMParameterStoreRepo struct {
	// contains filtered or unexported fields
}

SSMParameterStoreRepo stores entries in AWS Parameter Store. Values will always be stored encrypted

func NewSSMParameterStoreRepo

func NewSSMParameterStoreRepo(path string, ssmClient ssmiface.SSMAPI, itemTemplate serialization.Serializable) *SSMParameterStoreRepo

NewSSMParameterStoreRepo creates a new instance of the repository The repo can take structs and store them in serialized form.

func NewStringSSMParameterStoreRepo

func NewStringSSMParameterStoreRepo(path string, ssmClient ssmiface.SSMAPI) *SSMParameterStoreRepo

NewStringSSMParameterStoreRepo creates a new instance of the repository The repo stores the string without conversion.

func (*SSMParameterStoreRepo) Delete

func (repo *SSMParameterStoreRepo) Delete(key string) error

Only put a variable with the same name >=30 sec after deletion Not sure why, but this hint is documented in the AWS docu see https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_DeleteParameters.html

func (*SSMParameterStoreRepo) Find

func (*SSMParameterStoreRepo) FindAll

func (repo *SSMParameterStoreRepo) FindAll() ([]repository.KeyValuePair, error)

func (*SSMParameterStoreRepo) Overwrite

func (repo *SSMParameterStoreRepo) Overwrite(key string, in interface{}) (repository.KeyValuePair, error)

func (*SSMParameterStoreRepo) Save

func (repo *SSMParameterStoreRepo) Save(key string, in interface{}) (repository.KeyValuePair, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL