aws-credscache-go

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: MIT

README

AWS Credentials Cache for Go

This module provides credentials caching utilities that are partially compatible with AWS CLI.

Installation

go get github.com/Aton-Kish/aws-credscache-go

Usage

package main

import (
	"context"
	"log"

	credscache "github.com/Aton-Kish/aws-credscache-go/sdkv2"
	"github.com/aws/aws-sdk-go-v2/config"
	"github.com/aws/aws-sdk-go-v2/credentials/stscreds"
)

func main() {
	cfg, err := config.LoadDefaultConfig(context.Background(), config.WithAssumeRoleCredentialOptions(func(options *stscreds.AssumeRoleOptions) {
		options.TokenProvider = stscreds.StdinTokenProvider
	}))
	if err != nil {
		log.Fatal(err)
	}

	// Inject file cache provider
	if _, err := credscache.InjectFileCacheProvider(&cfg); err != nil {
		log.Fatal(err)
	}

	// client := ec2.NewFromConfig(cfg)
}

See exmples for more details.

Development

Setup
go mod tidy
Generate code
rm -rf internal/mock
go generate ./...
Test
: simple
go test ./...
: verbose
go test -v ./...
Doc
go run golang.org/x/tools/cmd/godoc@latest -http ":6060"

License

This library is licensed under the MIT License, see LICENSE.

Directories

Path Synopsis
internal
mock/github.com/aws/aws-sdk-go-v2/aws
Package mock_aws is a generated GoMock package.
Package mock_aws is a generated GoMock package.
mock/github.com/aws/aws-sdk-go-v2/credentials/stscreds
Package mock_stscreds is a generated GoMock package.
Package mock_stscreds is a generated GoMock package.
Package credscache provides credentials caching utilities for the AWS SDK for Go v2.
Package credscache provides credentials caching utilities for the AWS SDK for Go v2.

Jump to

Keyboard shortcuts

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