ec2metadata

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2015 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRetries = 3

DefaultRetries states the default number of times the service client will attempt to retry a failed request before failing.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*service.Service
}

A Client is an EC2 Metadata service Client.

func New

func New(config *Config) *Client

New creates a new instance of the EC2 Metadata service client.

In the general use case the configuration for this service client should not be needed and `nil` can be provided. Configuration is only needed if the `ec2metadata.Config` defaults need to be overridden. Eg. Setting LogLevel.

@note This configuration will NOT be merged with the default AWS service client configuration `defaults.DefaultConfig`. Due to circular dependencies with the defaults package and credentials EC2 Role Provider.

func (*Client) Available

func (c *Client) Available() bool

Available returns if the application has access to the EC2 Metadata service. Can be used to determine if application is running within an EC2 Instance and the metadata service is available.

func (*Client) GetMetadata

func (c *Client) GetMetadata(p string) (string, error)

GetMetadata uses the path provided to request

func (*Client) Region

func (c *Client) Region() (string, error)

Region returns the region the instance is running in.

type Config

type Config struct {
	// An optional endpoint URL (hostname only or fully qualified URI)
	// that overrides the default service endpoint for a client. Set this
	// to nil, or `""` to use the default service endpoint.
	Endpoint *string

	// The HTTP client to use when sending requests. Defaults to
	// `http.DefaultClient`.
	HTTPClient *http.Client

	// An integer value representing the logging level. The default log level
	// is zero (LogOff), which represents no logging. To enable logging set
	// to a LogLevel Value.
	Logger aws.Logger

	// The logger writer interface to write logging messages to. Defaults to
	// standard out.
	LogLevel *aws.LogLevelType

	// The maximum number of times that a request will be retried for failures.
	// Defaults to DefaultRetries for the number of retries to be performed
	// per request.
	MaxRetries *int
}

A Config provides the configuration for the EC2 Metadata service.

Jump to

Keyboard shortcuts

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