metadata

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 10 Imported by: 0

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

View Source
const Path = "/2026-01-15/metadata/execution-environment"

Variables

This section is empty.

Functions

func ClearMetadataCache

func ClearMetadataCache()

func GetMetadata

func GetMetadata(ctx context.Context, options ...Options) (map[string]any, error)
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.
}

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(config Config) *Client

func (*Client) ClearCache

func (c *Client) ClearCache()

func (*Client) Get

func (c *Client) Get(ctx context.Context, options ...Options) (map[string]any, error)

type Config

type Config struct {
	// Endpoint explicitly enables local HTTP access outside Lambda.
	Endpoint   string
	Token      string
	HTTPClient *http.Client
}

type Error

type Error struct {
	StatusCode int
	Err        error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Options

type Options struct{ Timeout time.Duration }

Jump to

Keyboard shortcuts

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