December 2017
Intermediate to advanced
404 pages
9h 28m
English
The second concept is the idea of service clients. A service client is an object that provides API access to a specific AWS service such as S3 or SQS.
Service client objects are created from session objects. Here is an example of a piece of code that makes use of an S3 service client to obtain a list of buckets (an S3 bucket is simply a container of files and folders), then prints out the name of each bucket individually:
//Don't forget to import github.com/aws/aws-sdk-go/service/s3 sess, err := session.NewSession(&aws.Config{ Region: aws.String("us-west-1"), }) if err != nil { log.Fatal(err) } s3Svc := s3.New(sess) results, err := s3Svc.ListBuckets(nil) if err != nil { log.Fatal("Unable to get bucket list") } fmt.Println("Buckets:") ...Read now
Unlock full access