Overview ▹

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).
.

Enumerating Regions and Endpoint Metadata

Casting the Resolver returned by DefaultResolver to a EnumPartitions interface
will allow you to get access to the list of underlying Partitions with the
Partitions method. This is helpful if you want to limit the SDK's endpoint
resolving to a single partition, or enumerate regions, services, and endpoints
in the partition.

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 session, or service client.

In addition the ResolverFunc is a wrapper for a func matching the signature
of Resolver.EndpointFor, converting it to a type that satisfies the
Resolver interface.

Examples

Package files

Internal call graph ▹

Internal call graph ▾

In the call graph viewer below, each node
is a function belonging to this package
and its children are the functions it
calls—perhaps dynamically.

The root nodes are the entry points of the
package: functions that may be called from
outside the package.
There may be non-exported or anonymous
functions among them if they are called
dynamically from another package.

Click a node to visit that function's source code.
From there you can visit its callers by
clicking its declaring func
token.

Functions may be omitted if they were
determined to be unreachable in the
particular programs or tests that were
analyzed.

type Options 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
// Enables resolving a service endpoint based on the region provided if the// service does not exist. The service endpoint ID will be used as the service// domain name prefix. By default the endpoint resolver requires the service// to be known when resolving endpoints.//// If resolving an endpoint on the partition list the provided region will// be used to determine which partition's domain name pattern to the service// endpoint ID with. If both the service and region are unknown and resolving// the endpoint on partition list an UnknownEndpointError error will be returned.//// If resolving and endpoint on a partition specific resolver that partition's// domain name pattern will be used with the service endpoint ID. If both// region and service do not exist when resolving an endpoint on a specific// partition the partition's domain pattern will be used to combine the// endpoint and region together.//// This option is ignored if StrictMatching is enabled.
ResolveUnknownService bool
}

Options provide the configuration needed to direct how the
endpoints will be resolved.

PartitionForRegion returns the first partition which includes the region
passed in. This includes both known regions and regions which match
a pattern supported by the partition which may include regions that are
not explicitly known by the partition. Use the Regions method of the
returned Partition if explicit support is needed.

EndpointFor attempts to resolve the endpoint based on service and region.
See Options for information on configuring how the endpoint is resolved.

If the service cannot be found in the metadata the UnknownServiceError
error will be returned. This validation will occur regardless if
StrictMatching is enabled. To enable resolving unknown services set the
"ResolveUnknownService" option to true. When StrictMatching is disabled
this option allows the partition resolver to resolve a endpoint based on
the service endpoint ID provided.

When resolving endpoints you can choose to enable StrictMatching. This will
require the provided service and region to be known by the partition.
If the endpoint cannot be strictly resolved an error will be returned. This
mode is useful to ensure the endpoint resolved is valid. Without
StrictMatching enabled the endpoint returned my look valid but may not work.
StrictMatching requires the SDK to be updated if you want to take advantage
of new regions and services expansions.

type ResolvedEndpoint struct {
// The endpoint URL
URL string
// The region that should be used for signing requests.
SigningRegion string
// The service name that should be used for signing requests.
SigningName string
// States that the signing name for this endpoint was derived from metadata// passed in, but was not explicitly modeled.
SigningNameDerived bool
// The signing method that should be used for signing requests.
SigningMethod string
}

A ResolvedEndpoint is an endpoint that has been resolved based on a partition
service, and region.

DecodeModel unmarshals a Regions and Endpoint model definition file into
a endpoint Resolver. If the file format is not supported, or an error occurs
when unmarshaling the model an error will be returned.

Casting the return value of this func to a EnumPartitions will
allow you to get a list of the partitions in the order the endpoints
will be resolved in.

ResolverFunc is a helper utility that wraps a function so it satisfies the
Resolver interface. This is useful when you want to add additional endpoint
resolving logic, or stub out specific endpoints with custom values.