Documentation ¶
Overview ¶
Package ec2metadata provides the client for making API calls to the EC2 Metadata service.
Index ¶
Constants ¶
const ServiceName = "ec2metadata"
ServiceName is the name of the service.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EC2Metadata ¶
A EC2Metadata is an EC2 Metadata service Client.
func New ¶
func New(p client.ConfigProvider, cfgs ...*aws.Config) *EC2Metadata
New creates a new instance of the EC2Metadata client with a session. This client is safe to use across multiple goroutines.
Example:
// Create a EC2Metadata client from just a session. svc := ec2metadata.New(mySession) // Create a EC2Metadata client with additional configuration svc := ec2metadata.New(mySession, aws.NewConfig().WithLogLevel(aws.LogDebugHTTPBody))
func NewClient ¶
func NewClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string, opts ...func(*client.Client)) *EC2Metadata
NewClient returns a new EC2Metadata client. Should be used to create a client when not using a session. Generally using just New with a session is preferred.
If an unmodified HTTP client is provided from the stdlib default, or no client the EC2RoleProvider's EC2Metadata HTTP client's timeout will be shortened. To disable this set Config.EC2MetadataDisableTimeoutOverride to false. Enabled by default.
func (*EC2Metadata) Available ¶
func (c *EC2Metadata) 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 (*EC2Metadata) GetMetadata ¶
func (c *EC2Metadata) GetMetadata(p string) (string, error)
GetMetadata uses the path provided to request
func (*EC2Metadata) Region ¶
func (c *EC2Metadata) Region() (string, error)
Region returns the region the instance is running in.