Skip to content

Commit 82f460f

Browse files
claudespiceClaudephillipleblanc
authored
Rework cloud-connect-dev recipe onto the spice cloud enrollment flow (#597)
* Fix cloud-connect-dev recipe: point the Cloud Connect doc links at the published pages Both Cloud Connect links 404: /docs/deployment/cloud/cloud-connect and /docs/deployment/cloud/cloud-connect/service are unreleased pages, published under /docs/next/ until v2.2 ships. The `spice connect` CLI reference resolves at the released path, but that page documents the superseded command (no `spice connect service install`, no `spiced --token`), so it points at /docs/next/ too — the flow this recipe and its validate.sh assert. Also align the docker-compose.yml comment with the README's PG_PASSWORD, since the README states that secret names are matched exactly. * recipe(cloud-connect-dev): sign in with spice login The CLI's own failure hint for an unauthenticated link reads "Run `spice login`, then retry `spice cloud link`". A reader who gets stuck reads the error before they re-read the recipe, so the recipe uses the same spelling. Also say that `spice cloud status` reads from Spice Cloud and needs that session: it reports project health from the control plane, so unlike the purely local checks in validate.sh it does not work signed out. * recipe(cloud-connect-dev): create the project from the CLI `spice cloud project create <name>` with no `--kind` creates the unattached Cloud Connect project that `spice cloud link` attaches to, so the recipe no longer sends the reader to the portal to make one. Setup is CLI end to end: `spice login`, `spice cloud project create`, `spice cloud link`, `spice run`. `--kind` is the discriminator. Naming one asks for a Spice-managed project and requires `--region`; omitting it asks for a Cloud Connect project, which has no region to choose. `--region` and the hosted-runtime flags are refused rather than ignored when no kind is given, so the README says so. validate.sh asserts that distinction. `execute_project_create` resolves placement before it connects, so both refusals are argument validation: they answer with no account and create nothing. The exit code is asserted alongside the message, so a future ordering change that created the project before validating it would fail the check rather than pass silently. `spice cloud link` still requires a terminal and a user login. Creating the project from the CLI does not change that. ./validate.sh: 37 passed, 0 failed, TEST PASSED (was 33 passed, 0 failed). * recipe(cloud-connect-dev): set the project secret from the CLI `spice cloud secrets set PG_PASSWORD "$SPICE_DEMO_PG_PASSWORD"` replaces the portal walkthrough, and `spice cloud secrets list` confirms it. Linking resolves the project, so neither needs `--project`. The value is a required positional argument. There is no stdin, file, or environment form: `SecretsSetArgs.value` is a bare `String` with no clap attribute, and the only stdin read in the module is the project-delete prompt. So the recipe passes the shell variable, which keeps the password out of shell history — history records the line as typed — but the expanded value is still in the process argument list while the command runs, and the README says so and points at the portal for a shared machine. `spice cloud secrets get` prints the value to stdout, so the confirmation step uses `list`, which reports names and timestamps only. validate.sh asserts the four subcommands exist and that the README passes the password by variable and never calls `secrets get`. Nothing sets, reads, or deletes a real secret: these commands reach the control plane, and a validator that mutates a cloud project when a developer happens to be logged in is worse than the coverage it would buy. The compose comment tracks the credential to the project rather than to the portal, which is where it now goes. ./validate.sh: 43 passed, 0 failed, TEST PASSED (was 37 passed, 0 failed). README URLs re-checked: 4/4 HTTP 200. * recipe(cloud-connect-dev): run the README checks above the version gate The checks that only read README.md need no CLI, but sat below the version gate with the ones that do. CI installs the stable CLI, so the gate skips everything under it and those checks never ran there — including the guard that fails if the recipe spells the database password literally instead of passing \$SPICE_DEMO_PG_PASSWORD. That is the one check that most needs to run on every pull request. Group them into a README section above the gate. The CLI sections keep only what actually needs a CLI: the --help listings, the project-kind refusals, and the non-interactive link refusal. No assertion is added or removed. Locally, where the gate passes, the suite is unchanged at 43 passed, 0 failed. On a CI image whose CLI predates the flow, the checks that run before the gate go from 16 to 23. --------- Co-authored-by: Claude <claude@Claudes-Mac-mini.local> Co-authored-by: Phillip LeBlanc <879445+phillipleblanc@users.noreply.github.com>
1 parent 244b443 commit 82f460f

3 files changed

Lines changed: 223 additions & 93 deletions

File tree

cloud-connect-dev/README.md

Lines changed: 94 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Works with Spice CLI v2.2 or later.
44

5-
Use this recipe to connect a local Spice instance to Spice Cloud. You will deploy live changes, deliver a secret, and reconnect the instance.
5+
Use this recipe to link a local Spice instance to Spice Cloud. You will deploy live changes, deliver a secret, and restart the instance.
66

77
## Prerequisites
88

@@ -16,34 +16,75 @@ Install the Spice CLI:
1616
curl https://install.spiceai.org | /bin/bash
1717
```
1818

19-
## 1. Connect the instance
19+
## 1. Link the instance
2020

2121
Clone the cookbook and open this recipe:
2222

2323
```shell
2424
git clone https://github.com/spiceai/cookbook.git
2525
cd cookbook/cloud-connect-dev
26-
spice connect
2726
```
2827

29-
Log in to Spice Cloud when the command prompts you. Select an organization. Accept `cloud-connect-dev` as the project name.
28+
Sign in to Spice Cloud:
3029

31-
If that name is in use, accept the suggested name.
30+
```shell
31+
spice login
32+
```
33+
34+
Create the project. With no `--kind`, this creates a Cloud Connect project — one your own runtime serves, which has no region to choose:
35+
36+
```shell
37+
spice cloud project create cloud-connect-dev
38+
```
39+
40+
If that name is taken in your organization, pick another and use it everywhere below.
41+
42+
`--region`, and the hosted-runtime flags such as `--replicas` and `--memory`, are refused here rather than ignored. They configure a Spice-managed project, which you ask for with `--kind set` or `--kind cluster`.
43+
44+
Link this directory to the project:
45+
46+
```shell
47+
spice cloud link <org>/cloud-connect-dev
48+
```
49+
50+
`spice cloud link` enrolls this directory as an instance and attaches it to the project. It needs an interactive terminal; omit the project to choose one from a list. For an unattended machine, mint an enrollment key in the portal and start the runtime with `spiced --token <enrollment-key>` instead.
51+
52+
```text
53+
✓ Linked the enrolled instance to project <org>/cloud-connect-dev
54+
55+
Start this instance in the current directory with:
56+
spice run
57+
58+
You can now use commands without specifying --project:
59+
spice cloud deploy
60+
spice cloud logs
61+
spice cloud secrets list
62+
```
63+
64+
Linking adds `.spice/` to `.gitignore`, the directory holding the instance's mTLS private key.
65+
66+
A project with no stored Spicepod is seeded from the local `spicepod.yaml`, so the project now defines the `data` dataset. Later local edits are not synchronized; deploy to change what the instance runs.
67+
68+
Start the instance:
69+
70+
```shell
71+
spice run
72+
```
3273

3374
Leave the runtime open. Open the monitor link in the output.
3475

3576
In a second terminal, check the connection:
3677

3778
```shell
3879
cd cookbook/cloud-connect-dev
39-
spice connect status
80+
spice cloud status
4081
```
4182

42-
## 2. Deploy a live change
83+
The report covers the project, its latest deployment, and the instances serving it, then closes with this directory's own state under `Local enrolled-instance state:`. It reads from Spice Cloud, so it needs the session `spice login` created.
4384

44-
A deployment replaces the Spicepod the instance runs. In the Spice Cloud portal, open the project Spicepod and paste in the contents of this recipe's local `spicepod.yaml`, so the deployed Spicepod still defines the `data` dataset.
85+
## 2. Deploy a live change
4586

46-
Add this view to the project Spicepod, below the datasets:
87+
A deployment replaces the Spicepod the instance runs. In the Spice Cloud portal, open the project Spicepod and add this view below the datasets:
4788

4889
```yaml
4990
views:
@@ -80,13 +121,30 @@ docker compose exec postgres \
80121
-c 'SELECT count(*) FROM public.orders;'
81122
```
82123

83-
In the portal, open the project's **Settings → Secrets** and add:
124+
Store the password as a project secret. Linking set this directory's project, so `--project` is not needed:
125+
126+
```shell
127+
spice cloud secrets set PG_PASSWORD "$SPICE_DEMO_PG_PASSWORD"
128+
```
129+
130+
```text
131+
✓ Secret 'PG_PASSWORD' set successfully
132+
```
133+
134+
The value is a command argument. Passing the variable keeps the password out of your shell history, but the expanded value is visible in the process list to anyone else on the machine while the command runs. On a shared machine, set it in the portal under **Settings → Secrets** instead.
135+
136+
Confirm the name without printing the value:
137+
138+
```shell
139+
spice cloud secrets list
140+
```
84141

85-
| Name | Value |
86-
| ------------- | ---------------------------------- |
87-
| `PG_PASSWORD` | Value of `$SPICE_DEMO_PG_PASSWORD` |
142+
```text
143+
NAME UPDATED
144+
PG_PASSWORD 2026-01-06T16:22:00Z
145+
```
88146

89-
Secret names are matched exactly. A Spicepod that references a name the project does not define is rejected when you deploy it, and the portal names the closest match it holds.
147+
Secret names are matched exactly. A Spicepod that references a name the project does not define is rejected when you deploy it, and Spice Cloud names the closest match it holds.
90148

91149
Add this dataset to the project Spicepod in the portal — not to the local `spicepod.yaml`:
92150

@@ -129,10 +187,11 @@ The query returns:
129187
Confirm the delivery:
130188

131189
```shell
132-
spice connect status
190+
spice cloud status
133191
```
134192

135193
```text
194+
Local enrolled-instance state:
136195
secrets: 1 delivered: PG_PASSWORD
137196
```
138197

@@ -172,11 +231,11 @@ In the first terminal, press `Ctrl-C`. Start the instance again from the same di
172231
spice run
173232
```
174233

175-
You do not need to run `spice connect` again. The existing identity reconnects the instance.
234+
You do not need to run `spice cloud link` again. The existing identity reconnects the instance.
176235

177236
The instance now serves the deployed `runtime` settings, and the deployment reports nothing pending.
178237

179-
> **Warning:** Spice Cloud invalidates the identity if the instance stays offline for more than 30 days. Enroll the instance again to reconnect it.
238+
> **Warning:** Spice Cloud invalidates the identity if the instance stays offline for more than 30 days. Link the directory again to reconnect it.
180239

181240
## 6. Validate the recipe
182241

@@ -190,10 +249,16 @@ These checks do not connect to Spice Cloud or use credentials.
190249

191250
## 7. Clean up
192251

193-
Stop the runtime. Remove the Cloud Connect instance and project:
252+
Stop the runtime first — `spice cloud unlink` refuses while the instance is running. Then detach this directory:
253+
254+
```shell
255+
spice cloud unlink
256+
```
257+
258+
Unlinking releases the enrolled instance, removes its local identity, and uninstalls its service if one is installed. The project keeps its Spicepod, secrets, and deployment history. Delete it when you are finished with it:
194259

195260
```shell
196-
spice connect remove
261+
spice cloud project delete <org>/cloud-connect-dev
197262
```
198263

199264
Stop PostgreSQL and delete its volume:
@@ -205,11 +270,18 @@ unset SPICE_DEMO_PG_PASSWORD
205270

206271
## Run as a service
207272

208-
To keep the instance running after you close the terminal, see [Cloud Connect as a service](https://spiceai.org/docs/deployment/cloud/cloud-connect/service).
273+
To keep the instance running after you close the terminal, install a service for this directory:
274+
275+
```shell
276+
spice cloud service install
277+
```
278+
279+
`spice cloud service` also has `start`, `stop`, `restart`, and `uninstall`. Uninstalling keeps the Cloud identity, so `spice run` still reconnects the instance.
209280

210281
Windows does not support the managed service.
211282

283+
See [Cloud Connect as a service](https://spiceai.org/docs/next/deployment/cloud/cloud-connect/service).
284+
212285
## Learn more
213286

214-
- [Cloud Connect](https://spiceai.org/docs/deployment/cloud/cloud-connect)
215-
- [`spice connect` reference](https://spiceai.org/docs/cli/reference/connect)
287+
- [Cloud Connect](https://spiceai.org/docs/next/deployment/cloud/cloud-connect)

cloud-connect-dev/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# A local PostgreSQL for the secrets step of the README.
22
#
33
# The password is never written here. It is read from the environment, and the
4-
# same value is what you set as the `pg_password` secret in the Spice Cloud
5-
# portal — so the one credential this recipe uses exists in your shell and in
6-
# the portal, and in no file this repository tracks.
4+
# same value is what you set as the `PG_PASSWORD` secret on the Spice Cloud
5+
# project — so the one credential this recipe uses exists in your shell and in
6+
# the project, and in no file this repository tracks.
77
services:
88
postgres:
99
image: postgres:16-alpine

0 commit comments

Comments
 (0)