github.com/aavshr/aws-sdk-go@v1.41.3/aws/endpoints/doc.go (about)

     1  // Package endpoints provides the types and functionality for defining regions
     2  // and endpoints, as well as querying those definitions.
     3  //
     4  // The SDK's Regions and Endpoints metadata is code generated into the endpoints
     5  // package, and is accessible via the DefaultResolver function. This function
     6  // returns a endpoint Resolver will search the metadata and build an associated
     7  // endpoint if one is found. The default resolver will search all partitions
     8  // known by the SDK. e.g AWS Standard (aws), AWS China (aws-cn), and
     9  // AWS GovCloud (US) (aws-us-gov).
    10  // .
    11  //
    12  // Enumerating Regions and Endpoint Metadata
    13  //
    14  // Casting the Resolver returned by DefaultResolver to a EnumPartitions interface
    15  // will allow you to get access to the list of underlying Partitions with the
    16  // Partitions method. This is helpful if you want to limit the SDK's endpoint
    17  // resolving to a single partition, or enumerate regions, services, and endpoints
    18  // in the partition.
    19  //
    20  //     resolver := endpoints.DefaultResolver()
    21  //     partitions := resolver.(endpoints.EnumPartitions).Partitions()
    22  //
    23  //     for _, p := range partitions {
    24  //         fmt.Println("Regions for", p.ID())
    25  //         for id, _ := range p.Regions() {
    26  //             fmt.Println("*", id)
    27  //         }
    28  //
    29  //         fmt.Println("Services for", p.ID())
    30  //         for id, _ := range p.Services() {
    31  //             fmt.Println("*", id)
    32  //         }
    33  //     }
    34  //
    35  // Using Custom Endpoints
    36  //
    37  // The endpoints package also gives you the ability to use your own logic how
    38  // endpoints are resolved. This is a great way to define a custom endpoint
    39  // for select services, without passing that logic down through your code.
    40  //
    41  // If a type implements the Resolver interface it can be used to resolve
    42  // endpoints. To use this with the SDK's Session and Config set the value
    43  // of the type to the EndpointsResolver field of aws.Config when initializing
    44  // the session, or service client.
    45  //
    46  // In addition the ResolverFunc is a wrapper for a func matching the signature
    47  // of Resolver.EndpointFor, converting it to a type that satisfies the
    48  // Resolver interface.
    49  //
    50  //
    51  //     myCustomResolver := func(service, region string, optFns ...func(*endpoints.Options)) (endpoints.ResolvedEndpoint, error) {
    52  //         if service == endpoints.S3ServiceID {
    53  //             return endpoints.ResolvedEndpoint{
    54  //                 URL:           "s3.custom.endpoint.com",
    55  //                 SigningRegion: "custom-signing-region",
    56  //             }, nil
    57  //         }
    58  //
    59  //         return endpoints.DefaultResolver().EndpointFor(service, region, optFns...)
    60  //     }
    61  //
    62  //     sess := session.Must(session.NewSession(&aws.Config{
    63  //         Region:           aws.String("us-west-2"),
    64  //         EndpointResolver: endpoints.ResolverFunc(myCustomResolver),
    65  //     }))
    66  package endpoints