diff --git a/api-reference/endpoint/create-compute.mdx b/api-reference/endpoint/create-compute.mdx index cabfbb6..06b9633 100644 --- a/api-reference/endpoint/create-compute.mdx +++ b/api-reference/endpoint/create-compute.mdx @@ -40,6 +40,37 @@ Use these slugs for the `region`, `image`, and `specification` fields in your re --- +### User Data + +Pass your own [cloud-init](https://cloudinit.readthedocs.io/) configuration in `userData` to set up the instance on its first boot: install packages, write files, create users or run a script. Send a `#cloud-config` file or a shell script starting with `#!`. It works with every image. + +- Encode it as standard base64, on one line. +- It can be at most 32 KiB after decoding. +- It's optional. Leave it out and the instance is created as usual. + +```bash +USER_DATA=$(printf '#cloud-config\npackages:\n - nginx\n' | base64 | tr -d '\n') + +curl -X POST https://api.strettch.cloud/api/v1/computes \ + -H "Authorization: Bearer $STRETTCH_API_KEY" \ + -H "Content-Type: application/json" \ + -H "Idempotency-Key: $(uuidgen)" \ + -d '{ + "hostName": "web-01", + "image": "UBUNTU-24.04", + "region": "KGL-1", + "specification": "S-1C-1G", + "publicKeys": ["ssh-ed25519 AAAA... you@laptop"], + "userData": "'"$USER_DATA"'" + }' +``` + + + The instance receives the data exactly as you sent it. Where your cloud-config and Strettch Cloud's defaults set the same key, your value wins. + + +--- + ### Response Error Codes If the request fails, the `code` field in the error response will contain one of the following. diff --git a/api-reference/openapi.json b/api-reference/openapi.json index 04c2923..4f2851e 100644 --- a/api-reference/openapi.json +++ b/api-reference/openapi.json @@ -1047,6 +1047,12 @@ "web" ] }, + "userData": { + "description": "Optional cloud-init user data: a #cloud-config file or a shell script starting with #!, base64 encoded, at most 32 KiB after decoding. The instance receives it unchanged on its first boot.", + "type": "string", + "contentEncoding": "base64", + "example": "I2Nsb3VkLWNvbmZpZwpwYWNrYWdlczoKICAtIG5naW54Cg==" + }, "withPublicIp": { "type": "boolean", "example": true diff --git a/skills/strettch-cloud/SKILL.md b/skills/strettch-cloud/SKILL.md index 5d7b991..2869157 100644 --- a/skills/strettch-cloud/SKILL.md +++ b/skills/strettch-cloud/SKILL.md @@ -92,6 +92,7 @@ Body: | `publicKeys` | string[] | Yes (min 1) | SSH public keys for access | | `withPublicIp` | boolean | No | Allocate a public IP address | | `tags` | string[] | No | Labels for the instance | +| `userData` | string (base64) | No | cloud-init user data (`#cloud-config` or a `#!` script), at most 32 KiB decoded | ### Upsize Compute Request (PATCH /computes/{id}/upsize)