sev

package module
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: MIT Imports: 12 Imported by: 0

README

sev

CI

A tool that retrieves AWS Secrets Manager / Parameter Store values, sets them to environment variables, and executes commands.

Usage

Usage: sev --config="~/.sev.toml" <profile> <command> ... [flags]

Arguments:
  <profile>        Profile name.
  <command> ...    Command and arguments.

Flags:
  -h, --help                         Show help.
      --config="~/.sev.toml"         Config file path ($SEV_CONFIG).
      --default-profile=STRING       Fallback profile name ($SEV_DEFAULT_PROFILE).
      --[no-]override-aws-profile    Use AWS_PROFILE in sev config (enabled by default).
      --version

Example

$ aws secretsmanager get-secret-value --secret-id foo/bar
{
  ...
  "SecretString": "BAZ",
  ...

$ aws secretsmanager get-secret-value --secret-id foo/zoo # JSON secret
{
  ...
  "SecretString": "{\"TOKEN\":\"AAA\",\"SECRET\":\"BBB\"}",
  ...
$ cat ~/.sev.toml
[default]
AWS_PROFILE = "prof1" # By default, the AWS_PROFILE in the configuration file is used.
FOO = "secretsmanager://foo/bar"
ZOO = "secretsmanager://foo/zoo:TOKEN"
BAZ = "BAZBAZBAZ"

[another]
HOGE = "secretsmanager://foo/zoo:SECRET"
FOGA = "secretsmanager://foo/bar"
PIYO = "PIYOPIYOPIYO"
# Run `env` command with extra environment variables
$ sev default -- env
FOO=BAZ
ZOO=AAA
BAZ=BAZBAZBAZ

$ sev another -- env
HOGE=BBB
FUGA=BAZ
PIYO=PIYOPIYOPIYO

Get values from Parameter Store

[default]
AWS_PROFILE = "prof1"
FOO = "parameterstore:///foo/bar"
ZOO = "parameterstore:///foo/zoo"
BAZ = "BAZBAZBAZ"

Documentation

Index

Constants

View Source
const (
	KeyAWSProfile        = "AWS_PROFILE"
	PrefixSecretsManager = "secretsmanager://"
	PrefixParameterStore = "parameterstore://"
)

Variables

This section is empty.

Functions

func Run

func Run(options *Options) error

Types

type AWSConfigOptFns added in v0.7.0

type AWSConfigOptFns []func(*config.LoadOptions) error

type Options

type Options struct {
	Config             string          `required:"" default:"~/.sev.toml" env:"SEV_CONFIG" help:"Config file path."`
	Profile            string          `arg:"" required:"" help:"Profile name."`
	Command            []string        `arg:"" required:"" help:"Command and arguments."`
	DefaultProfile     string          `env:"SEV_DEFAULT_PROFILE" help:"Fallback profile name."`
	OverrideAwsProfile bool            `negatable:"" default:"true" help:"Use AWS_PROFILE in sev config (enabled by default)."`
	AWSConfigOptFns    AWSConfigOptFns `kong:"-"`
}

func (*Options) AfterApply

func (options *Options) AfterApply() error

type Providers added in v0.7.0

type Providers struct {
	// contains filtered or unexported fields
}

func NewProviders added in v0.7.0

func NewProviders(fns AWSConfigOptFns) *Providers

func (*Providers) NewSSMClient added in v0.7.0

func (p *Providers) NewSSMClient() (*ssm.Client, error)

func (*Providers) NewSecretsManagerClient added in v0.7.0

func (p *Providers) NewSecretsManagerClient() (*secretsmanager.Client, error)

type ProviderssIface added in v0.7.0

type ProviderssIface interface {
	NewSecretsManagerClient() (*secretsmanager.Client, error)
	NewSSMClient() (*ssm.Client, error)
}

type SSMGetParameterAPI added in v0.7.0

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

type SecretsManagerGetSecretValueAPI added in v0.2.0

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

Directories

Path Synopsis
cmd
sev

Jump to

Keyboard shortcuts

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