Core Services Basics
This page is a single tour across all ten core services, one minimal call at a time.
Busca en todas las páginas de la documentación
This page is a single tour across all ten core services, one minimal call at a time.
Each example is deliberately small: confirm who you are, then touch identity, storage, databases, messaging, compute, networking, and observability in turn.
The point is not depth - each service has its own "your first X" page for that. The point is to feel how the same SDK shape repeats everywhere.
pip install boto3 (boto3 1.43.x, Python 3.10+). TypeScript: install the per-service clients you use, for example npm install @aws-sdk/client-s3 @aws-sdk/client-sqs (Node.js 18+).aws configure, environment variables, or an IAM role. The SDK finds them automatically.AWS_REGION, or passed per client. These examples assume us-east-1.Before anything else, check which identity your SDK calls run as.
# --- Python (boto3) ---
import boto3
sts = boto3.client("sts")
me = sts.get_caller_identity()
print(me["Account"], me["Arn"])// --- TypeScript (AWS SDK v3) ---
import { STSClient, GetCallerIdentityCommand } from "@aws-sdk/client-sts";
const sts = new STSClient({});
const me = await sts.send(new GetCallerIdentityCommand({}));
console.log(me.Account, me.Arn);GetCallerIdentity needs no permissions, so it always works and is the fastest sanity check.Arn tells you whether you are a user, an assumed role, or a federated session.Related: AWS IAM via SDK: Users, Roles & Policies - the identity layer in depth.
Put an object into a bucket, then read it back.
# --- Python (boto3) ---
import boto3
s3 = boto3.client("s3")
s3.put_object(Bucket="my-bucket", Key="hello.txt", Body=b"hi")
body = s3.get_object(Bucket="my-bucket", Key="hello.txt")["Body"].read()
print(body.decode())// --- TypeScript (AWS SDK v3) ---
import { S3Client, PutObjectCommand, GetObjectCommand } from "@aws-sdk/client-s3";
const s3 = new S3Client({});
await s3.send(new PutObjectCommand({ Bucket: "my-bucket", Key: "hello.txt", Body: "hi" }));
const out = await s3.send(new GetObjectCommand({ Bucket: "my-bucket", Key: "hello.txt" }));
console.log(await out.Body.transformToString());.read(); in SDK v3 use transformToString().Related: Amazon S3 via SDK: Buckets & Objects.
Put an item and get it back using the document-style interface.
# --- Python (boto3) ---
import boto3
table = boto3.resource("dynamodb").Table("Visits")
table.put_item(Item={"id": "user-7", "count": 1})
item = table.get_item(Key={"id": "user-7"})["Item"]
print(item)// --- TypeScript (AWS SDK v3) ---
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, PutCommand, GetCommand } from "@aws-sdk/lib-dynamodb";
const doc = DynamoDBDocumentClient.from(new DynamoDBClient({}));
await doc.send(new PutCommand({ TableName: "Visits", Item: { id: "user-7", count: 1 } }));
const { Item } = await doc.send(new GetCommand({ TableName: "Visits", Key: { id: "user-7" } }));
console.log(Item);id here is the table's partition key; every item needs it.boto3.resource("dynamodb").Table(...); SDK v3 uses lib-dynamodb.Describe the relational databases in your account.
# --- Python (boto3) ---
import boto3
rds = boto3.client("rds")
for db in rds.describe_db_instances()["DBInstances"]:
print(db["DBInstanceIdentifier"], db["DBInstanceStatus"])// --- TypeScript (AWS SDK v3) ---
import { RDSClient, DescribeDBInstancesCommand } from "@aws-sdk/client-rds";
const rds = new RDSClient({});
const out = await rds.send(new DescribeDBInstancesCommand({}));
for (const db of out.DBInstances ?? []) console.log(db.DBInstanceIdentifier, db.DBInstanceStatus);DescribeDBInstances is read-only, so it is a safe way to see what exists.Send a message and receive it back.
# --- Python (boto3) ---
import boto3
sqs = boto3.client("sqs")
url = sqs.get_queue_url(QueueName="jobs")["QueueUrl"]
sqs.send_message(QueueUrl=url, MessageBody="job-1")
msgs = sqs.receive_message(QueueUrl=url, WaitTimeSeconds=5).get("Messages", [])
print([m["Body"] for m in msgs])// --- TypeScript (AWS SDK v3) ---
import { SQSClient, GetQueueUrlCommand, SendMessageCommand, ReceiveMessageCommand } from "@aws-sdk/client-sqs";
const sqs = new SQSClient({});
const { QueueUrl } = await sqs.send(new GetQueueUrlCommand({ QueueName: "jobs" }));
await sqs.send(new SendMessageCommand({ QueueUrl, MessageBody: "job-1" }));
const { Messages } = await sqs.send(new ReceiveMessageCommand({ QueueUrl, WaitTimeSeconds: 5 }));
console.log((Messages ?? []).map((m) => m.Body));WaitTimeSeconds enables long polling, which cuts empty responses and cost.jobs, or create one on the SQS page.Related: Amazon SQS via SDK: Your First Queue.
Publish a message to a topic that fans out to subscribers.
# --- Python (boto3) ---
import boto3
sns = boto3.client("sns")
arn = sns.create_topic(Name="alerts")["TopicArn"]
sns.publish(TopicArn=arn, Subject="Hello", Message="first event")
print("published to", arn)// --- TypeScript (AWS SDK v3) ---
import { SNSClient, CreateTopicCommand, PublishCommand } from "@aws-sdk/client-sns";
const sns = new SNSClient({});
const { TopicArn } = await sns.send(new CreateTopicCommand({ Name: "alerts" }));
await sns.send(new PublishCommand({ TopicArn, Subject: "Hello", Message: "first event" }));
console.log("published to", TopicArn);CreateTopic is idempotent - calling it for an existing name just returns the ARN.Related: Amazon SNS via SDK: Your First Topic.
Call an existing Lambda function and read its response.
# --- Python (boto3) ---
import boto3, json
lam = boto3.client("lambda")
resp = lam.invoke(FunctionName="hello", Payload=json.dumps({"name": "Ada"}))
print(resp["Payload"].read().decode())// --- TypeScript (AWS SDK v3) ---
import { LambdaClient, InvokeCommand } from "@aws-sdk/client-lambda";
const lam = new LambdaClient({});
const resp = await lam.send(new InvokeCommand({
FunctionName: "hello",
Payload: JSON.stringify({ name: "Ada" }),
}));
console.log(new TextDecoder().decode(resp.Payload));Invoke runs the function synchronously by default and returns its output payload.hello, or create one on the Lambda page.FunctionError field signals the function threw.Related: AWS Lambda via SDK: Your First Function.
List your instances and your VPCs - both live in the EC2 API surface.
# --- Python (boto3) ---
import boto3
ec2 = boto3.client("ec2")
for r in ec2.describe_instances()["Reservations"]:
for i in r["Instances"]:
print(i["InstanceId"], i["State"]["Name"])
for v in ec2.describe_vpcs()["Vpcs"]:
print(v["VpcId"], v["CidrBlock"])// --- TypeScript (AWS SDK v3) ---
import { EC2Client, DescribeInstancesCommand, DescribeVpcsCommand } from "@aws-sdk/client-ec2";
const ec2 = new EC2Client({});
const inst = await ec2.send(new DescribeInstancesCommand({}));
for (const r of inst.Reservations ?? [])
for (const i of r.Instances ?? []) console.log(i.InstanceId, i.State?.Name);
const vpcs = await ec2.send(new DescribeVpcsCommand({}));
for (const v of vpcs.Vpcs ?? []) console.log(v.VpcId, v.CidrBlock);ec2 client - networking lives under the EC2 API.DescribeInstances nests instances inside reservations, an easy shape to trip over.Related: Amazon EC2 via SDK: Your First Instance and Amazon VPC via SDK: Your First Network.
Emit a metric so you can graph and alarm on your own numbers.
# --- Python (boto3) ---
import boto3
cw = boto3.client("cloudwatch")
cw.put_metric_data(
Namespace="MyApp",
MetricData=[{"MetricName": "SignUps", "Value": 1, "Unit": "Count"}],
)
print("metric sent")// --- TypeScript (AWS SDK v3) ---
import { CloudWatchClient, PutMetricDataCommand } from "@aws-sdk/client-cloudwatch";
const cw = new CloudWatchClient({});
await cw.send(new PutMetricDataCommand({
Namespace: "MyApp",
MetricData: [{ MetricName: "SignUps", Value: 1, Unit: "Count" }],
}));
console.log("metric sent");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