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 ¶
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()
}
Output:
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.
Click to show internal directories.
Click to hide internal directories.