Regions, Endpoints & Client Construction
Before an AWS SDK can send a single request, it has to answer one question: where do I send it?
Busca en todas las páginas de la documentación
Before an AWS SDK can send a single request, it has to answer one question: where do I send it?
That answer is the endpoint - a concrete hostname like dynamodb.us-east-1.amazonaws.com. You almost never type it. Instead you give the SDK a service name and a region, and it does the rest during client construction.
This page explains how region drives endpoint resolution, what happens when you build a client, and why region is the one input you cannot skip.
A region is a named geographic cluster of data centers, such as us-east-1 or eu-west-1.
A client is an in-memory object that knows one service and one region. When you build an S3 client for us-east-1, that client will only ever talk to S3 in us-east-1.
Construction is a local, offline step. It reads configuration, sets up a credential provider, prepares a connection pool, and computes the endpoint. No packet leaves your machine until you call an operation.
That is why creating a client is cheap and why you should reuse it. Rebuilding one per request throws away pooled connections for no benefit.
# --- Python (boto3) ---
import boto3
# Bind service ("s3") to a region; no network call happens here.
s3 = boto3.client("s3", region_name="us-east-1")
print(s3.meta.region_name) # us-east-1
print(s3.meta.endpoint_url) # https://s3.us-east-1.amazonaws.com// --- TypeScript (AWS SDK v3) ---
import { S3Client } from "@aws-sdk/client-s3";
// Bind the S3 client to a region; construction does no network call.
const s3 = new S3Client({ region: "us-east-1" });
const endpoint = await s3.config.endpoint?.();
console.log(await s3.config.region()); // us-east-1
console.log(endpoint?.hostname); // s3.us-east-1.amazonaws.comThe region is not decoration. It is the value the resolver uses to pick a hostname.
Endpoint resolution runs inside the SDK, once, at or just after construction.
The SDK takes the service id and the region, maps the region to its partition (commercial aws, GovCloud aws-us-gov, or China aws-cn), and runs the per-service endpoints ruleset to produce a URL. For most services the result is {service}.{region}.amazonaws.com, but the ruleset handles the many exceptions.
Region itself is resolved from a chain. Both SDKs look, in order, at the explicit argument you passed, then environment variables (AWS_REGION, and for boto3 also AWS_DEFAULT_REGION), then the shared config file (~/.aws/config).
If none of those supply a region, both SDKs raise, and both failures are common.
# --- Python (boto3) ---
import boto3
# No region_name, no AWS_REGION, no config -> raises at first call:
# botocore.exceptions.NoRegionError: You must specify a region.
s3 = boto3.client("s3")
s3.list_buckets()// --- TypeScript (AWS SDK v3) ---
import { S3Client, ListBucketsCommand } from "@aws-sdk/client-s3";
// No region and none in the environment -> throws at send time:
// "Region is missing"
const s3 = new S3Client({});
await s3.send(new ListBucketsCommand({}));Two other inputs commonly ride along with region at construction time.
Credentials are resolved by their own chain (environment, shared config, IAM role) and are independent of region - a client can have a region but still fail later if no credentials resolve.
Config objects let you attach retries, timeouts, and endpoint variants. In boto3 this is botocore.config.Config; in SDK v3 these are top-level constructor fields.
The endpoint the SDK resolves is not always the plain service.region form.
Some services are global and ignore region for routing, even though the SDK still wants a region set. IAM and Route 53 are classic examples: requests go to a single global endpoint regardless of the region you configure.
S3 has its own historical quirks, including a legacy global endpoint and region-specific addressing styles. Modern SDKs default to regional endpoints, which is what you want for performance and correctness.
You can inspect the resolved endpoint, which is invaluable when debugging "why did my call go there?"
# --- Python (boto3) ---
import boto3
ddb = boto3.client("dynamodb", region_name="eu-west-1")
# meta exposes the resolved endpoint and region for inspection.
print(ddb.meta.endpoint_url) # https://dynamodb.eu-west-1.amazonaws.com
print(ddb.meta.region_name) # eu-west-1// --- TypeScript (AWS SDK v3) ---
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
const ddb = new DynamoDBClient({ region: "eu-west-1" });
const ep = await ddb.config.endpoint?.();
console.log(ep?.hostname); // dynamodb.eu-west-1.amazonaws.com
console.log(await ddb.config.region()); // eu-west-1Two levers override normal resolution, covered in depth on later pages.
A full endpoint override (boto3 endpoint_url, SDK v3 endpoint) replaces resolution entirely - the SDK sends exactly where you tell it, which is how you reach LocalStack or a VPC endpoint.
Variant flags (dual-stack, FIPS) ask the resolver for an alternate hostname while keeping resolution intact.
| Input | Set at construction | Effect |
|---|---|---|
| Region | region_name / region | Drives endpoint hostname and signing region |
| Credentials | credential chain, usually implicit | Who you are; independent of region |
| Config | Config(...) / constructor fields | Retries, timeouts, endpoint variants |
| Endpoint override | endpoint_url / endpoint | Bypasses resolution entirely |
The practical guidance is simple. Always pin the region explicitly, build each client once, reuse it, and let the SDK resolve the endpoint rather than hardcoding a hostname.
The hostname (and URL) the SDK sends a request to, like s3.us-east-1.amazonaws.com. The SDK computes it from the service, region, and partition.
Region determines both the endpoint hostname and the region used when signing the request. Without it the SDK cannot decide where to send the call.
No. Construction resolves configuration, credentials, and the endpoint locally. The first network call happens only when you invoke an operation.
From the environment (AWS_REGION, and for boto3 AWS_DEFAULT_REGION) or the shared config file. If none supply it, the SDK raises a missing-region error.
In boto3 read client.meta.endpoint_url. In SDK v3 call client.config.endpoint?.() and read the resolved hostname.
No. A client is bound to a single region. To work across regions, construct one client per region and route between them.
They route to a single global endpoint regardless of region, but the SDK still expects a region to be configured for signing and resolution.
Only for local testing against tools like LocalStack, or to target a specific VPC endpoint. In portable code, let the SDK resolve endpoints instead.
No, construction is cheap, but it does set up connection pools and config. Reuse a client across requests rather than rebuilding it each time.
Yes. The signing region is derived from the client region, so a request to a us-east-1 client is signed for us-east-1.
Stack versions: This page was written for boto3 1.43.x (Python 3.10+) and the AWS SDK for JavaScript v3 (Node.js 18+).
Revisado por Chris St. John·Última actualización: 23 jul 2026