awssmfs

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package awssmfs provides an interface to AWS Secrets Manager which allows you to interact with the Secrets Manager API as a standard filesystem.

This filesystem's behaviour complies with fstest.TestFS.

Usage

To use this filesystem, call New with a base URL. All reads from the filesystem are relative to this base URL. Only the scheme "aws+sm" is supported. The URL may be an opaque URI (with no leading "/" in the path), in which case secrets with names starting with "/" are ignored. If the URL path does begin with "/", secrets with names not starting with "/" are instead ignored.

To scope the filesystem to a specific path, use that path on the URL. For example, for a filesystem that can only read secrets with names starting with "/prod/foo/", you would use a URL like:

aws+sm:///prod/foo/

And for a filesystem that can only read secrets with names starting with "prod/bar/", you would use the following opaque URI:

aws+sm:prod/bar/

Configuration

The AWS Secrets Manager client is configured using the default credential chain (see https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk/#specifying-credentials for more information).

If you require more customized configuration, you can override the default client with the WithSMClientFS function.

Index

Constants

This section is empty.

Variables

View Source
var FS = fsimpl.FSProviderFunc(New, "aws+sm")

FS is used to register this filesystem with an fsimpl.FSMux

Functions

func New

func New(u *url.URL) (fs.FS, error)

New provides a filesystem (an fs.FS) backed by the AWS Secrets Manager, rooted at the given URL. Note that the URL may be either a regular hierarchical URL (like "aws+sm:///foo/bar") or an opaque URI (like "aws+sm:foo/bar"), depending on how secrets are organized in Secrets Manager.

A context can be given by using WithContextFS.

func WithSMClientFS

func WithSMClientFS(smclient SecretsManagerClient, fsys fs.FS) fs.FS

WithSMClientFS overrides the AWS Secrets Manager client used by fs, if the filesystem supports it (i.e. has a WithSMClient method). This can be used for configuring specialized client options.

Note that this should not be used together with WithHTTPClient. If you wish only to override the HTTP client, use WithHTTPClient alone.

Types

type SecretsManagerClient

type SecretsManagerClient interface {
	ListSecrets(ctx context.Context,
		params *secretsmanager.ListSecretsInput,
		optFns ...func(*secretsmanager.Options)) (*secretsmanager.ListSecretsOutput, error)
	GetSecretValue(ctx context.Context,
		params *secretsmanager.GetSecretValueInput,
		optFns ...func(*secretsmanager.Options)) (*secretsmanager.GetSecretValueOutput, error)
}

Jump to

Keyboard shortcuts

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