aws_signing_client

package module
v0.0.0-...-8d9beca Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2017 License: MIT Imports: 9 Imported by: 0

README

AWS Signing Client

This package provides simple http.Client creation that wraps all outgoing HTTP requests with Amazon AWS signatures using the AWS SDK for Go.

Requirements

In order to use signing graciously provided by @nicolai86 in the AWS SDK for Go, you must be using a version that has been updated since the merge of pull request #735 for the SDK (tagged release v1.2.0).

Acknowledgements

Thank you to both @deoxxa and @Saikat for fixing signature issues when they arose. Without them, this would not work.

Usage

You can provide your own *http.Client to have any existing fields persist or your RoundTripper wrapped:

import (
	"github.com/aws/aws-sdk-go/aws/credentials"
	"github.com/aws/aws-sdk-go/aws/signer/v4"
	"github.com/sha1sum/aws_signing_client"
)

var credentials *credentials.Credentials
// ... set credentials ...
var signer = v4.NewSigner(credentials)

var myClient *http.Client
// ...

// *v4.Signer, *http.Client, AWS service abbreviation, AWS region
var awsClient = aws_signing_client.New(signer, myClient, "es", "us-east-1")

... or you can simply have the default client with default client and transport created for you:

import (
	"github.com/aws/aws-sdk-go/aws/credentials"
	"github.com/aws/aws-sdk-go/aws/signer/v4"
	"github.com/sha1sum/aws_signing_client"
)

var credentials *credentials.Credentials
// ... set credentials ...
var signer = v4.NewSigner(credentials)

// *v4.Signer, *http.Client, AWS service abbreviation, AWS region
var awsClient = aws_signing_client.New(signer, nil, "es", "us-east-1")

Documentation

Overview

Package aws_signing_client returns an HTTP client for use with AWS services that require signatures but are not supported by the official AWS SDK for Go, such as the Amazon Elasticsearch Service, that signs requests before sending.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(v4s *v4.Signer, client *http.Client, service string, region string, cl ContextLogger) (*http.Client, error)

New obtains an HTTP client with a RoundTripper that signs AWS requests for the provided service. An existing client can be specified for the `client` value, or--if nil--a new HTTP client will be created.

Types

type ContextLogger

type ContextLogger interface {
	Printf(ctx context.Context, format string, v ...interface{})
}

ContextLogger is used for context-enabled logging.

type DefaultLogger

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

DefaultLogger implements ContextLogger interface using log.Logger. This effectively means the context is ignored.

func (*DefaultLogger) Printf

func (dl *DefaultLogger) Printf(ctx context.Context, format string, v ...interface{})

DefaultLogger.Printf() ignores the specified context.

type MissingRegionError

type MissingRegionError struct{}

MissingRegionError is an implementation of the error interface that indicates that no AWS region was provided in order to create a client.

func (MissingRegionError) Error

func (err MissingRegionError) Error() string

Error implements the error interface.

type MissingServiceError

type MissingServiceError struct{}

MissingServiceError is an implementation of the error interface that indicates that no AWS service was provided in order to create a client.

func (MissingServiceError) Error

func (err MissingServiceError) Error() string

Error implements the error interface.

type MissingSignerError

type MissingSignerError struct{}

MissingSignerError is an implementation of the error interface that indicates that no AWS v4.Signer was provided in order to create a client.

func (MissingSignerError) Error

func (err MissingSignerError) Error() string

Error implements the error interface.

type Signer

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

Signer implements the http.RoundTripper interface and houses an optional RoundTripper that will be called between signing and response.

func (*Signer) RoundTrip

func (s *Signer) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the http.RoundTripper interface and is used to wrap HTTP requests in order to sign them for AWS API calls. The scheme for all requests will be changed to HTTPS.

Jump to

Keyboard shortcuts

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