In v1 you were able to override the global endpoint and port for a service from the default config options. Example:
AWS.config(:s3_endpoint => "my.example.endpoint")
AWS.config(:s3_port => 316)
Is this possible in v2? Or do you have to do override it when you create the client for a particular service?
You can do this, the semantics are slightly different. The concept to keep in mind is that we will resolve configuration in roughly the following order:
Or, for a contrived code example:
client = Aws::S3::Client.new(region: "us-east-1")
client.config.endpoint # => #<URI::HTTPS https://s3.amazonaws.com>
Aws.config[:s3] = { endpoint: "https://bar.foo" }
Aws.config[:endpoint] = "https://foo.bar"
ec2 = Aws::EC2::Client.new(region: "us-east-1")
ec2.config.endpoint # => #<URI::HTTPS https://foo.bar>
s3 = Aws::S3::Client.new(region: "us-east-1")
s3.config.endpoint # => #<URI::HTTPS https://bar.foo>
s3_custom = Aws::S3::Client.new(region: "us-east-1", endpoint: "https://my.example.endpoint")
s3_custom.config.endpoint # => #<URI::HTTPS https://my.example.endpoint>
Most helpful comment
You can do this, the semantics are slightly different. The concept to keep in mind is that we will resolve configuration in roughly the following order:
Or, for a contrived code example: