# README
aws
import "github.com/cognusion/go-jar/aws"
Overview
Index
- Variables
- func GetAwsRegion() (region string)
- func GetAwsRegionE() (region string, err error)
- func InitAWS(awsRegion, awsAccessKey, awsSecretKey string) (*session.Session, error)
- func S3urlToParts(url string) (bucket, filePath, filename string)
- type Session
- func NewSession(awsRegion, awsAccessKey, awsSecretKey string, ec2 bool) (*Session, error)
- func (s *Session) BucketToFile(bucket, bucketPath, filename string) (size int64, err error)
- func (s *Session) BucketToWriter(bucket, bucketPath string, out io.Writer) (size int64, err error)
- func (s *Session) BucketToWriterWithContext(ctx context.Context, bucket, bucketPath string, out io.Writer) (size int64, err error)
- func (s *Session) BucketUpload(bucket, bucketPath string, file io.Reader) error
- func (s *Session) BucketUploadWithContext(ctx context.Context, bucket, bucketPath string, file io.Reader) error
- func (s *Session) GetInstanceAZByIP(ip string) (string, error)
- func (s *Session) GetInstancesAZByIP(ips []*string) (*map[string]string, error)
- func (s *Session) S3Client() *s3.S3
Package files
Variables
var (
// DebugOut is a log.Logger for debug messages
DebugOut = log.New(io.Discard, "", 0)
// TimingOut is a log.Logger for timing-related debug messages. DEPRECATED
TimingOut = log.New(io.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, ec2 bool) (*Session, error)
NewSession returns a Session or an error. If ec2
is false, Session.Me
will be false.
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) BucketToWriter
func (s *Session) BucketToWriter(bucket, bucketPath string, out io.Writer) (size int64, err error)
BucketToWriter copies a file from an S3 bucket to a Writer
func (*Session) BucketToWriterWithContext
func (s *Session) BucketToWriterWithContext(ctx context.Context, bucket, bucketPath string, out io.Writer) (size int64, err error)
BucketToWriterWithContext copies a file from an S3 bucket to a Writer
func (*Session) BucketUpload
func (s *Session) BucketUpload(bucket, bucketPath string, file io.Reader) error
BucketUpload uploads the file to the bucket/bucketPath
func (*Session) BucketUploadWithContext
func (s *Session) BucketUploadWithContext(ctx context.Context, bucket, bucketPath string, file io.Reader) error
BucketUploadWithContext uploads the file to the bucket/bucketPath, with the specified context
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
func (*Session) S3Client
func (s *Session) S3Client() *s3.S3
S3Client returns a raw S3 client from the current session
Generated by godoc2md