Documentation
¶
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 (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
Constants ¶
This section is empty.
Variables ¶
Functions ¶
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 ¶
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 ¶
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 ¶
S3urlToParts explodes an s3://bucket/path/file url into its parts
Types ¶
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 ¶
NewSession returns a Session or an error. If `ec2` is false, `Session.Me` will be false.
func (*Session) BucketToFile ¶
BucketToFile copies a file from an S3 bucket to a local file
func (*Session) BucketToWriter ¶
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 ¶
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 ¶
GetInstanceAZByIP returns an Availability Zone or an error
func (*Session) GetInstancesAZByIP ¶
GetInstancesAZByIP returns a map of IPs to Availability Zones or an error