awssm

package
v0.0.0-...-7bfb7dc Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 6 Imported by: 0

README

awssm

The awssm package provides urfave/cli/v3 value sources backed by AWS Secrets Manager. It seamlessly handles both SecretString and SecretBinary return values.

Usage

import (
    "github.com/aws-contrib/aws-cli/awssm"
    "github.com/urfave/cli/v3"
)

// Fetch a single secret
&cli.StringFlag{
    Name: "api-key",
    Sources: cli.NewValueSourceChain(
        awssm.Secret("my-app-api-key"),
    ),
}
Fallbacks (Multiple Secrets)

If you have multiple secrets you want to check as fallbacks, use the awssm.Secrets helper:

&cli.StringFlag{
    Name: "api-key",
    Sources: awssm.Secrets("my-app-api-key", "legacy-app-api-key"),
}
Custom AWS Configuration

You can pass standard AWS SDK functional options to the constructors to configure the underlying AWS client (e.g., setting a specific region or custom endpoint).

import "github.com/aws/aws-sdk-go-v2/config"

awssm.Secret("my-secret", config.WithRegion("us-west-2"))

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Secrets

func Secrets(secretIds ...string) cli.ValueSourceChain

Secrets is a helper function to encapsulate a number of ValueSource together as a ValueSourceChain.

Types

type ValueSource

type ValueSource struct {
	SecretId string
	Options  []func(*config.LoadOptions) error
}

ValueSource retrieves values from AWS Secrets Manager. It implements the cli.ValueSource interface.

func Secret

func Secret(secretId string, opts ...func(*config.LoadOptions) error) *ValueSource

Secret creates a new ValueSource for the given secret ID. Optional AWS SDK configuration options can be provided.

func (*ValueSource) GoString

func (f *ValueSource) GoString() string

GoString returns a Go-syntax representation of the ValueSource.

func (*ValueSource) Lookup

func (f *ValueSource) Lookup() (string, bool)

Lookup retrieves the secret value from AWS Secrets Manager. It returns the secret value and a boolean indicating whether the retrieval was successful.

func (*ValueSource) String

func (f *ValueSource) String() string

String returns a string representation of the ValueSource.

Jump to

Keyboard shortcuts

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