ssowrap

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2025 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

ssowrap

CI

ssowrap is a single binary tool that run a command using AWS SSO credentials.

[!note] In most cases it is better to use aws configure export-credentials.

Installation

brew install winebarrel/ssowrap/ssowrap

Usage

Usage: ssowrap --aws-profile=STRING <command> [flags]

Arguments:
  <command>    Command and arguments.

Flags:
  -h, --help                                   Show help.
      --aws-profile=STRING                     AWS CLI profile ($AWS_PROFILE).
      --aws-config-file="~/.aws/config"        AWS CLI config file location ($AWS_CONFIG_FILE).
      --awssso-cache-dir="~/.aws/sso/cache"    AWS SSO token cache dir location ($AWS_SSO_CACHE_DIR).
      --version
$ export AWS_PROFILE=my-profile
$ aws sso login
$ ssowrap env | grep ^AWS_

$ cat ./list-users.sh
#!/bin/sh
curl -L "https://iam.amazonaws.com/?Action=ListUsers&Version=2010-05-08" \
  --aws-sigv4 "aws:amz:us-east-1:iam" \
  --user "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" \
  -H "X-Amz-Security-Token: $AWS_SESSION_TOKEN"

# Call AWS IAM API using curl with AWS SSO credentials.
$ ssowrap ./list-users.sh

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, options *Options) error

Types

type Command

type Command []string

func (Command) Run

func (command Command) Run(ctx context.Context, creds *Credentials) error

func (Command) String

func (command Command) String() string

type Credentials

type Credentials struct {
	AccessKeyId     string `env:"AWS_ACCESS_KEY_ID"`
	SecretAccessKey string `env:"AWS_SECRET_ACCESS_KEY"`
	SessionToken    string `env:"AWS_SESSION_TOKEN"`
}

func NewCredsFromRoleCreds

func NewCredsFromRoleCreds(roleCreds *types.RoleCredentials) *Credentials

func (*Credentials) EnvSet

func (creds *Credentials) EnvSet() (env.EnvSet, error)

type Options

type Options struct {
	Command        Command `arg:"" required:"" help:"Command and arguments."`
	AWSProfile     string  `required:"" env:"AWS_PROFILE" help:"AWS CLI profile."`
	AWSConfigFile  string  `default:"~/.aws/config" env:"AWS_CONFIG_FILE" help:"AWS CLI config file location."`
	AWSSSOCacheDir string  `default:"~/.aws/sso/cache" env:"AWS_SSO_CACHE_DIR" help:"AWS SSO token cache dir location."`
	// contains filtered or unexported fields
}

func (*Options) AfterApply

func (options *Options) AfterApply() error

type Role

type Role struct {
	Account string
	Name    string
}

type SSO

type SSO struct {
	*Options
	// contains filtered or unexported fields
}

func NewSSO

func NewSSO(options *Options) *SSO

func (*SSO) GetCredentials

func (ssoClient *SSO) GetCredentials(ctx context.Context) (*Credentials, error)

type SSOCache

type SSOCache struct {
	*Options
	SSOStartUrl string
}

func NewSSOCache

func NewSSOCache(options *Options, ssoStartUrl string) *SSOCache

func (*SSOCache) LastToken

func (ssoCache *SSOCache) LastToken() (*Token, error)

type STS

type STS struct {
	*Options
	// contains filtered or unexported fields
}

func NewSTS

func NewSTS(options *Options) *STS

func (*STS) GetRole

func (stsClient *STS) GetRole(ctx context.Context) (*Role, error)

type Token

type Token struct {
	StartUrl    string
	AccessToken string
	Region      string
	ExpiresAt   time.Time
}

Directories

Path Synopsis
cmd
ssowrap command

Jump to

Keyboard shortcuts

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