|
1
|
import { Table, Note, CodeTabs, CodeTab } from "docs-ui" |
|
2
|
|
|
3
|
export const metadata = { |
|
4
|
title: `variables Command - Medusa Cloud CLI Reference`, |
|
5
|
} |
|
6
|
|
|
7
|
# {metadata.title} |
|
8
|
|
|
9
|
In this guide, you'll learn how to inspect and manage the [environment variables](../../../environments/environment-variables/page.mdx) of a Cloud environment using the CLI. |
|
10
|
|
|
11
|
## variables list |
|
12
|
|
|
13
|
List all environment variables for a Cloud environment. |
|
14
|
|
|
15
|
<CodeTabs group="cli-auth"> |
|
16
|
<CodeTab label="With Flags" value="flags"> |
|
17
|
|
|
18
|
```bash |
|
19
|
mcloud variables list \ |
|
20
|
--organization org_123 \ |
|
21
|
--project proj_123 \ |
|
22
|
--environment env_123 |
|
23
|
``` |
|
24
|
|
|
25
|
</CodeTab> |
|
26
|
<CodeTab label="Using mcloud use" value="use"> |
|
27
|
|
|
28
|
```bash |
|
29
|
# Run once: mcloud use --organization org_123 --project proj_123 --environment env_123 |
|
30
|
|
|
31
|
mcloud variables list |
|
32
|
``` |
|
33
|
|
|
34
|
</CodeTab> |
|
35
|
</CodeTabs> |
|
36
|
|
|
37
|
### Options |
|
38
|
|
|
39
|
<Table> |
|
40
|
<Table.Header> |
|
41
|
<Table.Row> |
|
42
|
<Table.HeaderCell> |
|
43
|
Option |
|
44
|
</Table.HeaderCell> |
|
45
|
<Table.HeaderCell> |
|
46
|
Description |
|
47
|
</Table.HeaderCell> |
|
48
|
<Table.HeaderCell> |
|
49
|
Required |
|
50
|
</Table.HeaderCell> |
|
51
|
<Table.HeaderCell> |
|
52
|
Default |
|
53
|
</Table.HeaderCell> |
|
54
|
</Table.Row> |
|
55
|
</Table.Header> |
|
56
|
<Table.Body> |
|
57
|
<Table.Row> |
|
58
|
<Table.Cell> |
|
59
|
|
|
60
|
`-o <id>`, `--organization <id>` |
|
61
|
|
|
62
|
</Table.Cell> |
|
63
|
<Table.Cell> |
|
64
|
|
|
65
|
The [ID of the organization](../organizations/page.mdx#find-organization-id) that the environment belongs to. |
|
66
|
|
|
67
|
</Table.Cell> |
|
68
|
<Table.Cell> |
|
69
|
|
|
70
|
Yes |
|
71
|
|
|
72
|
</Table.Cell> |
|
73
|
<Table.Cell> |
|
74
|
|
|
75
|
Falls back to the organization in the [active context](../use/page.mdx), if set. |
|
76
|
|
|
77
|
</Table.Cell> |
|
78
|
</Table.Row> |
|
79
|
<Table.Row> |
|
80
|
<Table.Cell> |
|
81
|
|
|
82
|
`-p <id-or-handle>`, `--project <id-or-handle>` |
|
83
|
|
|
84
|
</Table.Cell> |
|
85
|
<Table.Cell> |
|
86
|
|
|
87
|
The [ID or handle of the project](../projects/page.mdx#find-project-ids-and-handles) that the environment belongs to. |
|
88
|
|
|
89
|
</Table.Cell> |
|
90
|
<Table.Cell> |
|
91
|
|
|
92
|
Yes |
|
93
|
|
|
94
|
</Table.Cell> |
|
95
|
<Table.Cell> |
|
96
|
|
|
97
|
Falls back to the project in the [active context](../use/page.mdx), if set. |
|
98
|
|
|
99
|
</Table.Cell> |
|
100
|
</Table.Row> |
|
101
|
<Table.Row> |
|
102
|
<Table.Cell> |
|
103
|
|
|
104
|
`-e <handle>`, `--environment <handle>` |
|
105
|
|
|
106
|
</Table.Cell> |
|
107
|
<Table.Cell> |
|
108
|
|
|
109
|
The [handle of the environment](../environments/page.mdx#find-environment-handles) to list variables from. |
|
110
|
|
|
111
|
</Table.Cell> |
|
112
|
<Table.Cell> |
|
113
|
|
|
114
|
Yes |
|
115
|
|
|
116
|
</Table.Cell> |
|
117
|
<Table.Cell> |
|
118
|
|
|
119
|
Falls back to the environment in the [active context](../use/page.mdx), if set. |
|
120
|
|
|
121
|
</Table.Cell> |
|
122
|
</Table.Row> |
|
123
|
<Table.Row> |
|
124
|
<Table.Cell> |
|
125
|
|
|
126
|
`-t <type>`, `--type <type>` |
|
127
|
|
|
128
|
</Table.Cell> |
|
129
|
<Table.Cell> |
|
130
|
|
|
131
|
The type of variables to list. Accepts `backend` or `storefront`. |
|
132
|
|
|
133
|
</Table.Cell> |
|
134
|
<Table.Cell> |
|
135
|
|
|
136
|
No |
|
137
|
|
|
138
|
</Table.Cell> |
|
139
|
<Table.Cell> |
|
140
|
|
|
141
|
`backend` |
|
142
|
|
|
143
|
</Table.Cell> |
|
144
|
</Table.Row> |
|
145
|
<Table.Row> |
|
146
|
<Table.Cell> |
|
147
|
|
|
148
|
`--reveal` |
|
149
|
|
|
150
|
</Table.Cell> |
|
151
|
<Table.Cell> |
|
152
|
|
|
153
|
Print secret values in plain text instead of masking them. |
|
154
|
|
|
155
|
</Table.Cell> |
|
156
|
<Table.Cell> |
|
157
|
|
|
158
|
No |
|
159
|
|
|
160
|
</Table.Cell> |
|
161
|
<Table.Cell> |
|
162
|
|
|
163
|
`false` |
|
164
|
|
|
165
|
</Table.Cell> |
|
166
|
</Table.Row> |
|
167
|
<Table.Row> |
|
168
|
<Table.Cell> |
|
169
|
|
|
170
|
`--include-system` |
|
171
|
|
|
172
|
</Table.Cell> |
|
173
|
<Table.Cell> |
|
174
|
|
|
175
|
Include system variables that Medusa auto-injects into the environment. |
|
176
|
|
|
177
|
</Table.Cell> |
|
178
|
<Table.Cell> |
|
179
|
|
|
180
|
No |
|
181
|
|
|
182
|
</Table.Cell> |
|
183
|
<Table.Cell> |
|
184
|
|
|
185
|
`false` |
|
186
|
|
|
187
|
</Table.Cell> |
|
188
|
</Table.Row> |
|
189
|
<Table.Row> |
|
190
|
<Table.Cell> |
|
191
|
|
|
192
|
`--scope <scope>` |
|
193
|
|
|
194
|
</Table.Cell> |
|
195
|
<Table.Cell> |
|
196
|
|
|
197
|
Filter variables by scope. Accepts `build` or `runtime`, and you can pass it multiple times to include more than one scope. By default, both build and runtime variables are included. |
|
198
|
|
|
199
|
</Table.Cell> |
|
200
|
<Table.Cell> |
|
201
|
|
|
202
|
No |
|
203
|
|
|
204
|
</Table.Cell> |
|
205
|
<Table.Cell> |
|
206
|
|
|
207
|
Both scopes |
|
208
|
|
|
209
|
</Table.Cell> |
|
210
|
</Table.Row> |
|
211
|
<Table.Row> |
|
212
|
<Table.Cell> |
|
213
|
|
|
214
|
`--dotenv` |
|
215
|
|
|
216
|
</Table.Cell> |
|
217
|
<Table.Cell> |
|
218
|
|
|
219
|
Output the variables in `.env` file format (`KEY=VALUE` lines) instead of a table. |
|
220
|
|
|
221
|
</Table.Cell> |
|
222
|
<Table.Cell> |
|
223
|
|
|
224
|
No |
|
225
|
|
|
226
|
</Table.Cell> |
|
227
|
<Table.Cell> |
|
228
|
|
|
229
|
`false` |
|
230
|
|
|
231
|
</Table.Cell> |
|
232
|
</Table.Row> |
|
233
|
<Table.Row> |
|
234
|
<Table.Cell> |
|
235
|
|
|
236
|
`--json` |
|
237
|
|
|
238
|
</Table.Cell> |
|
239
|
<Table.Cell> |
|
240
|
|
|
241
|
Print the result as JSON instead of formatted text. |
|
242
|
|
|
243
|
</Table.Cell> |
|
244
|
<Table.Cell> |
|
245
|
|
|
246
|
No |
|
247
|
|
|
248
|
</Table.Cell> |
|
249
|
<Table.Cell> |
|
250
|
|
|
251
|
`false` |
|
252
|
|
|
253
|
</Table.Cell> |
|
254
|
</Table.Row> |
|
255
|
</Table.Body> |
|
256
|
</Table> |
|
257
|
|
|
258
|
--- |
|
259
|
|
|
260
|
## variables get |
|
261
|
|
|
262
|
Retrieve a single variable by its ID (`var_...`) or by its key. Looking up by key requires `--project` and `--environment` (or the equivalent values in the [active context](../use/page.mdx)) so the CLI knows which environment to search. |
|
263
|
|
|
264
|
<CodeTabs group="cli-auth"> |
|
265
|
<CodeTab label="With Flags" value="flags"> |
|
266
|
|
|
267
|
```bash |
|
268
|
mcloud variables get ADMIN_CORS \ |
|
269
|
--organization org_123 \ |
|
270
|
--project proj_123 \ |
|
271
|
--environment env_123 |
|
272
|
``` |
|
273
|
|
|
274
|
</CodeTab> |
|
275
|
<CodeTab label="Using mcloud use" value="use"> |
|
276
|
|
|
277
|
```bash |
|
278
|
# Run once: mcloud use --organization org_123 --project proj_123 --environment env_123 |
|
279
|
|
|
280
|
mcloud variables get ADMIN_CORS |
|
281
|
``` |
|
282
|
|
|
283
|
</CodeTab> |
|
284
|
</CodeTabs> |
|
285
|
|
|
286
|
You can also fetch a variable by ID without setting the active environment: |
|
287
|
|
|
288
|
```bash |
|
289
|
mcloud variables get var_01XYZ |
|
290
|
``` |
|
291
|
|
|
292
|
This returns the variable's details, similar to the following: |
|
293
|
|
|
294
|
<CodeTabs group="cli-output"> |
|
295
|
<CodeTab label="Plaintext" value="plaintext"> |
|
296
|
|
|
297
|
```bash |
|
298
|
Key: ADMIN_CORS |
|
299
|
Value: https://admin.mystore.com |
|
300
|
Secret: no |
|
301
|
Scope: runtime |
|
302
|
System: no |
|
303
|
ID: var_123 |
|
304
|
Environment: env_123 |
|
305
|
Updated at: Feb 17, 2026, 4:15 PM GMT+2 |
|
306
|
``` |
|
307
|
|
|
308
|
</CodeTab> |
|
309
|
<CodeTab label="JSON (--json)" value="json"> |
|
310
|
|
|
311
|
```json |
|
312
|
{ |
|
313
|
"id": "var_123", |
|
314
|
"environment_id": "env_123", |
|
315
|
"key": "ADMIN_CORS", |
|
316
|
"value": "https://admin.mystore.com", |
|
317
|
"is_secret": false, |
|
318
|
"is_build": false, |
|
319
|
"is_runtime": true, |
|
320
|
"updated_at": "2026-02-17T14:15:00.000Z", |
|
321
|
"source": "user" |
|
322
|
} |
|
323
|
``` |
|
324
|
|
|
325
|
</CodeTab> |
|
326
|
</CodeTabs> |
|
327
|
|
|
328
|
### Arguments |
|
329
|
|
|
330
|
<Table> |
|
331
|
<Table.Header> |
|
332
|
<Table.Row> |
|
333
|
<Table.HeaderCell> |
|
334
|
Option |
|
335
|
</Table.HeaderCell> |
|
336
|
<Table.HeaderCell> |
|
337
|
Description |
|
338
|
</Table.HeaderCell> |
|
339
|
<Table.HeaderCell> |
|
340
|
Required |
|
341
|
</Table.HeaderCell> |
|
342
|
</Table.Row> |
|
343
|
</Table.Header> |
|
344
|
<Table.Body> |
|
345
|
<Table.Row> |
|
346
|
<Table.Cell> |
|
347
|
|
|
348
|
`variable` |
|
349
|
|
|
350
|
</Table.Cell> |
|
351
|
<Table.Cell> |
|
352
|
|
|
353
|
Variable ID (`var_...`) or key. When passing a key, you must also provide `--project` and `--environment` (or set them in the [active context](../use/page.mdx)). |
|
354
|
|
|
355
|
</Table.Cell> |
|
356
|
<Table.Cell> |
|
357
|
|
|
358
|
Yes |
|
359
|
|
|
360
|
</Table.Cell> |
|
361
|
</Table.Row> |
|
362
|
</Table.Body> |
|
363
|
</Table> |
|
364
|
|
|
365
|
### Options |
|
366
|
|
|
367
|
<Table> |
|
368
|
<Table.Header> |
|
369
|
<Table.Row> |
|
370
|
<Table.HeaderCell> |
|
371
|
Option |
|
372
|
</Table.HeaderCell> |
|
373
|
<Table.HeaderCell> |
|
374
|
Description |
|
375
|
</Table.HeaderCell> |
|
376
|
<Table.HeaderCell> |
|
377
|
Required |
|
378
|
</Table.HeaderCell> |
|
379
|
<Table.HeaderCell> |
|
380
|
Default |
|
381
|
</Table.HeaderCell> |
|
382
|
</Table.Row> |
|
383
|
</Table.Header> |
|
384
|
<Table.Body> |
|
385
|
<Table.Row> |
|
386
|
<Table.Cell> |
|
387
|
|
|
388
|
`-o <id>`, `--organization <id>` |
|
389
|
|
|
390
|
</Table.Cell> |
|
391
|
<Table.Cell> |
|
392
|
|
|
393
|
The [ID of the organization](../organizations/page.mdx#find-organization-id) that the variable belongs to. |
|
394
|
|
|
395
|
</Table.Cell> |
|
396
|
<Table.Cell> |
|
397
|
|
|
398
|
Yes |
|
399
|
|
|
400
|
</Table.Cell> |
|
401
|
<Table.Cell> |
|
402
|
|
|
403
|
Falls back to the organization in the [active context](../use/page.mdx), if set. |
|
404
|
|
|
405
|
</Table.Cell> |
|
406
|
</Table.Row> |
|
407
|
<Table.Row> |
|
408
|
<Table.Cell> |
|
409
|
|
|
410
|
`-p <id-or-handle>`, `--project <id-or-handle>` |
|
411
|
|
|
412
|
</Table.Cell> |
|
413
|
<Table.Cell> |
|
414
|
|
|
415
|
The [ID or handle of the project](../projects/page.mdx#find-project-ids-and-handles) that the variable belongs to. Required when looking up by key. |
|
416
|
|
|
417
|
</Table.Cell> |
|
418
|
<Table.Cell> |
|
419
|
|
|
420
|
Conditional |
|
421
|
|
|
422
|
</Table.Cell> |
|
423
|
<Table.Cell> |
|
424
|
|
|
425
|
Falls back to the project in the [active context](../use/page.mdx), if set. |
|
426
|
|
|
427
|
</Table.Cell> |
|
428
|
</Table.Row> |
|
429
|
<Table.Row> |
|
430
|
<Table.Cell> |
|
431
|
|
|
432
|
`-e <handle>`, `--environment <handle>` |
|
433
|
|
|
434
|
</Table.Cell> |
|
435
|
<Table.Cell> |
|
436
|
|
|
437
|
The [handle of the environment](../environments/page.mdx#find-environment-handles) that the variable belongs to. Required when looking up by key. |
|
438
|
|
|
439
|
</Table.Cell> |
|
440
|
<Table.Cell> |
|
441
|
|
|
442
|
Conditional |
|
443
|
|
|
444
|
</Table.Cell> |
|
445
|
<Table.Cell> |
|
446
|
|
|
447
|
Falls back to the environment in the [active context](../use/page.mdx), if set. |
|
448
|
|
|
449
|
</Table.Cell> |
|
450
|
</Table.Row> |
|
451
|
<Table.Row> |
|
452
|
<Table.Cell> |
|
453
|
|
|
454
|
`-t <type>`, `--type <type>` |
|
455
|
|
|
456
|
</Table.Cell> |
|
457
|
<Table.Cell> |
|
458
|
|
|
459
|
The type of variable to get. Accepts `backend` or `storefront`. |
|
460
|
|
|
461
|
</Table.Cell> |
|
462
|
<Table.Cell> |
|
463
|
|
|
464
|
No |
|
465
|
|
|
466
|
</Table.Cell> |
|
467
|
<Table.Cell> |
|
468
|
|
|
469
|
`backend` |
|
470
|
|
|
471
|
</Table.Cell> |
|
472
|
</Table.Row> |
|
473
|
<Table.Row> |
|
474
|
<Table.Cell> |
|
475
|
|
|
476
|
`--reveal` |
|
477
|
|
|
478
|
</Table.Cell> |
|
479
|
<Table.Cell> |
|
480
|
|
|
481
|
Print the secret value in plain text instead of masking it. |
|
482
|
|
|
483
|
</Table.Cell> |
|
484
|
<Table.Cell> |
|
485
|
|
|
486
|
No |
|
487
|
|
|
488
|
</Table.Cell> |
|
489
|
<Table.Cell> |
|
490
|
|
|
491
|
`false` |
|
492
|
|
|
493
|
</Table.Cell> |
|
494
|
</Table.Row> |
|
495
|
<Table.Row> |
|
496
|
<Table.Cell> |
|
497
|
|
|
498
|
`--json` |
|
499
|
|
|
500
|
</Table.Cell> |
|
501
|
<Table.Cell> |
|
502
|
|
|
503
|
Print the result as JSON instead of formatted text. |
|
504
|
|
|
505
|
</Table.Cell> |
|
506
|
<Table.Cell> |
|
507
|
|
|
508
|
No |
|
509
|
|
|
510
|
</Table.Cell> |
|
511
|
<Table.Cell> |
|
512
|
|
|
513
|
`false` |
|
514
|
|
|
515
|
</Table.Cell> |
|
516
|
</Table.Row> |
|
517
|
</Table.Body> |
|
518
|
</Table> |
|
519
|
|
|
520
|
--- |
|
521
|
|
|
522
|
## variables set |
|
523
|
|
|
524
|
<Note> |
|
525
|
|
|
526
|
This command is available since Medusa mcloud CLI v0.1.10. |
|
527
|
|
|
528
|
</Note> |
|
529
|
|
|
530
|
Create or update one or more environment variables. Pass a single variable and value as arguments, or set multiple variables at once using `--var` or `--env-file`. |
|
531
|
|
|
532
|
The CLI updates a variable when you reference it by ID (`var_...`) or by an existing key, and creates a new variable when the key doesn't exist yet. Creating or looking up a variable by key requires `--project` and `--environment` (or the equivalent values in the [active context](../use/page.mdx)). |
|
533
|
|
|
534
|
<CodeTabs group="cli-auth"> |
|
535
|
<CodeTab label="With Flags" value="flags"> |
|
536
|
|
|
537
|
```bash |
|
538
|
mcloud variables set API_KEY pk_123 \ |
|
539
|
--organization org_123 \ |
|
540
|
--project proj_123 \ |
|
541
|
--environment env_123 |
|
542
|
``` |
|
543
|
|
|
544
|
</CodeTab> |
|
545
|
<CodeTab label="Using mcloud use" value="use"> |
|
546
|
|
|
547
|
```bash |
|
548
|
# Run once: mcloud use --organization org_123 --project proj_123 --environment env_123 |
|
549
|
|
|
550
|
mcloud variables set API_KEY pk_123 |
|
551
|
``` |
|
552
|
|
|
553
|
</CodeTab> |
|
554
|
</CodeTabs> |
|
555
|
|
|
556
|
To set multiple variables at once, use `--var` for each variable or point to a `.env` file with `--env-file`: |
|
557
|
|
|
558
|
```bash |
|
559
|
mcloud variables set \ |
|
560
|
-v API_KEY=pk_123 \ |
|
561
|
-v CLIENT_ID=my_app |
|
562
|
``` |
|
563
|
|
|
564
|
```bash |
|
565
|
mcloud variables set --env-file .env |
|
566
|
``` |
|
567
|
|
|
568
|
### Redeploy or Rebuild to Apply Changes |
|
569
|
|
|
570
|
Setting a variable saves it to the environment but doesn't rebuild or redeploy your application. The running deployment keeps using the previous values until you deploy again: |
|
571
|
|
|
572
|
- For a **runtime** variable (`--runtime`), run [`mcloud environments redeploy`](../environments/page.mdx#environments-redeploy) to re-run the active build with the new value. |
|
573
|
- For a **build** variable (`--build`), run [`mcloud environments trigger-build`](../environments/page.mdx#environments-trigger-build) to start a new build. A redeploy reuses the existing image and won't pick up build variable changes. |
|
574
|
|
|
575
|
### Arguments |
|
576
|
|
|
577
|
<Table> |
|
578
|
<Table.Header> |
|
579
|
<Table.Row> |
|
580
|
<Table.HeaderCell> |
|
581
|
Option |
|
582
|
</Table.HeaderCell> |
|
583
|
<Table.HeaderCell> |
|
584
|
Description |
|
585
|
</Table.HeaderCell> |
|
586
|
<Table.HeaderCell> |
|
587
|
Required |
|
588
|
</Table.HeaderCell> |
|
589
|
</Table.Row> |
|
590
|
</Table.Header> |
|
591
|
<Table.Body> |
|
592
|
<Table.Row> |
|
593
|
<Table.Cell> |
|
594
|
|
|
595
|
`variable` |
|
596
|
|
|
597
|
</Table.Cell> |
|
598
|
<Table.Cell> |
|
599
|
|
|
600
|
Variable ID (`var_...`) or key to set. When passing a key, you must also provide `--project` and `--environment` (or set them in the [active context](../use/page.mdx)). Omit when using `--var` or `--env-file`. |
|
601
|
|
|
602
|
</Table.Cell> |
|
603
|
<Table.Cell> |
|
604
|
|
|
605
|
No |
|
606
|
|
|
607
|
</Table.Cell> |
|
608
|
</Table.Row> |
|
609
|
<Table.Row> |
|
610
|
<Table.Cell> |
|
611
|
|
|
612
|
`value` |
|
613
|
|
|
614
|
</Table.Cell> |
|
615
|
<Table.Cell> |
|
616
|
|
|
617
|
The value to set for the variable. Required when a `variable` argument is passed. |
|
618
|
|
|
619
|
</Table.Cell> |
|
620
|
<Table.Cell> |
|
621
|
|
|
622
|
No |
|
623
|
|
|
624
|
</Table.Cell> |
|
625
|
</Table.Row> |
|
626
|
</Table.Body> |
|
627
|
</Table> |
|
628
|
|
|
629
|
### Options |
|
630
|
|
|
631
|
<Table> |
|
632
|
<Table.Header> |
|
633
|
<Table.Row> |
|
634
|
<Table.HeaderCell> |
|
635
|
Option |
|
636
|
</Table.HeaderCell> |
|
637
|
<Table.HeaderCell> |
|
638
|
Description |
|
639
|
</Table.HeaderCell> |
|
640
|
<Table.HeaderCell> |
|
641
|
Required |
|
642
|
</Table.HeaderCell> |
|
643
|
<Table.HeaderCell> |
|
644
|
Default |
|
645
|
</Table.HeaderCell> |
|
646
|
</Table.Row> |
|
647
|
</Table.Header> |
|
648
|
<Table.Body> |
|
649
|
<Table.Row> |
|
650
|
<Table.Cell> |
|
651
|
|
|
652
|
`-o <id>`, `--organization <id>` |
|
653
|
|
|
654
|
</Table.Cell> |
|
655
|
<Table.Cell> |
|
656
|
|
|
657
|
The [ID of the organization](../organizations/page.mdx#find-organization-id) that the variable belongs to. |
|
658
|
|
|
659
|
</Table.Cell> |
|
660
|
<Table.Cell> |
|
661
|
|
|
662
|
Yes |
|
663
|
|
|
664
|
</Table.Cell> |
|
665
|
<Table.Cell> |
|
666
|
|
|
667
|
Falls back to the organization in the [active context](../use/page.mdx), if set. |
|
668
|
|
|
669
|
</Table.Cell> |
|
670
|
</Table.Row> |
|
671
|
<Table.Row> |
|
672
|
<Table.Cell> |
|
673
|
|
|
674
|
`-p <id-or-handle>`, `--project <id-or-handle>` |
|
675
|
|
|
676
|
</Table.Cell> |
|
677
|
<Table.Cell> |
|
678
|
|
|
679
|
The [ID or handle of the project](../projects/page.mdx#find-project-ids-and-handles) that the variable belongs to. Required when setting a variable by key. |
|
680
|
|
|
681
|
</Table.Cell> |
|
682
|
<Table.Cell> |
|
683
|
|
|
684
|
Conditional |
|
685
|
|
|
686
|
</Table.Cell> |
|
687
|
<Table.Cell> |
|
688
|
|
|
689
|
Falls back to the project in the [active context](../use/page.mdx), if set. |
|
690
|
|
|
691
|
</Table.Cell> |
|
692
|
</Table.Row> |
|
693
|
<Table.Row> |
|
694
|
<Table.Cell> |
|
695
|
|
|
696
|
`-e <handle>`, `--environment <handle>` |
|
697
|
|
|
698
|
</Table.Cell> |
|
699
|
<Table.Cell> |
|
700
|
|
|
701
|
The [handle of the environment](../environments/page.mdx#find-environment-handles) that the variable belongs to. Required when setting a variable by key. |
|
702
|
|
|
703
|
</Table.Cell> |
|
704
|
<Table.Cell> |
|
705
|
|
|
706
|
Conditional |
|
707
|
|
|
708
|
</Table.Cell> |
|
709
|
<Table.Cell> |
|
710
|
|
|
711
|
Falls back to the environment in the [active context](../use/page.mdx), if set. |
|
712
|
|
|
713
|
</Table.Cell> |
|
714
|
</Table.Row> |
|
715
|
<Table.Row> |
|
716
|
<Table.Cell> |
|
717
|
|
|
718
|
`-t <type>`, `--type <type>` |
|
719
|
|
|
720
|
</Table.Cell> |
|
721
|
<Table.Cell> |
|
722
|
|
|
723
|
The type of variable to set. Accepts `backend` or `storefront`. |
|
724
|
|
|
725
|
</Table.Cell> |
|
726
|
<Table.Cell> |
|
727
|
|
|
728
|
No |
|
729
|
|
|
730
|
</Table.Cell> |
|
731
|
<Table.Cell> |
|
732
|
|
|
733
|
`backend` |
|
734
|
|
|
735
|
</Table.Cell> |
|
736
|
</Table.Row> |
|
737
|
<Table.Row> |
|
738
|
<Table.Cell> |
|
739
|
|
|
740
|
`-v <var>`, `--var <var>` |
|
741
|
|
|
742
|
</Table.Cell> |
|
743
|
<Table.Cell> |
|
744
|
|
|
745
|
A variable to set in the format `ID=VALUE` or `KEY=VALUE`. Pass it multiple times to set more than one variable. Keys require `--project` and `--environment`. |
|
746
|
|
|
747
|
</Table.Cell> |
|
748
|
<Table.Cell> |
|
749
|
|
|
750
|
No |
|
751
|
|
|
752
|
</Table.Cell> |
|
753
|
<Table.Cell> |
|
754
|
|
|
755
|
\- |
|
756
|
|
|
757
|
</Table.Cell> |
|
758
|
</Table.Row> |
|
759
|
<Table.Row> |
|
760
|
<Table.Cell> |
|
761
|
|
|
762
|
`--env-file <path>` |
|
763
|
|
|
764
|
</Table.Cell> |
|
765
|
<Table.Cell> |
|
766
|
|
|
767
|
Path to a `.env` file whose variables are set on the environment. |
|
768
|
|
|
769
|
</Table.Cell> |
|
770
|
<Table.Cell> |
|
771
|
|
|
772
|
No |
|
773
|
|
|
774
|
</Table.Cell> |
|
775
|
<Table.Cell> |
|
776
|
|
|
777
|
\- |
|
778
|
|
|
779
|
</Table.Cell> |
|
780
|
</Table.Row> |
|
781
|
<Table.Row> |
|
782
|
<Table.Cell> |
|
783
|
|
|
784
|
`--secret`, `--no-secret` |
|
785
|
|
|
786
|
</Table.Cell> |
|
787
|
<Table.Cell> |
|
788
|
|
|
789
|
Whether the variable is a secret. Pass `--no-secret` to explicitly mark it as not secret. |
|
790
|
|
|
791
|
</Table.Cell> |
|
792
|
<Table.Cell> |
|
793
|
|
|
794
|
No |
|
795
|
|
|
796
|
</Table.Cell> |
|
797
|
<Table.Cell> |
|
798
|
|
|
799
|
`false` for new variables |
|
800
|
|
|
801
|
</Table.Cell> |
|
802
|
</Table.Row> |
|
803
|
<Table.Row> |
|
804
|
<Table.Cell> |
|
805
|
|
|
806
|
`--build`, `--no-build` |
|
807
|
|
|
808
|
</Table.Cell> |
|
809
|
<Table.Cell> |
|
810
|
|
|
811
|
Whether the variable is available at build time. |
|
812
|
|
|
813
|
</Table.Cell> |
|
814
|
<Table.Cell> |
|
815
|
|
|
816
|
No |
|
817
|
|
|
818
|
</Table.Cell> |
|
819
|
<Table.Cell> |
|
820
|
|
|
821
|
`false` for new variables |
|
822
|
|
|
823
|
</Table.Cell> |
|
824
|
</Table.Row> |
|
825
|
<Table.Row> |
|
826
|
<Table.Cell> |
|
827
|
|
|
828
|
`--runtime`, `--no-runtime` |
|
829
|
|
|
830
|
</Table.Cell> |
|
831
|
<Table.Cell> |
|
832
|
|
|
833
|
Whether the variable is available at runtime. Pass `--no-runtime` to disable it. |
|
834
|
|
|
835
|
</Table.Cell> |
|
836
|
<Table.Cell> |
|
837
|
|
|
838
|
No |
|
839
|
|
|
840
|
</Table.Cell> |
|
841
|
<Table.Cell> |
|
842
|
|
|
843
|
`true` for new variables |
|
844
|
|
|
845
|
</Table.Cell> |
|
846
|
</Table.Row> |
|
847
|
<Table.Row> |
|
848
|
<Table.Cell> |
|
849
|
|
|
850
|
`--json` |
|
851
|
|
|
852
|
</Table.Cell> |
|
853
|
<Table.Cell> |
|
854
|
|
|
855
|
Print the result as JSON instead of formatted text. |
|
856
|
|
|
857
|
</Table.Cell> |
|
858
|
<Table.Cell> |
|
859
|
|
|
860
|
No |
|
861
|
|
|
862
|
</Table.Cell> |
|
863
|
<Table.Cell> |
|
864
|
|
|
865
|
`false` |
|
866
|
|
|
867
|
</Table.Cell> |
|
868
|
</Table.Row> |
|
869
|
</Table.Body> |
|
870
|
</Table> |
|
871
|
|
|
872
|
--- |
|
873
|
|
|
874
|
## variables delete |
|
875
|
|
|
876
|
<Note> |
|
877
|
|
|
878
|
This command is available since Medusa mcloud CLI v0.1.10. |
|
879
|
|
|
880
|
</Note> |
|
881
|
|
|
882
|
Delete an environment variable by its ID (`var_...`) or key. Looking up by key requires `--project` and `--environment` (or the equivalent values in the [active context](../use/page.mdx)). |
|
883
|
|
|
884
|
<Note type="warning"> |
|
885
|
|
|
886
|
Deleting a variable is irreversible. You can't delete system variables that Medusa auto-injects into the environment. |
|
887
|
|
|
888
|
</Note> |
|
889
|
|
|
890
|
<CodeTabs group="cli-auth"> |
|
891
|
<CodeTab label="With Flags" value="flags"> |
|
892
|
|
|
893
|
```bash |
|
894
|
mcloud variables delete API_KEY \ |
|
895
|
--organization org_123 \ |
|
896
|
--project proj_123 \ |
|
897
|
--environment env_123 \ |
|
898
|
--yes |
|
899
|
``` |
|
900
|
|
|
901
|
</CodeTab> |
|
902
|
<CodeTab label="Using mcloud use" value="use"> |
|
903
|
|
|
904
|
```bash |
|
905
|
# Run once: mcloud use --organization org_123 --project proj_123 --environment env_123 |
|
906
|
|
|
907
|
mcloud variables delete API_KEY --yes |
|
908
|
``` |
|
909
|
|
|
910
|
</CodeTab> |
|
911
|
</CodeTabs> |
|
912
|
|
|
913
|
Without `--yes`, the CLI prompts you to confirm the deletion. In a non-interactive environment (such as a CI pipeline), you must pass `--yes`, otherwise the command errors out. |
|
914
|
|
|
915
|
### Redeploy or Rebuild to Apply Changes |
|
916
|
|
|
917
|
Like setting a variable, deleting one doesn't rebuild or redeploy your application. Redeploy the environment with [`mcloud environments redeploy`](../environments/page.mdx#environments-redeploy), or start a new build with [`mcloud environments trigger-build`](../environments/page.mdx#environments-trigger-build) if the variable was a build variable, for the change to take effect. |
|
918
|
|
|
919
|
### Arguments |
|
920
|
|
|
921
|
<Table> |
|
922
|
<Table.Header> |
|
923
|
<Table.Row> |
|
924
|
<Table.HeaderCell> |
|
925
|
Option |
|
926
|
</Table.HeaderCell> |
|
927
|
<Table.HeaderCell> |
|
928
|
Description |
|
929
|
</Table.HeaderCell> |
|
930
|
<Table.HeaderCell> |
|
931
|
Required |
|
932
|
</Table.HeaderCell> |
|
933
|
</Table.Row> |
|
934
|
</Table.Header> |
|
935
|
<Table.Body> |
|
936
|
<Table.Row> |
|
937
|
<Table.Cell> |
|
938
|
|
|
939
|
`variable` |
|
940
|
|
|
941
|
</Table.Cell> |
|
942
|
<Table.Cell> |
|
943
|
|
|
944
|
Variable ID (`var_...`) or key to delete. When passing a key, you must also provide `--project` and `--environment` (or set them in the [active context](../use/page.mdx)). |
|
945
|
|
|
946
|
</Table.Cell> |
|
947
|
<Table.Cell> |
|
948
|
|
|
949
|
Yes |
|
950
|
|
|
951
|
</Table.Cell> |
|
952
|
</Table.Row> |
|
953
|
</Table.Body> |
|
954
|
</Table> |
|
955
|
|
|
956
|
### Options |
|
957
|
|
|
958
|
<Table> |
|
959
|
<Table.Header> |
|
960
|
<Table.Row> |
|
961
|
<Table.HeaderCell> |
|
962
|
Option |
|
963
|
</Table.HeaderCell> |
|
964
|
<Table.HeaderCell> |
|
965
|
Description |
|
966
|
</Table.HeaderCell> |
|
967
|
<Table.HeaderCell> |
|
968
|
Required |
|
969
|
</Table.HeaderCell> |
|
970
|
<Table.HeaderCell> |
|
971
|
Default |
|
972
|
</Table.HeaderCell> |
|
973
|
</Table.Row> |
|
974
|
</Table.Header> |
|
975
|
<Table.Body> |
|
976
|
<Table.Row> |
|
977
|
<Table.Cell> |
|
978
|
|
|
979
|
`-o <id>`, `--organization <id>` |
|
980
|
|
|
981
|
</Table.Cell> |
|
982
|
<Table.Cell> |
|
983
|
|
|
984
|
The [ID of the organization](../organizations/page.mdx#find-organization-id) that the variable belongs to. |
|
985
|
|
|
986
|
</Table.Cell> |
|
987
|
<Table.Cell> |
|
988
|
|
|
989
|
Yes |
|
990
|
|
|
991
|
</Table.Cell> |
|
992
|
<Table.Cell> |
|
993
|
|
|
994
|
Falls back to the organization in the [active context](../use/page.mdx), if set. |
|
995
|
|
|
996
|
</Table.Cell> |
|
997
|
</Table.Row> |
|
998
|
<Table.Row> |
|
999
|
<Table.Cell> |
|
1000
|
|
|
1001
|
`-p <id-or-handle>`, `--project <id-or-handle>` |
|
1002
|
|
|
1003
|
</Table.Cell> |
|
1004
|
<Table.Cell> |
|
1005
|
|
|
1006
|
The [ID or handle of the project](../projects/page.mdx#find-project-ids-and-handles) that the variable belongs to. Required when deleting by key. |
|
1007
|
|
|
1008
|
</Table.Cell> |
|
1009
|
<Table.Cell> |
|
1010
|
|
|
1011
|
Conditional |
|
1012
|
|
|
1013
|
</Table.Cell> |
|
1014
|
<Table.Cell> |
|
1015
|
|
|
1016
|
Falls back to the project in the [active context](../use/page.mdx), if set. |
|
1017
|
|
|
1018
|
</Table.Cell> |
|
1019
|
</Table.Row> |
|
1020
|
<Table.Row> |
|
1021
|
<Table.Cell> |
|
1022
|
|
|
1023
|
`-e <handle>`, `--environment <handle>` |
|
1024
|
|
|
1025
|
</Table.Cell> |
|
1026
|
<Table.Cell> |
|
1027
|
|
|
1028
|
The [handle of the environment](../environments/page.mdx#find-environment-handles) that the variable belongs to. Required when deleting by key. |
|
1029
|
|
|
1030
|
</Table.Cell> |
|
1031
|
<Table.Cell> |
|
1032
|
|
|
1033
|
Conditional |
|
1034
|
|
|
1035
|
</Table.Cell> |
|
1036
|
<Table.Cell> |
|
1037
|
|
|
1038
|
Falls back to the environment in the [active context](../use/page.mdx), if set. |
|
1039
|
|
|
1040
|
</Table.Cell> |
|
1041
|
</Table.Row> |
|
1042
|
<Table.Row> |
|
1043
|
<Table.Cell> |
|
1044
|
|
|
1045
|
`-t <type>`, `--type <type>` |
|
1046
|
|
|
1047
|
</Table.Cell> |
|
1048
|
<Table.Cell> |
|
1049
|
|
|
1050
|
The type of variable to delete. Accepts `backend` or `storefront`. |
|
1051
|
|
|
1052
|
</Table.Cell> |
|
1053
|
<Table.Cell> |
|
1054
|
|
|
1055
|
No |
|
1056
|
|
|
1057
|
</Table.Cell> |
|
1058
|
<Table.Cell> |
|
1059
|
|
|
1060
|
`backend` |
|
1061
|
|
|
1062
|
</Table.Cell> |
|
1063
|
</Table.Row> |
|
1064
|
<Table.Row> |
|
1065
|
<Table.Cell> |
|
1066
|
|
|
1067
|
`-y`, `--yes` |
|
1068
|
|
|
1069
|
</Table.Cell> |
|
1070
|
<Table.Cell> |
|
1071
|
|
|
1072
|
Skip the confirmation prompt and delete the variable. Required in non-interactive environments. |
|
1073
|
|
|
1074
|
</Table.Cell> |
|
1075
|
<Table.Cell> |
|
1076
|
|
|
1077
|
No |
|
1078
|
|
|
1079
|
</Table.Cell> |
|
1080
|
<Table.Cell> |
|
1081
|
|
|
1082
|
`false` |
|
1083
|
|
|
1084
|
</Table.Cell> |
|
1085
|
</Table.Row> |
|
1086
|
<Table.Row> |
|
1087
|
<Table.Cell> |
|
1088
|
|
|
1089
|
`--json` |
|
1090
|
|
|
1091
|
</Table.Cell> |
|
1092
|
<Table.Cell> |
|
1093
|
|
|
1094
|
Print the result as JSON instead of formatted text. |
|
1095
|
|
|
1096
|
</Table.Cell> |
|
1097
|
<Table.Cell> |
|
1098
|
|
|
1099
|
No |
|
1100
|
|
|
1101
|
</Table.Cell> |
|
1102
|
<Table.Cell> |
|
1103
|
|
|
1104
|
`false` |
|
1105
|
|
|
1106
|
</Table.Cell> |
|
1107
|
</Table.Row> |
|
1108
|
</Table.Body> |
|
1109
|
</Table> |
|
1110
|
|
|
1111
|
--- |
|
1112
|
|
|
1113
|
## Reveal Secret Values |
|
1114
|
|
|
1115
|
By default, the CLI masks values for variables marked as secrets. Pass `--reveal` to print the plaintext value: |
|
1116
|
|
|
1117
|
<Note type="warning"> |
|
1118
|
|
|
1119
|
Avoid `--reveal` on shared terminals or in shell history. The plaintext value is printed to standard output, which is captured by terminal scrollback, log aggregators, and process listings. |
|
1120
|
|
|
1121
|
</Note> |
|
1122
|
|
|
1123
|
```bash |
|
1124
|
mcloud variables get DATABASE_URL --reveal |
|
1125
|
``` |
|
1126
|
|
|
1127
|
--- |
|
1128
|
|
|
1129
|
## Export Variables to a `.env` File |
|
1130
|
|
|
1131
|
Use the `--dotenv` flag with `--reveal` to output the variables in `.env` file format, then write them to a local `.env` file. This is useful for replicating a Cloud environment's variables to a local development environment: |
|
1132
|
|
|
1133
|
```bash |
|
1134
|
mcloud variables list --reveal --dotenv > .env |
|
1135
|
``` |
|
1136
|
|
|
1137
|
<Note type="warning"> |
|
1138
|
|
|
1139
|
`--reveal` prints secret values in plain text. Avoid running this on shared terminals or storing the resulting `.env` file in version control. |
|
1140
|
|
|
1141
|
</Note> |