aws

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package aws provides AWS ElastiCache and MemoryDB IAM authentication for redisconn.

Index

Examples

Constants

View Source
const (
	RegionDetect                = "detect"
	ServiceElastiCache          = "elasticache"
	ServiceMemoryDB             = "memorydb"
	ResourceTypeServerlessCache = "ServerlessCache"
	DefaultConnMaxLifetime      = 12 * time.Minute
)

AWS IAM signing constants and default connection lifetime.

Variables

This section is empty.

Functions

func NewDynamicAuth

func NewDynamicAuth(ctx context.Context, cfg Config) (*redisconn.DynamicAuth, error)

NewDynamicAuth resolves the AWS credential chain once and returns a callback that signs a fresh token for each new Redis connection.

Example
package main

import (
	"context"

	"github.com/stacklok/toolhive-core/redisconn"
	redisconnaws "github.com/stacklok/toolhive-core/redisconn/aws"
)

func main() {
	auth, err := redisconnaws.NewDynamicAuth(context.Background(), redisconnaws.Config{
		Username:    "redis-iam-user",
		Region:      "us-east-1",
		ClusterName: "orders-cache",
	})
	if err != nil {
		return
	}
	client, err := redisconn.NewClient(context.Background(), &redisconn.Config{
		Addr:        "orders-cache.example.cache.amazonaws.com:6379",
		TLS:         &redisconn.TLSConfig{},
		DynamicAuth: auth,
	})
	if err != nil {
		return
	}
	defer client.Close()
}

Types

type Config

type Config struct {
	// Username is the Redis IAM user included in AUTH and the signed token.
	Username string
	// Region signs the token; RegionDetect resolves it from EC2 IMDS.
	Region string
	// ClusterName is the ElastiCache cache or MemoryDB cluster name.
	ClusterName string
	// ServiceName is empty/ServiceElastiCache or ServiceMemoryDB.
	ServiceName string
	// ResourceType is empty, or ResourceTypeServerlessCache for serverless caches.
	ResourceType string
}

Config configures AWS IAM token signing.

func (Config) Validate

func (c Config) Validate() error

Validate checks required and enum-constrained signing settings.

Jump to

Keyboard shortcuts

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