ec2

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2015 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EC2_METADATA_SERVICE_URL                      = "http://169.254.169.254"
	SECURITY_CREDENTIALS_RESOURCE                 = "/2014-02-25/meta-data/iam/security-credentials/"
	INSTANCE_IDENTITY_DOCUMENT_RESOURCE           = "/2014-02-25/dynamic/instance-identity/document"
	INSTANCE_IDENTITY_DOCUMENT_SIGNATURE_RESOURCE = "/2014-02-25/dynamic/instance-identity/signature"
	SIGNED_INSTANCE_IDENTITY_DOCUMENT_RESOURCE    = "/2014-02-25/dynamic/instance-identity/pkcs7"
	EC2_METADATA_REQUEST_TIMEOUT                  = time.Duration(1 * time.Second)
)

Variables

View Source
var DefaultClient = NewEC2MetadataClient(nil)

DefaultClient is the client used for package level methods.

Functions

func ReadResource

func ReadResource(path string) ([]byte, error)

ReadResource reads a given path from the EC2 metadata service using the default client

Types

type EC2MetadataClient

type EC2MetadataClient interface {
	DefaultCredentials() (*RoleCredentials, error)
	ReadResource(string) ([]byte, error)
	InstanceIdentityDocument() (*InstanceIdentityDocument, error)
}

func NewBlackholeEC2MetadataClient added in v1.5.0

func NewBlackholeEC2MetadataClient() EC2MetadataClient

func NewEC2MetadataClient

func NewEC2MetadataClient(httpClient HttpClient) EC2MetadataClient

type HttpClient

type HttpClient interface {
	Get(string) (*http.Response, error)
}

type InstanceIdentityDocument

type InstanceIdentityDocument struct {
	InstanceId       string  `json:"instanceId"`
	InstanceType     string  `json:"instanceType"`
	Region           string  `json:"region"`
	PrivateIp        *string `json:"privateIp"`
	AvailabilityZone string  `json:"availabilityZone"`
}

func GetInstanceIdentityDocument

func GetInstanceIdentityDocument() (*InstanceIdentityDocument, error)

GetInstanceIdentityDocument returns an InstanceIdentityDocument read using the default client

type RoleCredentials

type RoleCredentials struct {
	Code            string    `json:"Code"`
	LastUpdated     time.Time `json:"LastUpdated"`
	Type            string    `json:"Type"`
	AccessKeyId     string    `json:"AccessKeyId"`
	SecretAccessKey string    `json:"SecretAccessKey"`
	Token           string    `json:"Token"`
	Expiration      time.Time `json:"Expiration"`
}

func DefaultCredentials

func DefaultCredentials() (*RoleCredentials, error)

DefaultCredentials returns the instance's default role read using the default client

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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