An instance template defines the configuration for an instance: which
image to boot and an optional cloud-init script. Templates are used by
deployments to create instances with a consistent configuration.
Templates are immutable. To change a configuration, create a new template and update your
deployment to reference it.
Create an instance template
sf instance-templates create \
--name prod-worker \
--image ubuntu-22.04.5-cuda-12.7 \
--cloud-init ./startup.sh
Cloud-init
Pass a startup script or cloud-config YAML file via --cloud-init. The file is stored with the
template and applied to every instance created from it. Maximum size is 64 KB.
#!/bin/bash
mkdir -p /root/.ssh
cat >>/root/.ssh/authorized_keys <<"EOF"
ssh-ed25519 AAAA... you@example.com
EOF
sf instance-templates create --name ssh-ready \
--image ubuntu-22.04.5-cuda-12.7 --cloud-init ./startup.sh
List templates
sf instance-templates list
NAME IMAGE CLOUD-INIT CREATED
prod-ubuntu ubuntu-22.04.5-cuda-12.7 yes Mar 23, 4:40pm
dev-debian debian-12-cuda-12.7 - Mar 26, 2:00pm
staging-base ubuntu-22.04.5-cuda-12.7 yes Mar 27, 2:00pm
Get template details
sf instance-templates get prod-ubuntu
│ ID ntmpl_Gw5rT8mKn2Pj4Lx9Qf7Y
│ NAME prod-ubuntu
│ IMAGE ubuntu-22.04.5-cuda-12.7 (image_TQiHEBzCA18ToAQqBtOr_)
│ CLOUD-INIT yes
└ CREATED Mar 23, 4:40pm UTC
Template IDs are prefixed ntmpl_ for backwards compatibility with the resource’s previous name
(node-template). The CLI, API, and SDK all refer to it as an instance template.
Delete a template
sf instance-templates delete prod-ubuntu
A template cannot be deleted while it is in use by a deployment or running
instance. Remove or update the referencing deployment first.
API reference
See the Instance Templates API
for programmatic access.