awsbase

package module
v2.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: MPL-2.0 Imports: 30 Imported by: 15

README

aws-sdk-go-base

An opinionated AWS Go SDK library for consistent authentication configuration between projects and additional helper functions. This library was originally started in HashiCorp Terraform, migrated with the Terraform AWS Provider during the Terraform 0.10 Core and Provider split, and now is offered as a separate library to allow easier dependency management in the Terraform ecosystem.

NOTE: This library is not currently designed or intended for usage outside the Terraform S3 Backend and the Terraform AWS Provider.

Requirements

Development

Testing this project can be done through Go standard library functionality or if Make is available:

$ go test -v ./...
# Optionally if Make is available; both run the same testing
$ make test

Code quality assurance uses golangci-lint:

$ golangci-lint run ./...
# Optionally if Make is available; both run the same linting
$ make lint

Release Process

  • Push a new vX.Y.Z tag to the repository
  • Close associated vX.Y.Z milestone
  • For Terraform AWS Provider: Renovate will automatically detect the update and submit a dependency pull request (usually within an hour)
  • For Terraform S3 Backend: Submit a new dependency pull request by running:
go get github.com/hashicorp/aws-sdk-go-base@vX.Y.Z
go mod tidy
go mod vendor

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAwsAccountIDAndPartition

func GetAwsAccountIDAndPartition(ctx context.Context, awsConfig aws.Config, skipCredsValidation, skipRequestingAccountId bool) (string, string, error)

func GetAwsConfig

func GetAwsConfig(ctx context.Context, c *Config) (aws.Config, error)

func IsCannotAssumeRoleError

func IsCannotAssumeRoleError(err error) bool

IsCannotAssumeRoleError returns true if the error contains the CannotAssumeRoleError type.

func IsNoValidCredentialSourcesError

func IsNoValidCredentialSourcesError(err error) bool

IsNoValidCredentialSourcesError returns true if the error contains the NoValidCredentialSourcesError type.

func ValidateRegion

func ValidateRegion(region string) error

ValidateRegion checks if the given region is a valid AWS region.

Types

type CannotAssumeRoleError

type CannotAssumeRoleError struct {
	Config *Config
	Err    error
}

CannotAssumeRoleError occurs when AssumeRole cannot complete.

func (CannotAssumeRoleError) Error

func (e CannotAssumeRoleError) Error() string

func (CannotAssumeRoleError) Unwrap

func (e CannotAssumeRoleError) Unwrap() error

type Config

type Config struct {
	AccessKey                   string
	AssumeRoleARN               string
	AssumeRoleDurationSeconds   int
	AssumeRoleExternalID        string
	AssumeRolePolicy            string
	AssumeRolePolicyARNs        []string
	AssumeRoleSessionName       string
	AssumeRoleTags              map[string]string
	AssumeRoleTransitiveTagKeys []string
	CallerDocumentationURL      string
	CallerName                  string
	DebugLogging                bool
	IamEndpoint                 string
	Insecure                    bool
	MaxRetries                  int
	Profile                     string
	Region                      string
	SecretKey                   string
	SharedCredentialsFiles      []string
	SharedConfigFiles           []string
	SkipCredsValidation         bool
	SkipMetadataApiCheck        bool
	StsEndpoint                 string
	Token                       string
	UserAgentProducts           []*UserAgentProduct
}

func (*Config) NewCannotAssumeRoleError

func (c *Config) NewCannotAssumeRoleError(err error) CannotAssumeRoleError

func (*Config) NewNoValidCredentialSourcesError

func (c *Config) NewNoValidCredentialSourcesError(err error) NoValidCredentialSourcesError

type InvalidRegionError

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

func (*InvalidRegionError) Error

func (e *InvalidRegionError) Error() string

type NoValidCredentialSourcesError

type NoValidCredentialSourcesError struct {
	Config *Config
	Err    error
}

NoValidCredentialSourcesError occurs when all credential lookup methods have been exhausted without results.

func (NoValidCredentialSourcesError) Error

func (NoValidCredentialSourcesError) Unwrap

type UserAgentProduct

type UserAgentProduct struct {
	Extra   []string
	Name    string
	Version string
}

Directories

Path Synopsis
awsv1shim module
internal

Jump to

Keyboard shortcuts

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