aws

package
Version: v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2016 License: LGPL-3.0, AGPL-3.0, Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

goamz - Go packages to interact with the Amazon Web Services.

https://wiki.ubuntu.com/goamz

Copyright (c) 2011 Canonical Ltd.

Written by Gustavo Niemeyer <gustavo.niemeyer@canonical.com>

Index

Constants

View Source
const (
	V2Signature      = iota
	V4Signature      = iota
	Route53Signature = iota
)

Defines the valid signers

View Source
const (
	ISO8601BasicFormat      = "20060102T150405Z"
	ISO8601BasicFormatShort = "20060102"
)

Common date formats for signing requests

Variables

View Source
var APNortheast = Region{
	"ap-northeast-1",
	"https://ec2.ap-northeast-1.amazonaws.com",
	"https://s3-ap-northeast-1.amazonaws.com",
	"",
	true,
	true,
	"https://sdb.ap-northeast-1.amazonaws.com",
	"",
	"https://sns.ap-northeast-1.amazonaws.com",
	"https://sqs.ap-northeast-1.amazonaws.com",
	"https://iam.amazonaws.com",
	"https://elasticloadbalancing.ap-northeast-1.amazonaws.com",
	"https://dynamodb.ap-northeast-1.amazonaws.com",
	ServiceInfo{"https://monitoring.ap-northeast-1.amazonaws.com", V2Signature},
	"https://autoscaling.ap-northeast-1.amazonaws.com",
	ServiceInfo{"https://rds.ap-northeast-1.amazonaws.com", V2Signature},
	"https://sts.amazonaws.com",
	"https://cloudformation.ap-northeast-1.amazonaws.com",
	"https://ecs.ap-northeast-1.amazonaws.com",
	"https://streams.dynamodb.ap-northeast-1.amazonaws.com",
}
View Source
var APSoutheast = Region{
	"ap-southeast-1",
	"https://ec2.ap-southeast-1.amazonaws.com",
	"https://s3-ap-southeast-1.amazonaws.com",
	"",
	true,
	true,
	"https://sdb.ap-southeast-1.amazonaws.com",
	"",
	"https://sns.ap-southeast-1.amazonaws.com",
	"https://sqs.ap-southeast-1.amazonaws.com",
	"https://iam.amazonaws.com",
	"https://elasticloadbalancing.ap-southeast-1.amazonaws.com",
	"https://dynamodb.ap-southeast-1.amazonaws.com",
	ServiceInfo{"https://monitoring.ap-southeast-1.amazonaws.com", V2Signature},
	"https://autoscaling.ap-southeast-1.amazonaws.com",
	ServiceInfo{"https://rds.ap-southeast-1.amazonaws.com", V2Signature},
	"https://sts.amazonaws.com",
	"https://cloudformation.ap-southeast-1.amazonaws.com",
	"https://ecs.ap-southeast-1.amazonaws.com",
	"https://streams.dynamodb.ap-southeast-1.amazonaws.com",
}
View Source
var APSoutheast2 = Region{
	"ap-southeast-2",
	"https://ec2.ap-southeast-2.amazonaws.com",
	"https://s3-ap-southeast-2.amazonaws.com",
	"",
	true,
	true,
	"https://sdb.ap-southeast-2.amazonaws.com",
	"",
	"https://sns.ap-southeast-2.amazonaws.com",
	"https://sqs.ap-southeast-2.amazonaws.com",
	"https://iam.amazonaws.com",
	"https://elasticloadbalancing.ap-southeast-2.amazonaws.com",
	"https://dynamodb.ap-southeast-2.amazonaws.com",
	ServiceInfo{"https://monitoring.ap-southeast-2.amazonaws.com", V2Signature},
	"https://autoscaling.ap-southeast-2.amazonaws.com",
	ServiceInfo{"https://rds.ap-southeast-2.amazonaws.com", V2Signature},
	"https://sts.amazonaws.com",
	"https://cloudformation.ap-southeast-2.amazonaws.com",
	"https://ecs.ap-southeast-2.amazonaws.com",
	"https://streams.dynamodb.ap-southeast-2.amazonaws.com",
}
View Source
var CNNorth = Region{
	"cn-north-1",
	"https://ec2.cn-north-1.amazonaws.com.cn",
	"https://s3.cn-north-1.amazonaws.com.cn",
	"",
	true,
	true,
	"https://sdb.cn-north-1.amazonaws.com.cn",
	"",
	"https://sns.cn-north-1.amazonaws.com.cn",
	"https://sqs.cn-north-1.amazonaws.com.cn",
	"https://iam.cn-north-1.amazonaws.com.cn",
	"https://elasticloadbalancing.cn-north-1.amazonaws.com.cn",
	"https://dynamodb.cn-north-1.amazonaws.com.cn",
	ServiceInfo{"https://monitoring.cn-north-1.amazonaws.com.cn", V4Signature},
	"https://autoscaling.cn-north-1.amazonaws.com.cn",
	ServiceInfo{"https://rds.cn-north-1.amazonaws.com.cn", V4Signature},
	"https://sts.cn-north-1.amazonaws.com.cn",
	"https://cloudformation.cn-north-1.amazonaws.com.cn",
	"https://ecs.cn-north-1.amazonaws.com.cn",
	"https://streams.dynamodb.cn-north-1.amazonaws.com.cn",
}
View Source
var EUCentral = Region{
	"eu-central-1",
	"https://ec2.eu-central-1.amazonaws.com",
	"https://s3-eu-central-1.amazonaws.com",
	"",
	true,
	true,
	"https://sdb.eu-central-1.amazonaws.com",
	"https://email.eu-central-1.amazonaws.com",
	"https://sns.eu-central-1.amazonaws.com",
	"https://sqs.eu-central-1.amazonaws.com",
	"https://iam.amazonaws.com",
	"https://elasticloadbalancing.eu-central-1.amazonaws.com",
	"https://dynamodb.eu-central-1.amazonaws.com",
	ServiceInfo{"https://monitoring.eu-central-1.amazonaws.com", V2Signature},
	"https://autoscaling.eu-central-1.amazonaws.com",
	ServiceInfo{"https://rds.eu-central-1.amazonaws.com", V2Signature},
	"https://sts.amazonaws.com",
	"https://cloudformation.eu-central-1.amazonaws.com",
	"https://ecs.eu-central-1.amazonaws.com",
	"https://streams.dynamodb.eu-central-1.amazonaws.com",
}
View Source
var EUWest = Region{
	"eu-west-1",
	"https://ec2.eu-west-1.amazonaws.com",
	"https://s3-eu-west-1.amazonaws.com",
	"",
	true,
	true,
	"https://sdb.eu-west-1.amazonaws.com",
	"https://email.eu-west-1.amazonaws.com",
	"https://sns.eu-west-1.amazonaws.com",
	"https://sqs.eu-west-1.amazonaws.com",
	"https://iam.amazonaws.com",
	"https://elasticloadbalancing.eu-west-1.amazonaws.com",
	"https://dynamodb.eu-west-1.amazonaws.com",
	ServiceInfo{"https://monitoring.eu-west-1.amazonaws.com", V2Signature},
	"https://autoscaling.eu-west-1.amazonaws.com",
	ServiceInfo{"https://rds.eu-west-1.amazonaws.com", V2Signature},
	"https://sts.amazonaws.com",
	"https://cloudformation.eu-west-1.amazonaws.com",
	"https://ecs.eu-west-1.amazonaws.com",
	"https://streams.dynamodb.eu-west-1.amazonaws.com",
}
View Source
var RetryingClient = NewClient(retryingTransport)

