Documentation
¶
Index ¶
- type Manager
- func (self *Manager) Delete(ctx context.Context, key string) (err error)
- func (self *Manager) Describe(ctx context.Context, key, description string) (err error)
- func (self *Manager) Expand(ctx context.Context, value string) (_ string, err error)
- func (self *Manager) Get(ctx context.Context, key string) (_ json.RawMessage, err error)
- func (self *Manager) List(ctx context.Context) (_ []credential.Credential, err error)
- func (self *Manager) Set(ctx context.Context, key string, value json.RawMessage) (err error)
- type Opt
- func WithCredentials(accessKeyID, secretAccessKey, sessionToken string) Opt
- func WithEndpoint(endpoint string) Opt
- func WithEnv() Opt
- func WithKMSKey(keyID string) Opt
- func WithPrefix(prefix string) Opt
- func WithProfile(profile string) Opt
- func WithRecoveryWindow(days int) Opt
- func WithRegion(region string) Opt
- func WithTracer(tracer trace.Tracer) Opt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager stores credentials as secrets in AWS Secrets Manager, one for each key, which AWS encrypts with KMS
func New ¶
New returns a manager for credentials in AWS Secrets Manager. The region, credentials and endpoint are from the AWS environment variables, such as AWS_REGION, AWS_PROFILE, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, and the shared configuration files, unless they are set with options.
func (*Manager) Delete ¶
Delete schedules the key's secret for deletion, after the recovery window set with WithRecoveryWindow, or AWS's default of 30 days, or deletes it at once when the window is zero. A secret with the key can't be created again until the deletion is complete. Returns ErrNotFound when there isn't one.
func (*Manager) Describe ¶
Describe sets the description of the key's secret, which AWS keeps beside it, unencrypted, or removes it, when it's empty, without changing its value, and returns ErrNotFound when there isn't one
func (*Manager) Expand ¶
Expand replaces each $KEY or ${KEY} placeholder in the value with the credential for the key, which must be a string, or with the environment variable, with WithEnv, when there is no secret for it. Keys containing "-" must use the ${KEY} form. Each secret is read once, however many times it's used. Returns an error, rather than a partly expanded value, if a placeholder is not a valid key, or its credential does not exist or is not a string.
func (*Manager) Get ¶
Get returns the credential for the key, as JSON, or the environment variable's value, with WithEnv, when there is no secret for it. A secret which isn't JSON is returned as a JSON string. Returns an error if the key isn't valid, or the credential doesn't exist.
func (*Manager) List ¶
func (self *Manager) List(ctx context.Context) (_ []credential.Credential, err error)
List returns the stored credentials, in key order, without their values: the secrets whose names start with the prefix, and the rest of which is a key. Secrets which are scheduled for deletion aren't listed.
type Opt ¶
type Opt func(*opt) error
Opt is a functional option for the AWS credential manager
func WithCredentials ¶
WithCredentials sets static credentials, in place of AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN, or the profile's. The session token is optional.
func WithEndpoint ¶
WithEndpoint sets the endpoint URL, in place of AWS_ENDPOINT_URL, such as for a local emulator
func WithEnv ¶
func WithEnv() Opt
WithEnv reads a credential from the environment when there is no secret for it, so $KEY is expanded from the environment variable KEY. The environment is read-only, so credentials are still stored as secrets.
func WithKMSKey ¶
WithKMSKey sets the KMS key which new secrets are encrypted with, in place of the account's default key for Secrets Manager
func WithPrefix ¶
WithPrefix sets a prefix for the secret names, such as "myapp/", so the credential for key KEY is the secret "myapp/KEY"
func WithProfile ¶
WithProfile sets the shared configuration profile, in place of AWS_PROFILE
func WithRecoveryWindow ¶
WithRecoveryWindow sets the number of days, from 7 to 30, that a deleted secret can be recovered for, in place of AWS's default of 30 days, or 0 to delete secrets at once, without recovery
func WithRegion ¶
WithRegion sets the AWS region, in place of AWS_REGION or the profile's
func WithTracer ¶
WithTracer sets the tracer used for tracing operations