secretlamb

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: MIT Imports: 10 Imported by: 2

README

secretlamb

CI Go Reference GitHub tag (latest by date) Go Report Card

Golang library for using AWS Parameters and Secrets Lambda Extension.

Installation

go get github.com/winebarrel/secretlamb

Usage

Parameter Store
package main

import (
	"context"
	"fmt"

	"github.com/aws/aws-lambda-go/lambda"
	"github.com/winebarrel/secretlamb"
)

func HandleRequest(ctx context.Context, event any) (*string, error) {
	client := secretlamb.MustNewParameters() // .WithRetry(3)

	v, err := client.Get("foo")
	//v, err := client.GetWithDecryption("foo")

	if err != nil {
		return nil, err
	}

	fmt.Println(v.Parameter.Value)
	return nil, nil
}

func main() {
	lambda.Start(HandleRequest)
}
Secrets Manager
package main

import (
	"context"
	"fmt"

	"github.com/aws/aws-lambda-go/lambda"
	"github.com/winebarrel/secretlamb"
)

func HandleRequest(ctx context.Context, event any) (*string, error) {
	client := secretlamb.MustNewSecrets() // .WithRetry(3)
	v, err := client.Get("foo")

	if err != nil {
		return nil, err
	}

	fmt.Println(v.SecretString)
	return nil, nil
}

func main() {
	lambda.Start(HandleRequest)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ParameterOption

type ParameterOption struct {
	Key   string
	Value string
}

func ParameterLabel

func ParameterLabel(label string) *ParameterOption

func ParameterVersion

func ParameterVersion(version int) *ParameterOption

func ParameterWithDecryption

func ParameterWithDecryption() *ParameterOption

type ParameterOutput

type ParameterOutput struct {
	Parameter ParameterOutputParameter `json:"Parameter"`
}

type ParameterOutputParameter

type ParameterOutputParameter struct {
	Name             string `json:"Name"`
	Type             string `json:"Type"`
	Value            string `json:"Value"`
	Version          int64  `json:"Version"`
	LastModifiedDate string `json:"LastModifiedDate"`
	Arn              string `json:"ARN"`
	DataType         string `json:"DataType"`
}

type Parameters

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

func MustNewParameters

func MustNewParameters() *Parameters

func NewParameters

func NewParameters() (*Parameters, error)

func (*Parameters) Get

func (p *Parameters) Get(name string, options ...*ParameterOption) (*ParameterOutput, error)

func (*Parameters) GetWithContext added in v0.4.0

func (p *Parameters) GetWithContext(ctx context.Context, name string, options ...*ParameterOption) (*ParameterOutput, error)

func (*Parameters) GetWithDecryption

func (p *Parameters) GetWithDecryption(name string) (*ParameterOutput, error)

func (*Parameters) WithRetry added in v0.3.0

func (p *Parameters) WithRetry(retryMax int) *Parameters

type SecretOption

type SecretOption struct {
	Key   string
	Value string
}

func SecretVersionId

func SecretVersionId(versionId string) *SecretOption

func SecretVersionStage

func SecretVersionStage(versionStage string) *SecretOption

type SecretOutput

type SecretOutput struct {
	Arn           string   `json:"ARN"`
	Name          string   `json:"Name"`
	VersionID     string   `json:"VersionId"`
	SecretString  string   `json:"SecretString"`
	VersionStages []string `json:"VersionStages"`
	CreatedDate   string   `json:"CreatedDate"`
}

type Secrets

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

func MustNewSecrets

func MustNewSecrets() *Secrets

func NewSecrets

func NewSecrets() (*Secrets, error)

func (*Secrets) Get

func (s *Secrets) Get(secretId string, options ...*SecretOption) (*SecretOutput, error)

func (*Secrets) GetWithContext added in v0.4.0

func (s *Secrets) GetWithContext(ctx context.Context, secretId string, options []*SecretOption) (*SecretOutput, error)

func (*Secrets) WithRetry added in v0.3.0

func (s *Secrets) WithRetry(retryMax int) *Secrets

Jump to

Keyboard shortcuts

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