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 1:1 to deployment profile fields in anycloud.yaml.

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:

  • gpuType / gpu — specify by GPU name (e.g., h100, a100:8). anycloud resolves this to the right instance type for your cloud provider. Use this when you care about the GPU, not the specific VM.
  • vmType / vm_type — specify the exact cloud instance type (e.g., g6e.xlarge, Standard_NC6s_v3). Use this 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 --region us-west-2

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, use per-bucket credential and region fields to tell anycloud how to access them. Input and output can be on different clouds:

cc = CloudConfig(
credentials="gcp-prod", # compute runs on GCP
input_storage_credentials="aws-prod", # input is on AWS
input_storage_region="us-east-1",
output_storage_credentials="azure-prod", # output is on Azure
output_storage_region="eastus",
)

The SDK can also wire this automatically when you pass Bucket objects from a different client — see Bucket Sync — Credentials for the full cross-cloud setup.