New creates a new instance of the handlers merging in the provided Configs
on top of the SDK's default configurations. Once the session is created it
can be mutated to modify Configs or Handlers. The session is safe to be read
concurrently, but it should not be written to concurrently.
Example:
// Create a session with the default config and request handlers.
sess := session.New()
// Create a session with a custom region
sess := session.New(&aws.Config{Region: aws.String("us-east-1")})
// Create a session, and add additional handlers for all service
// clients created with the session to inherit. Adds logging handler.
sess := session.New()
sess.Handlers.Send.PushFront(func(r *request.Request) {
// Log every request made and its payload
logger.Println("Request: %s/%s, Payload: %s", r.ClientInfo.ServiceName, r.Operation, r.Params)
})
// Create a S3 client instance from a session
sess := session.New()
svc := s3.New(sess)
ClientConfig satisfies the client.ConfigProvider interface and is used to
configure the service client instances. Passing the Session to the service
client's constructor (New) will use this method to configure the client.
Copy creates and returns a copy of the current session, coping the config
and handlers. If any additional configs are provided they will be merged
on top of the session's copied config.
Example:
// Create a copy of the current session, configured for the us-west-2 region.
sess.Copy(&aws.Config{Region: aws.String("us-west-2"})