Exported default client

View Source
var SAEast = Region{
	"sa-east-1",
	"https://ec2.sa-east-1.amazonaws.com",
	"https://s3-sa-east-1.amazonaws.com",
	"",
	true,
	true,
	"https://sdb.sa-east-1.amazonaws.com",
	"",
	"https://sns.sa-east-1.amazonaws.com",
	"https://sqs.sa-east-1.amazonaws.com",
	"https://iam.amazonaws.com",
	"https://elasticloadbalancing.sa-east-1.amazonaws.com",
	"https://dynamodb.sa-east-1.amazonaws.com",
	ServiceInfo{"https://monitoring.sa-east-1.amazonaws.com", V2Signature},
	"https://autoscaling.sa-east-1.amazonaws.com",
	ServiceInfo{"https://rds.sa-east-1.amazonaws.com", V2Signature},
	"https://sts.amazonaws.com",
	"https://cloudformation.sa-east-1.amazonaws.com",
	"https://ecs.sa-east-1.amazonaws.com",
	"https://streams.dynamodb.sa-east-1.amazonaws.com",
}
View Source
var USEast = Region{
	"us-east-1",
	"https://ec2.us-east-1.amazonaws.com",
	"https://s3.amazonaws.com",
	"",
	false,
	false,
	"https://sdb.amazonaws.com",
	"https://email.us-east-1.amazonaws.com",
	"https://sns.us-east-1.amazonaws.com",
	"https://sqs.us-east-1.amazonaws.com",
	"https://iam.amazonaws.com",
	"https://elasticloadbalancing.us-east-1.amazonaws.com",
	"https://dynamodb.us-east-1.amazonaws.com",
	ServiceInfo{"https://monitoring.us-east-1.amazonaws.com", V2Signature},
	"https://autoscaling.us-east-1.amazonaws.com",
	ServiceInfo{"https://rds.us-east-1.amazonaws.com", V2Signature},
	"https://sts.amazonaws.com",
	"https://cloudformation.us-east-1.amazonaws.com",
	"https://ecs.us-east-1.amazonaws.com",
	"https://streams.dynamodb.us-east-1.amazonaws.com",
}
View Source
var USGovWest = Region{
	"us-gov-west-1",
	"https://ec2.us-gov-west-1.amazonaws.com",
	"https://s3-fips-us-gov-west-1.amazonaws.com",
	"",
	true,
	true,
	"",
	"",
	"https://sns.us-gov-west-1.amazonaws.com",
	"https://sqs.us-gov-west-1.amazonaws.com",
	"https://iam.us-gov.amazonaws.com",
	"https://elasticloadbalancing.us-gov-west-1.amazonaws.com",
	"https://dynamodb.us-gov-west-1.amazonaws.com",
	ServiceInfo{"https://monitoring.us-gov-west-1.amazonaws.com", V2Signature},
	"https://autoscaling.us-gov-west-1.amazonaws.com",
	ServiceInfo{"https://rds.us-gov-west-1.amazonaws.com", V2Signature},
	"https://sts.amazonaws.com",
	"https://cloudformation.us-gov-west-1.amazonaws.com",
	"https://ecs.us-gov-west-1.amazonaws.com",
	"https://streams.dynamodb.us-gov-west-1.amazonaws.com",
}
View Source
var USWest = Region{
	"us-west-1",
	"https://ec2.us-west-1.amazonaws.com",
	"https://s3-us-west-1.amazonaws.com",
	"",
	true,
	true,
	"https://sdb.us-west-1.amazonaws.com",
	"",
	"https://sns.us-west-1.amazonaws.com",
	"https://sqs.us-west-1.amazonaws.com",
	"https://iam.amazonaws.com",
	"https://elasticloadbalancing.us-west-1.amazonaws.com",
	"https://dynamodb.us-west-1.amazonaws.com",
	ServiceInfo{"https://monitoring.us-west-1.amazonaws.com", V2Signature},
	"https://autoscaling.us-west-1.amazonaws.com",
	ServiceInfo{"https://rds.us-west-1.amazonaws.com", V2Signature},
	"https://sts.amazonaws.com",
	"https://cloudformation.us-west-1.amazonaws.com",
	"https://ecs.us-west-1.amazonaws.com",
	"https://streams.dynamodb.us-west-1.amazonaws.com",
}
View Source
var USWest2 = Region{
	"us-west-2",
	"https://ec2.us-west-2.amazonaws.com",
	"https://s3-us-west-2.amazonaws.com",
	"",
	true,
	true,
	"https://sdb.us-west-2.amazonaws.com",
	"https://email.us-west-2.amazonaws.com",
	"https://sns.us-west-2.amazonaws.com",
	"https://sqs.us-west-2.amazonaws.com",
	"https://iam.amazonaws.com",
	"https://elasticloadbalancing.us-west-2.amazonaws.com",
	"https://dynamodb.us-west-2.amazonaws.com",
	ServiceInfo{"https://monitoring.us-west-2.amazonaws.com", V2Signature},
	"https://autoscaling.us-west-2.amazonaws.com",
	ServiceInfo{"https://rds.us-west-2.amazonaws.com", V2Signature},
	"https://sts.amazonaws.com",
	"https://cloudformation.us-west-2.amazonaws.com",
	"https://ecs.us-west-2.amazonaws.com",
	"https://streams.dynamodb.us-west-2.amazonaws.com",
}

