Skip to main content

CloudConfig Internals

CloudConfig is the single object that configures where and how a job runs — cloud provider, credentials, VM type, region, storage, and spot settings. It's used in the Python SDK (@anycloud.function(), Client.submit()) and maps to the inline flags accepted by the CLI.

See CloudConfig Parameters for the full parameter table.

Credential Resolution

anycloud resolves credentials in this order:

  1. Explicit object — pass a credential object directly (e.g., AWSCredentials(...))
  2. By name — pass a string name (e.g., "azure2") to look up credentials saved in the local anycloud API database
  3. Auto-select — if only one credential set exists, it's used automatically
from anycloud.types import CloudConfig, AWSCredentials

# Explicit object — highest precedence
cc = CloudConfig(
credentials=AWSCredentials(accessKeyId="AKIA...", secretAccessKey="..."),
)

# By name — resolved from saved credentials
cc = CloudConfig(credentials="azure2")

# Auto-select — omit credentials entirely when you have only one set
cc = CloudConfig(vm_type="t3.medium")

When using Client(cloud_config=cc), the client-level config applies to all submits unless overridden per-submit.

GPU Type vs VM Type

There are two ways to specify what hardware your job runs on:

  • gpu (CLI --gpu-type) — specify by GPU name (e.g., h100, a100:8); anycloud resolves it to the right instance type for your cloud. It's a submit-level argument — submit(gpu=…) / @anycloud.function(gpu=…) — not a CloudConfig field. Use it when you care about the GPU, not the specific VM.
  • vm_type (CLI --vm-type) — the exact cloud instance type (e.g., g6e.xlarge, Standard_NC6s_v3), a CloudConfig field. Use it when you need a specific instance or a CPU-only VM.

They are mutually exclusive — set one or the other, not both.

# GPU type — anycloud picks the best instance
cc = CloudConfig(credentials="my-aws", spot=True)
job = ac.submit("train:latest", cloud_config=cc, gpu="h100:8")

# VM type — you pick the exact instance
cc = CloudConfig(credentials="my-aws", vm_type="t3.medium", region="us-west-2")
job = ac.submit("app:latest", cloud_config=cc)

CLI equivalents:

# By GPU type
anycloud submit my-training:latest --credentials my-aws --gpu-type h100 --spot --gpus all

# By VM type
anycloud submit my-app:latest --credentials my-aws --vm-type t3.medium

Config Variants with replace()

CloudConfig.replace() creates a new config with selected fields changed, without repeating shared fields:

base = CloudConfig(
credentials="azure2",
vm_type="Standard_NC16as_T4_v3",
spot=True,
disk_size_gb=400,
input_bucket="eval-data",
output_bucket="eval-results",
)

# Same config but different region
west = base.replace(region="westus2")

# Same config but on-demand instead of spot
on_demand = base.replace(spot=False)

# Different cloud entirely
gcp = base.replace(credentials="gcp-prod", vm_type="n1-standard-8")

This is useful when you need to fan out the same job across regions or clouds, or when you want spot with an on-demand fallback.

Submission.replace() works the same way for fan-out with a shared base — see the Python SDK reference.

Cross-Cloud Storage

When your storage buckets are on a different cloud than compute, each bucket carries its own credentials and region (input_storage_credentials / input_storage_region, plus the output and checkpoint equivalents). The SDK fills these in for you when you pass a Bucket sourced from a different Client — input and output can even be on different clouds:

compute = anycloud.Client(credentials="gcp-prod")  # compute runs on GCP
aws = anycloud.Client(credentials="aws-prod") # input lives on AWS S3
azure = anycloud.Client(credentials="azure-prod") # output lives on Azure

job = compute.submit(
"train:latest",
input=aws.bucket("training-data"),
output=azure.bucket("results"),
)

See Bucket Sync — Credentials for the full cross-cloud setup, including the CLI flags.