Preparing your design workspace

Loading the problem and your latest saved attempt…

Design an Asynchronous Cloud Resource API

Design a cloud-provider API that lets Terraform create, inspect, update, and delete resources while polling for long-running operation results.

Problem statement

Design the cloud-provider side of resource provisioning for Terraform. The API must support creating, reading, updating, and deleting resources, and callers must be able to poll for an operation's status.

For this exercise, assume one resource type: a managed compute instance with a name and a capacity setting. Each authenticated caller acts within one project. Create, update, and delete may take up to five minutes after the API accepts them.

Reading a resource and polling an operation must distinguish accepted or running work from a confirmed success or failure. A successful delete leaves a readable operation result even though the instance is gone.

Also assume callers retry after losing a response, workers can restart, and the underlying compute service can time out after applying a change. One resource may have only one unresolved mutation at a time.

A retry of the same logical request must not create another instance or overwrite a later change, and one project must never read or change another project's resources or operations. Design admission, resource and operation state, execution, polling, and recovery.

Keep Terraform's plan engine, dependency graphs, billing, credential issuance, and multi-region failover outside this exercise.

What to build

  1. An authorized caller can create, inspect, update, and delete a compute instance within its project.
  2. A caller can poll a stable operation identifier and distinguish pending work, confirmed success, confirmed failure, and an unresolved dependency outcome.
  3. A repeated logical request reuses its prior result or operation, and conflicting mutations on one resource receive an explicit outcome.
  4. Accepted work and its status remain recoverable after a worker restart or a lost response from the underlying compute service.

At scale

  • For this exercise, assume 10,000 projects manage 100,000 instances, with peaks of 50 mutation requests and 2,000 resource or operation reads per second.
  • For this exercise, assume healthy admission and status reads complete within 300 milliseconds at p95, while compute changes can take up to five minutes.
  • For this exercise, assume acknowledged operation records survive a process restart; a dependency timeout alone is never proof that a change failed or never ran.