Functions

func Encode

func Encode(s string) string

Encode takes a string and URI-encodes it in a way suitable to be used in AWS signatures.

func ExpBackoff

func ExpBackoff(try int)

func GetMetaData

func GetMetaData(path string) (contents []byte, err error)

GetMetaData retrieves instance metadata about the current machine.

See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html for more details.

func LinearBackoff

func LinearBackoff(try int)

func MakeParams

func MakeParams(action string) map[string]string

Create a base set of params for an action

func NewClient

func NewClient(rt *ResilientTransport) *http.Client

Convenience method for creating an http client

Types

type AWSService

type AWSService interface {
	// Queries the AWS service at a given method/path with the params and
	// returns an http.Response and error
	Query(method, path string, params map[string]string) (*http.Response, error)
	// Builds an error given an XML payload in the http.Response, can be used
	// to process an error if the status code is not 200 for example.
	BuildError(r *http.Response) error
}

An AWS Service interface with the API to query the AWS service

Supplied as an easy way to mock out service calls during testing.

type Attempt

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

func (*Attempt) HasNext

func (a *Attempt) HasNext() bool

HasNext returns whether another attempt will be made if the current one fails. If it returns true, the following call to Next is guaranteed to return true.

func (*Attempt) Next

func (a *Attempt) Next() bool

