aws-sdk-go-bindings

module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: Apache-2.0

README

Go Report Card Apache V2 License BCH compliance

aws-sdk-go-bindings

Helper to easily access some aws-sdk-go's methods. It also contains multiple methods to cover tricky problems like preparing and sns default message and unmarshal an image coming out from a stream like:

// UnmarshalStreamImage unmarshals a dynamo stream image in a pointer to an interface
func UnmarshalStreamImage(in map[string]events.DynamoDBAttributeValue, out interface{}) error {

	dbAttrMap := make(map[string]*dynamodb.AttributeValue)

	for k, v := range in {

		bytes, marshalErr := v.MarshalJSON()
		if marshalErr != nil {
			return marshalErr
		}

		var dbAttr dynamodb.AttributeValue

		json.Unmarshal(bytes, &dbAttr)
		dbAttrMap[k] = &dbAttr

	}

	return dynamodbattribute.UnmarshalMap(dbAttrMap, out)

}

At the moment it covers SNS, SQS, DynamoDB, Rekognition and S3.

Utilization

You can import code from both cmd and pkg root package. cmd contains high level methods that interact with pkg ones while pkg directly interacts with aws-sdk-go.

Development

Install dep and run dep ensure inside the project's folder to get project's vendors. If you want to fork it or just use it in local, edit internal/configuration/configuration.json by setting your aws options like:

{
  "region" : "eu-central-1",
  "SNS" : {
    "target_arn" : "arn:aws:sns:eu-central-1:${your_aws_account_id}:${your_resource_name}"
  },
  "DynamoDB" : {
    "endpoint" : "your_local_dynamo_endpoint",
    "pkg_table_name" : "some_table_1",
    "cmd_table_name" : "some_table_2",
    "primary_key" : "some_param"
  },
  "S3" : {
    "bucket" : "your_bucket",
    "source_image" : "path_to_a_test_image"
  },
  "Rekognition" : {
      "region" : "rekognition_region",
      "compare_faces" : {
        "source_image" : "path_to_a_test_image",
        "target_image" : "path_to_a_test_image",
        "similarity" : 70.0
      },
      "detect_faces" : {
        "source_image" : "path_to_a_test_image"
      },
      "detect_text" : {
        "source_image" : "path_to_a_test_image"
      }
  },
  "SQS" : {
      "queue_url" : "some_queue_url"
  }
}

Also, to make dynamodb tests work you need to start a local dynamodb and run it on the same endpoint you put in the configuration above like java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb -port 4200 if you used "DynamoDB.endpoint" : "http://localhost:4200/".

Directories

Path Synopsis
cmd
aws
Package aws contains methods and types that interact with pkg/aws code
Package aws contains methods and types that interact with pkg/aws code
aws/dynamodb
Package dynamodb handles interactions with pkg/aws/dynamodb
Package dynamodb handles interactions with pkg/aws/dynamodb
aws/rekognition
Package rekognition interacts with pkg/aws/rekognition methods and types
Package rekognition interacts with pkg/aws/rekognition methods and types
aws/s3
Package s3 handles interactions with pkg/aws/s3
Package s3 handles interactions with pkg/aws/s3
aws/sns
Package sns interacts with pkg/aws/sns methods and types
Package sns interacts with pkg/aws/sns methods and types
aws/sqs
Package sqs interacts with pkg/aws/sqs methods and types
Package sqs interacts with pkg/aws/sqs methods and types
internal
configuration
Package configuration allows reading configuration parameters from a given configuration file
Package configuration allows reading configuration parameters from a given configuration file
pkg
aws
Package aws handles the initialization of a new aws session
Package aws handles the initialization of a new aws session
aws/dynamodb
Package dynamodb contains third party interactions with aws-sdk-go/dynamodb
Package dynamodb contains third party interactions with aws-sdk-go/dynamodb
aws/rekognition
Package rekognition handles interactions with aws-sdk-go/service/rekognition
Package rekognition handles interactions with aws-sdk-go/service/rekognition
aws/s3
Package s3 handles interactions with aws-sdk-go/service/s3
Package s3 handles interactions with aws-sdk-go/service/s3
aws/sns
Package sns handles interactions with aws-sdk-go/service/sns
Package sns handles interactions with aws-sdk-go/service/sns
aws/sqs
Package sqs handles interactions with aws-sdk-go/service/sqs
Package sqs handles interactions with aws-sdk-go/service/sqs

Jump to

Keyboard shortcuts

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