awssmpfs

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: 17 Imported by: 0

Documentation

Overview

Package awssmpfs provides an interface to the AWS Systems Manager (SSM) Parameter Store which allows you to interact with the SSM Parameter Store API as a standard filesystem.

This filesystem's behaviour complies with testing/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+smp" is supported. The URL may not be opaque (with no leading "/" in the path), as AWS SSM Parameter Store does not support this (1).

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

aws+smp:///prod/foo/

For use with alternate endpoints (e.g. localstack), you can set a host on the URL. For example, for a filesystem that reads parameters from a localstack instance running on localhost, you could use a URL like:

aws+smp://localhost:4566

To retrieve a specific version of a parameter, suffix the path with a colon and the version number. For example, to retrieve version 2 of the parameter "/prod/keys/foo" you would use "foo:2" in the path:

fsys, err := awssmpfs.New("aws+smp:///prod")
f, err := fsys.Open("keys/foo:2")
// etc...

Authentication

To authenticate, the default credential chain is used. This means that credentials can be provided with environment variables, shared credentials files, or EC2 instance metadata. See the credential chain documentation for details.

Extensions

The filesystem may be configured with a few standard and awssmpfs-specific extensions. See the documentation for each extension for more details:

Index

Constants

This section is empty.

Variables

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

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 io/fs.FS) backed by the AWS Systems Manager Parameter Store, rooted at the given URL. The URL should be a regular hierarchical URL (like "aws+smp:///foo/bar" or "aws+smp:///").

func WithClientFS

func WithClientFS(client SSMClient, fsys fs.FS) fs.FS

WithClientFS overrides the AWS Systems Manager client used by fsys, if the filesystem supports it (i.e. has a WithClient method). This can be used for configuring specialized client options.

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

Usually, client would be a *github.com/aws/aws-sdk-go-v2/service/ssm.Client created using github.com/aws/aws-sdk-go-v2/service/ssm.New or github.com/aws/aws-sdk-go-v2/service/ssm.NewFromConfig.

Types

type SSMClient

type SSMClient interface {
	GetParameter(ctx context.Context,
		params *ssm.GetParameterInput,
		optFns ...func(*ssm.Options)) (*ssm.GetParameterOutput, error)
	GetParametersByPath(ctx context.Context,
		params *ssm.GetParametersByPathInput,
		optFns ...func(*ssm.Options)) (*ssm.GetParametersByPathOutput, error)
}

SSMClient is an interface that wraps basic functionality of the AWS SSM client that is used by this filesystem. This interface is usually implemented by github.com/aws/aws-sdk-go-v2/service/ssm.Client.

Jump to

Keyboard shortcuts

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