Next waits until it is time to perform the next attempt or returns false if it is time to stop trying.

type AttemptStrategy

type AttemptStrategy struct {
	Total time.Duration // total duration of attempt.
	Delay time.Duration // interval between each try in the burst.
	Min   int           // minimum number of retries; overrides Total
}

AttemptStrategy represents a strategy for waiting for an action to complete successfully. This is an internal type used by the implementation of other goamz packages.

func (AttemptStrategy) Start

func (s AttemptStrategy) Start() *Attempt

Start begins a new sequence of attempts for the given strategy.

type Auth

type Auth struct {
	AccessKey, SecretKey string
	// contains filtered or unexported fields
}

func EnvAuth

func EnvAuth() (auth Auth, err error)

EnvAuth creates an Auth based on environment information. The AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are used. AWS_SESSION_TOKEN is used if present.

func GetAuth

func GetAuth(accessKey string, secretKey, token string, expiration time.Time) (auth Auth, err error)

GetAuth creates an Auth based on either passed in credentials, environment information or instance based role credentials.

func NewAuth

func NewAuth(accessKey, secretKey, token string, expiration time.Time) *Auth

To be used with other APIs that return auth credentials such as STS

func SharedAuth

func SharedAuth() (auth Auth, err error)

SharedAuth creates an Auth based on shared credentials stored in $HOME/.aws/credentials. The AWS_PROFILE environment variables is used to select the profile.

func (*Auth) Expiration

func (a *Auth) Expiration() time.Time

func (*Auth) Token

func (a *Auth) Token() string

type BaseResponse

type BaseResponse struct {
	ResponseMetadata ResponseMetadata
}

type DeadlineFunc

type DeadlineFunc func() time.Time

type Error

type Error struct {
	StatusCode int
	Type       string
	Code       string
	Message    string
	RequestId  string
}

func (*Error) Error

func (err *Error) Error() string

type ErrorResponse

type ErrorResponse struct {
	Errors    Error  `xml:"Error"`
	RequestId string // A unique ID for tracking the request
}

type Region

