Categorygithub.com/cognusion/awslib/v2
package
2.2.1
Repository: https://github.com/cognusion/awslib.git
Documentation: pkg.go.dev

# README

aws

import "github.com/cognusion/awslib/v2"

Overview

Index

Package files

aws.go

Variables

var (
    // DebugOut is a log.Logger for debug messages
    DebugOut = log.New(ioutil.Discard, "", 0)
    // TimingOut is a log.Logger for timing-related debug messages. DEPRECATED
    TimingOut = log.New(ioutil.Discard, "[TIMING] ", 0)
)

func GetAwsRegion

func GetAwsRegion() (region string)

GetAwsRegion returns the region as a string, first consulting the well-known environment variables, then falling back EC2 metadata calls

func GetAwsRegionE

func GetAwsRegionE() (region string, err error)

GetAwsRegionE returns the region as a string and and error, first consulting the well-known environment variables, then falling back EC2 metadata calls

func InitAWS

func InitAWS(awsRegion, awsAccessKey, awsSecretKey string) (*session.Session, error)

InitAWS optionally takes a region, accesskey and secret key, setting AWSSession to the resulting session. If values aren't provided, the well-known environment variables (WKE) are consulted. If they're not available, and running in an EC2 instance, then it will use the local IAM role

func S3urlToParts

func S3urlToParts(url string) (bucket, filePath, filename string)

S3urlToParts explodes an s3://bucket/path/file url into its parts

type Session

type Session struct {
    // AWS is the raw, hopefully initialized AWS Session
    AWS *session.Session
    Me  *ec2metadata.EC2InstanceIdentityDocument
}

Session is a container around an AWS Session, to make AWS operations easier

func NewSession

func NewSession(awsRegion, awsAccessKey, awsSecretKey string) (*Session, error)

NewSession returns a Session or an error

func (*Session) BucketToFile

func (s *Session) BucketToFile(bucket, bucketPath, filename string) (size int64, err error)

BucketToFile copies a file from an S3 bucket to a local file

func (*Session) GetInstanceAZByIP

func (s *Session) GetInstanceAZByIP(ip string) (string, error)

GetInstanceAZByIP returns an Availability Zone or an error

func (*Session) GetInstancesAZByIP

func (s *Session) GetInstancesAZByIP(ips []*string) (*map[string]string, error)

GetInstancesAZByIP returns a map of IPs to Availability Zones or an error


Generated by godoc2md