PeaBox Lab › PeaLang › Learn › Chapter 17 › Lesson 5

Part III — Advanced Systems · Chapter 17 · Lesson 5 of 7 · 5 min read

Lesson 5: Object Storage Across S3, Azure, and Google Cloud

Lesson level: Advanced

Purpose: Read and write cloud objects through a shared contract while respecting provider-specific identity, consistency, metadata, and cost behavior.

Release note. The project materials describe adapters for S3, Azure Blob Storage, ADLS Gen2, and Google Cloud Storage with a shared API and DataFrame ingestion. Treat exact signatures as illustrative, and validate each provider in an approved non-production account before operational use.

Learning objectives

By the end of this lesson, you will be able to:

5.1 Objects are not local files

An object store organizes data as named objects inside containers or buckets. Names may look like paths, but many object stores do not provide the same directory, locking, rename, or append semantics as a local filesystem. ADLS Gen2 adds hierarchical namespace features, which further changes path behavior.

Write code against the shared contract only for operations whose semantics truly match across providers. For provider-specific behavior—such as conditional writes, hierarchical rename, object versioning, retention, or access tiers—use an explicit capability and document the difference.

Shared contract fields: provider, account or project, bucket or container, approved prefix, credential reference, region, operation set, object-size limits, content types, checksum policy, encryption expectations, retry policy, and cleanup rules.

5.2 Prefixes, names, and listing

Use an approved prefix for each workflow, such as orders/inbound/. Validate object names derived from data. Reject traversal-like segments where the adapter normalizes names, control characters, unexpected encodings, and names outside the approved prefix.

Listing can be paginated and may not return objects in the order a workflow expects. Sort explicitly when deterministic processing order matters. Stop at configured object and byte limits. Do not infer that a dataset is complete merely because listing ended unless a manifest or completion signal confirms it.

Illustrative manifest pattern. A producer writes data objects, then writes a manifest containing object names, sizes, checksums, schema version, and record counts. The consumer processes only datasets with a valid manifest and verifies each listed object.

Common mistakes. Treating a prefix as an access-control boundary without matching permissions; reading partially written datasets; using object names as trusted local paths; and assuming listing order is chronological.

5.3 Reading and writing objects safely

Bound every read. Check object size before download when metadata is available, then enforce limits during the transfer. Validate content type and checksum when the producer contract provides them. Do not trust file extensions alone.

For DataFrame ingestion, reuse the interchange discipline from Chapter 16: declare the format, encoding, schema version, null policy, and rejection rules. A cloud object is still an untrusted input boundary.

For writes, prefer immutable outputs with unique names, such as a run identifier in the object name. Write the data object first, verify it, then publish a manifest or completion marker. Overwrite only when the workflow explicitly requires it and the provider capability supports the needed conditional protection.

Large transfers may use multipart or chunked uploads. Treat chunk failures, abandoned uploads, and cleanup as part of the contract. Verify the final object rather than assuming that every chunk call implies a complete object.

Illustrative output workflow. Write orders_summary_RUNID.jsonl to the approved output prefix; verify its size and checksum; write a manifest with schema version and record count; mark the run complete; never overwrite earlier run outputs.

5.4 Identity, encryption, and cost

Use workload or managed identities where the hosting platform supports them. If a key or token is required, obtain it from an approved secret provider. Grant permissions to the minimum account, container, bucket, and prefix needed.

Encryption may be provided by the service, by customer-managed keys, or by application-level encryption. The connector should not claim a specific encryption posture unless configuration and evidence confirm it.

Object operations incur cost: requests, storage, retrieval, egress, and sometimes tier changes. Large list operations, repeated downloads, and unbounded retries can become expensive. Include cost-related limits in production design and monitor them.

Guided practice. Write a least-privilege access request for a workflow that reads from orders/inbound/ and writes to orders/curated/. Exclude delete authority unless the cleanup design requires it.

Review prompt. Why is a manifest stronger evidence of dataset completeness than a successful list operation?

5.5 Hands-on lab: Provider-neutral object ingestion

Scenario. Build a provider-neutral ingestion workflow using a local fake object store or test doubles. Then map the same contract to S3, Azure Blob Storage, ADLS Gen2, and Google Cloud Storage without executing live calls unless an approved test account exists.

Required failure cases. Missing manifest; manifest referencing a missing object; checksum mismatch; object outside the approved prefix; oversized object; unsupported content type; paginated listing with a repeated continuation token; and transient read failure followed by success.

Acceptance criteria. Incomplete datasets are not ingested; unsafe names are rejected; limits are enforced; output objects are immutable; credentials are absent; and every provider-specific claim is backed by documentation or approved live evidence.

Review questions. Why are object prefixes not equivalent to folders? Why should outputs be immutable? Which object operations create cost? What does a manifest prove? Why should provider-specific capabilities remain explicit?

Applied challenge. Design a retention and cleanup policy for abandoned multipart uploads, rejected input objects, and superseded outputs. Include legal-hold or retention constraints as configurable external requirements rather than assumptions.

Lesson summary. Cloud object storage requires bounded traversal, safe naming, manifest-based completeness, checksum validation, immutable publication, least-privilege identity, and provider-specific evidence.

Common mistakes

Review questions

Applied challenge

Write a job that archives daily CSV exports to object storage under date-based prefixes, lists the last seven days, and verifies each object's checksum. Run it against a local fake provider, and document the identity and encryption settings that S3, Azure, and Google Cloud would each need.

Lesson summary

Object storage is a flat, remote, eventually consistent store, not a local disk. Use provider-neutral code, page through listings, prefer identity-based short-lived credentials, protect important objects with versioning or conditional writes, and test against fakes.

Lesson status: Ready for review.

← Previous Next →