Documentation
¶
Overview ¶
Package metadata retrieves AWS Lambda execution-environment metadata on demand.
GetMetadata uses the default client. New constructs an application-owned Client with an explicit endpoint, token and HTTP client for custom environments. Importing this package does not fetch metadata.
Caching and errors ¶
Successful responses are cached and returned as independent snapshots. Client.ClearCache invalidates the client cache; ClearMetadataCache invalidates the default cache. Pass invocation context and Options to bound retrieval. Error preserves HTTP status information and underlying errors.
Metadata access remains optional: ordinary logging, tracing and configuration retrieval do not require this module or a metadata request.
For usage and compatibility details, see the user guide.
Index ¶
Examples ¶
Constants ¶
const Path = "/2026-01-15/metadata/execution-environment"
Variables ¶
This section is empty.
Functions ¶
func ClearMetadataCache ¶
func ClearMetadataCache()
func GetMetadata ¶
Example ¶
This example requires a Lambda environment with the metadata endpoint enabled.
package main
import (
"context"
"time"
"github.com/rambow-cloud/powertools-lambda-go/commons/metadata"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
value, err := metadata.GetMetadata(ctx)
if err != nil {
panic(err)
}
_ = value // Consume metadata without including it in application logs.
}
Output:
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ClearCache ¶
func (c *Client) ClearCache()