Struct: ec2metadata.EC2Metadata
Overview
A EC2Metadata is an EC2 Metadata service Client.
Implemented Interfaces
s3crypto.Cipher, s3manager.ReadSeekerWriteTo, s3manager.WriterReadFrom
Fields included from client.Client
client.Client.Config, client.Client.Handlers
Constructor Functions collapse
-
func New(p client.ConfigProvider, cfgs ...*aws.Config) *EC2Metadata
New creates a new instance of the EC2Metadata client with a session.
Method Summary collapse
-
func (c *EC2Metadata) Available() bool
Available returns if the application has access to the EC2 Metadata service.
-
func (c *EC2Metadata) AvailableWithContext(ctx aws.Context) bool
AvailableWithContext returns if the application has access to the EC2 Metadata service.
-
func (c *EC2Metadata) GetDynamicData(p string) (string, error)
GetDynamicData uses the path provided to request information from the EC2 instance metadata service for dynamic data.
-
func (c *EC2Metadata) GetDynamicDataWithContext(ctx aws.Context, p string) (string, error)
GetDynamicDataWithContext uses the path provided to request information from the EC2 instance metadata service for dynamic data.
-
func (c *EC2Metadata) GetInstanceIdentityDocument() (EC2InstanceIdentityDocument, error)
GetInstanceIdentityDocument retrieves an identity document describing an instance.
-
func (c *EC2Metadata) GetInstanceIdentityDocumentWithContext(ctx aws.Context) (EC2InstanceIdentityDocument, error)
GetInstanceIdentityDocumentWithContext retrieves an identity document describing an instance.
-
func (c *EC2Metadata) GetMetadata(p string) (string, error)
GetMetadata uses the path provided to request information from the EC2 instance metadata service.
-
func (c *EC2Metadata) GetMetadataWithContext(ctx aws.Context, p string) (string, error)
GetMetadataWithContext uses the path provided to request information from the EC2 instance metadata service.
-
func (c *EC2Metadata) GetUserData() (string, error)
GetUserData returns the userdata that was configured for the service.
-
func (c *EC2Metadata) GetUserDataWithContext(ctx aws.Context) (string, error)
GetUserDataWithContext returns the userdata that was configured for the service.
-
func (c *EC2Metadata) IAMInfo() (EC2IAMInfo, error)
IAMInfo retrieves IAM info from the metadata API.
-
func (c *EC2Metadata) IAMInfoWithContext(ctx aws.Context) (EC2IAMInfo, error)
IAMInfoWithContext retrieves IAM info from the metadata API.
-
func (c *EC2Metadata) Region() (string, error)
Region returns the region the instance is running in.
-
func (c *EC2Metadata) RegionWithContext(ctx aws.Context) (string, error)
RegionWithContext returns the region the instance is running in.
Methods included from client.Client
client.Client.AddDebugHandlers(), client.Client.NewRequest()
Function Details
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))
66 67 68 69 |
// File 'aws/ec2metadata/service.go', line 66
|
Method Details
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.
207 208 209 |
// File 'aws/ec2metadata/api.go', line 207
|
func (c *EC2Metadata) AvailableWithContext(ctx aws.Context) bool
AvailableWithContext 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.
214 215 216 217 218 219 220 |
// File 'aws/ec2metadata/api.go', line 214
|
func (c *EC2Metadata) GetDynamicData(p string) (string, error)
GetDynamicData uses the path provided to request information from the EC2 instance metadata service for dynamic data. The content will be returned as a string, or error if the request failed.
104 105 106 |
// File 'aws/ec2metadata/api.go', line 104
|
func (c *EC2Metadata) GetDynamicDataWithContext(ctx aws.Context, p string) (string, error)
GetDynamicDataWithContext uses the path provided to request information from the EC2 instance metadata service for dynamic data. The content will be returned as a string, or error if the request failed.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
// File 'aws/ec2metadata/api.go', line 111
|
func (c *EC2Metadata) GetInstanceIdentityDocument() (EC2InstanceIdentityDocument, error)
GetInstanceIdentityDocument retrieves an identity document describing an instance. Error is returned if the request fails or is unable to parse the response.
129 130 131 |
// File 'aws/ec2metadata/api.go', line 129
|
func (c *EC2Metadata) GetInstanceIdentityDocumentWithContext(ctx aws.Context) (EC2InstanceIdentityDocument, error)
GetInstanceIdentityDocumentWithContext retrieves an identity document describing an instance. Error is returned if the request fails or is unable to parse the response.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
// File 'aws/ec2metadata/api.go', line 136
|
func (c *EC2Metadata) GetMetadata(p string) (string, error)
GetMetadata uses the path provided to request information from the EC2 instance metadata service. The content will be returned as a string, or error if the request failed.
53 54 55 |
// File 'aws/ec2metadata/api.go', line 53
|
func (c *EC2Metadata) GetMetadataWithContext(ctx aws.Context, p string) (string, error)
GetMetadataWithContext uses the path provided to request information from the EC2 instance metadata service. The content will be returned as a string, or error if the request failed.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
// File 'aws/ec2metadata/api.go', line 60
|
func (c *EC2Metadata) GetUserData() (string, error)
GetUserData returns the userdata that was configured for the service. If there is no user-data setup for the EC2 instance a “NotFoundError” error code will be returned.
79 80 81 |
// File 'aws/ec2metadata/api.go', line 79
|
func (c *EC2Metadata) GetUserDataWithContext(ctx aws.Context) (string, error)
GetUserDataWithContext returns the userdata that was configured for the service. If there is no user-data setup for the EC2 instance a “NotFoundError” error code will be returned.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
// File 'aws/ec2metadata/api.go', line 86
|
func (c *EC2Metadata) IAMInfo() (EC2IAMInfo, error)
IAMInfo retrieves IAM info from the metadata API
155 156 157 |
// File 'aws/ec2metadata/api.go', line 155
|
func (c *EC2Metadata) IAMInfoWithContext(ctx aws.Context) (EC2IAMInfo, error)
IAMInfoWithContext retrieves IAM info from the metadata API
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
// File 'aws/ec2metadata/api.go', line 160
|
func (c *EC2Metadata) Region() (string, error)
Region returns the region the instance is running in.
185 186 187 |
// File 'aws/ec2metadata/api.go', line 185
|
func (c *EC2Metadata) RegionWithContext(ctx aws.Context) (string, error)
RegionWithContext returns the region the instance is running in.
190 191 192 193 194 195 196 197 198 199 200 201 202 |
// File 'aws/ec2metadata/api.go', line 190
|