type Region struct {
	Name                    string // the canonical name of this region.
	EC2Endpoint             string
	S3Endpoint              string
	S3BucketEndpoint        string // Not needed by AWS S3. Use ${bucket} for bucket name.
	S3LocationConstraint    bool   // true if this region requires a LocationConstraint declaration.
	S3LowercaseBucket       bool   // true if the region requires bucket names to be lower case.
	SDBEndpoint             string
	SESEndpoint             string
	SNSEndpoint             string
	SQSEndpoint             string
	IAMEndpoint             string
	ELBEndpoint             string
	DynamoDBEndpoint        string
	CloudWatchServicepoint  ServiceInfo
	AutoScalingEndpoint     string
	RDSEndpoint             ServiceInfo
	STSEndpoint             string
	CloudFormationEndpoint  string
	ECSEndpoint             string
	DynamoDBStreamsEndpoint string
}

Region defines the URLs where AWS services may be accessed.

See http://goo.gl/d8BP1 for more details.

type ResilientTransport

type ResilientTransport struct {
	// Timeout is the maximum amount of time a dial will wait for
	// a connect to complete.
	//
	// The default is no timeout.
	//
	// With or without a timeout, the operating system may impose
	// its own earlier timeout. For instance, TCP timeouts are
	// often around 3 minutes.
	DialTimeout time.Duration

	// MaxTries, if non-zero, specifies the number of times we will retry on
	// failure. Retries are only attempted for temporary network errors or known
	// safe failures.
	MaxTries    int
	Deadline    DeadlineFunc
	ShouldRetry RetryableFunc
	Wait        WaitFunc
	// contains filtered or unexported fields
}

func (*ResilientTransport) RoundTrip

func (t *ResilientTransport) RoundTrip(req *http.Request) (*http.Response, error)

type ResponseMetadata

type ResponseMetadata struct {
	RequestId string // A unique ID for tracking the request
}

ResponseMetadata

type RetryableFunc

type RetryableFunc func(*http.Request, *http.Response, error) bool

type Route53Signer

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

func NewRoute53Signer

func NewRoute53Signer(auth Auth) *Route53Signer

func (*Route53Signer) Sign

func (s *Route53Signer) Sign(req *http.Request)

Adds all the required headers for AWS Route53 API to the request including the authorization

type Service

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

Implements a Server Query/Post API to easily query AWS services and build errors when desired

func NewService

func NewService(auth Auth, service ServiceInfo) (s *Service, err error)

Create a new AWS server to handle making requests

func (*Service) BuildError

func (s *Service) BuildError(r *http.Response) error

func (*Service) Query

func (s *Service) Query(method, path string, params map[string]string) (resp *http.Response, err error)

type ServiceInfo

type ServiceInfo struct {
	Endpoint string
	Signer   uint
}

Defines the service endpoint and correct Signer implementation to use to sign requests for this endpoint

type Signer

type Signer interface {
	Sign(method, path string, params map[string]string)
}

Designates a signer interface suitable for signing AWS requests, params should be appropriately encoded for the request before signing.

A signer should be initialized with Auth and the appropriate endpoint.

type V2Signer

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

func NewV2Signer

func NewV2Signer(auth Auth, service ServiceInfo) (*V2Signer, error)

func (*V2Signer) Sign

func (s *V2Signer) Sign(method, path string, params map[string]string)

type V4Signer

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

The V4Signer encapsulates all of the functionality to sign a request with the AWS Signature Version 4 Signing Process. (http://goo.gl/u1OWZz)

func NewV4Signer

func NewV4Signer(auth Auth, serviceName string, region Region) *V4Signer

Return a new instance of a V4Signer capable of signing AWS requests.

func (*V4Signer) Sign

func (s *V4Signer) Sign(req *http.Request)

Sign a request according to the AWS Signature Version 4 Signing Process. (http://goo.gl/u1OWZz)

The signed request will include an "x-amz-date" header with a current timestamp if a valid "x-amz-date" or "date" header was not available in the original request. In addition, AWS Signature Version 4 requires the "host" header to be a signed header, therefor the Sign method will manually set a "host" header from the request.Host.

The signed request will include a new "Authorization" header indicating that the request has been signed.

Any changes to the request after signing the request will invalidate the signature.

type WaitFunc

type WaitFunc func(try int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL