aws

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: Apache-2.0 Imports: 10 Imported by: 2

README

component-aws - Settings component for AWS clients

GoDoc

Overview

This is a settings component that enables constructing AWS credentials/sessions and some of the clients we regularly use when building services.

Quick Start

package main

import (
    "context"
    "net/http"

    aws "github.com/asecurityteam/component-aws"
    "github.com/aws/aws-sdk-go/service/dynamodb"
    "github.com/asecurityteam/settings"
)

func main() {
    ctx := context.Background()
    envSource := settings.NewEnvSource(os.Environ())

    sess, _ := aws.NewSession(ctx, envSource)
    d := dynamodb.New(sess)
    // or
    db, _ := aws.NewDynamoDB(ctx, envSource)
    // or
    s3 := aws.NewS3(ctx, envSource)
}

Status

This project is in incubation which means we are not yet operating this tool in production and the interfaces are subject to change.

Contributing

Building And Testing

We publish a docker image called SDCLI that bundles all of our build dependencies. It is used by the included Makefile to help make building and testing a bit easier. The following actions are available through the Makefile:

  • make dep

    Install the project dependencies into a vendor directory

  • make lint

    Run our static analysis suite

  • make test

    Run unit tests and generate a coverage artifact

  • make integration

    Run integration tests and generate a coverage artifact

  • make coverage

    Report the combined coverage for unit and integration tests

License

This project is licensed under Apache 2.0. See LICENSE.txt for details.

Contributing Agreement

Atlassian requires signing a contributor's agreement before we can accept a patch. If you are an individual you can fill out the individual CLA. If you are contributing on behalf of your company then please fill out the corporate CLA.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadDynamoDB

func LoadDynamoDB(ctx context.Context, source settings.Source, c *DynamoDBComponent) (*dynamodb.DynamoDB, error)

LoadDynamoDB is a convenience method for binding the source to the component.

func LoadS3

func LoadS3(ctx context.Context, source settings.Source, c *S3Component) (*s3.S3, error)

LoadS3 is a convenience method for binding the source to the component.

func LoadSession

func LoadSession(ctx context.Context, source settings.Source, c *SessionComponent) (*session.Session, error)

LoadSession is a convenience method for binding the source to the component.

func NewDynamoDB

func NewDynamoDB(ctx context.Context, source settings.Source) (*dynamodb.DynamoDB, error)

NewDynamoDB is the top-level entry point for creating a DynamoDB client.

func NewS3

func NewS3(ctx context.Context, source settings.Source) (*s3.S3, error)

NewS3 is the top-level entry point for creating an S3 client.

func NewSession

func NewSession(ctx context.Context, source settings.Source) (*session.Session, error)

NewSession is the top-level entry point for creating an AWS auth session.

Types

type AssumeRoleCredentialConfig

type AssumeRoleCredentialConfig struct {
	Role       string `description:"The ARN of the role to assume."`
	ExternalID string `description:"External ID to use if using a cross-acount role."`
}

AssumeRoleCredentialConfig contains settings for assuming a role.

func (*AssumeRoleCredentialConfig) Name

Name of the configuration root.

type DynamoDBComponent

type DynamoDBComponent struct {
	Session *SessionComponent
}

DynamoDBComponent is used to create a new DynamoDB client.

func NewDynamoDBComponent

func NewDynamoDBComponent() *DynamoDBComponent

NewDynamoDBComponent generates a default component.

func (*DynamoDBComponent) New

New constructs a DynamoDB client.

func (*DynamoDBComponent) Settings

func (c *DynamoDBComponent) Settings() *DynamoDBConfig

Settings generates the default settings for the component.

type DynamoDBConfig

type DynamoDBConfig struct {
	Session *SessionConfig
}

DynamoDBConfig contains the settings for a DynamoDB client.

func (*DynamoDBConfig) Name

func (*DynamoDBConfig) Name() string

Name of the configuration root.

type S3Component

type S3Component struct {
	Session *SessionComponent
}

S3Component is used to create a new S3 client.

func NewS3Component

func NewS3Component() *S3Component

NewS3Component generates a default component.

func (*S3Component) New

func (c *S3Component) New(ctx context.Context, conf *S3Config) (*s3.S3, error)

New constructs a S3 client.

func (*S3Component) Settings

func (c *S3Component) Settings() *S3Config

Settings generates the default settings for the component.

type S3Config

type S3Config struct {
	Session *SessionConfig
}

S3Config contains the settings for a S3 client.

func (*S3Config) Name

func (*S3Config) Name() string

Name of the configuration root.

type SessionComponent

type SessionComponent struct{}

SessionComponent implements the Component interface and produces an AWS session object.

func NewSessionComponent

func NewSessionComponent() *SessionComponent

NewSessionComponent constructs a default SessionComponent.

func (*SessionComponent) New

New generates a session for use with any AWS client.

func (*SessionComponent) Settings

func (*SessionComponent) Settings() *SessionConfig

Settings generates the default configuration.

type SessionConfig

type SessionConfig struct {
	Region                     string `description:"The AWS region in which to authenticate."`
	Endpoint                   string `description:"Override the default AWS URL."`
	SharedCredentialConfig     *SharedCredentialConfig
	StaticCredentialConfig     *StaticCredentialConfig
	AssumeRoleCredentialConfig *AssumeRoleCredentialConfig
}

SessionConfig contains settings for establishing an authenticated AWS session.

func (*SessionConfig) Name

func (*SessionConfig) Name() string

Name of the configuration root.

type SharedCredentialConfig

type SharedCredentialConfig struct {
	File    string `description:"The location of the shared profile configuration file. Leave blank for the default AWS location."`
	Profile string `description:"Name of the profile to use from the file."`
}

SharedCredentialConfig contains settings for using the AWS shared profile configuration file to authenticate.

func (*SharedCredentialConfig) Name

Name of the configuration root.

type StaticCredentialConfig

type StaticCredentialConfig struct {
	ID     string `description:"The access key ID."`
	Secret string `descriptin:"The secret key."`
	Token  string `description:"Optional access token."`
}

StaticCredentialConfig contains settings for using a fixed set of credentials to authenticate.

func (*StaticCredentialConfig) Name

Name of the configuration root.

Jump to

Keyboard shortcuts

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