Documentation ¶
Overview ¶
Package endpoints provides the types and functionality for defining regions and endpoints, as well as querying those definitions.
The SDK's Regions and Endpoints metadata is code generated into the endpoints package, and is accessible via the DefaultResolver function. This function returns a endpoint Resolver will search the metadata and build an associated endpoint if one is found. The default resolver will search all partitions known by the SDK. e.g AWS Standard (aws), AWS China (aws-cn), and AWS GovCloud (US) (aws-us-gov).
Using Custom Endpoints ¶
The endpoints package also gives you the ability to use your own logic how endpoints are resolved. This is a great way to define a custom endpoint for select services, without passing that logic down through your code.
If a type implements the Resolver interface it can be used to resolve endpoints. To use this with the SDK's Session and Config set the value of the type to the EndpointsResolver field of aws.Config when initializing the service client.
In addition the ResolverFunc is a wrapper for a func matching the signature of Resolver.ResolveEndpoint, converting it to a type that satisfies the Resolver interface.
defaultResolver := endpoints.NewDefaultResolver() myCustomResolver := func(service, region string) (aws.Endpoint, error) { if service == endpoints.S3ServiceID { return aws.Endpoint{ URL: "s3.custom.endpoint.com", SigningRegion: "custom-signing-region", }, nil } return defaultResolver.ResolveEndpoint(service, region) } cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic(err) } cfg.Region = "us-west-2" cfg.EndpointResolver = aws.EndpointResolverFunc(myCustomResolver)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ResolveOptions ¶
type ResolveOptions struct { // DisableSSL forces the endpoint to be resolved as HTTP. // instead of HTTPS if the service supports it. DisableSSL bool // Sets the resolver to resolve the endpoint as a dualstack endpoint // for the service. If dualstack support for a service is not known and // StrictMatching is not enabled a dualstack endpoint for the service will // be returned. This endpoint may not be valid. If StrictMatching is // enabled only services that are known to support dualstack will return // dualstack endpoints. UseDualStack bool // Enables strict matching of services and regions resolved endpoints. // If the partition doesn't enumerate the exact service and region an // error will be returned. This option will prevent returning endpoints // that look valid, but may not resolve to any real endpoint. StrictMatching bool }
ResolveOptions provide the configuration needed to direct how the endpoints will be resolved.
type Resolver ¶
type Resolver struct { ResolveOptions // contains filtered or unexported fields }
A Resolver provides endpoint resolution based on modeled endpoint data.
func NewDefaultResolver ¶
func NewDefaultResolver() *Resolver
NewDefaultResolver returns an Endpoint resolver that will be able to resolve endpoints for: AWS Standard, AWS China, AWS GovCloud (US), AWS ISO (US), and AWS ISOB (US).
func (*Resolver) ResolveEndpoint ¶
ResolveEndpoint attempts to resolve an endpoint againsted the modeled endpoint data. If an endpoint is found it will be returned. An error will be returned otherwise.
Searches through the partitions in the order they are defined.
type UnknownEndpointError ¶
A UnknownEndpointError is returned when in StrictMatching mode and the service is valid, but the region does not resolve to an endpoint. Includes a list of all known endpoints for the service.
func NewUnknownEndpointError ¶
func NewUnknownEndpointError(p, s, r string, known []string) UnknownEndpointError
NewUnknownEndpointError builds and returns UnknownEndpointError.
func (UnknownEndpointError) Error ¶
func (e UnknownEndpointError) Error() string
String returns the string representation of the error.
type UnknownServiceError ¶
A UnknownServiceError is returned when the service does not resolve to an endpoint. Includes a list of all known services for the partition. Returned when a partition does not support the service.
func NewUnknownServiceError ¶
func NewUnknownServiceError(p, s string, known []string) UnknownServiceError
NewUnknownServiceError builds and returns UnknownServiceError.
func (UnknownServiceError) Error ¶
func (e UnknownServiceError) Error() string
String returns the string representation of the error.