carlos / carloku Public

Clone
git clone https://amadan.net/carlos/carloku

Plain git — no account needed to clone.

Download

Download this file

1# Object storage
2
3Uploads, generated files, anything your app wants to still have next week —
4none of it belongs on the box's local disk, because the process that wrote
5it there is not guaranteed to be the one serving your next request. Each app
6can have a bucket of its own instead, and the credentials for it arrive in
7your process as environment variables.
8
9```sh
10carlos store create -app hello
11```
12
13That records the request and nothing more. No bucket exists yet: creating
14declares that the app wants one, and provisioning is a step on the Carloku
15side. `carlos store status` is where you watch for it landing.
16
17## What your app ends up with
18
19Five variables under a prefix, `CARLOS_STORE` unless you name another:
20`CARLOS_STORE_BUCKET`, `_REGION`, `_ACCESS_KEY` and `_SECRET_KEY`, plus
21`_ENDPOINT` where the backend has one. Your app reads them like any other
22config and talks to the bucket directly, with whichever S3 client its
23language already has. Nothing proxies that traffic.
24
25The bucket, region and endpoint are ordinary values — `carlos env list` will
26show them to you. The two keys are delivered through the sealed store, so
27they reach your process and stop being readable to anyone, including you.
28[Env and secrets](/docs/config/) explains why that is one-way.
29
30If your app already expects a particular set of names, say so at create
31time and skip the adapter code:
32
33```sh
34carlos store create -app hello -env-prefix BLOBS
35```
36
37## Watching it arrive
38
39```sh
40carlos store status -app hello
41```
42
43You get what you declared, what was granted, and what was provisioned —
44bucket, region, the user the credential belongs to, and the key id currently
45in use. Two of its lines are worth knowing before you meet them. One says a
46delivered variable has not reached your app's config yet. That is the
47ordinary state for a few seconds after any change, and a problem only if it
48persists. The other says a rotation was started and never finished.
49
50## Rotating the key
51
52```sh
53carlos store rotate -app hello
54```
55
56A fresh credential is minted and delivered, and the previous one keeps
57working. Your app picks the new values up the way it picks up any config
58change: the box rewrites the environment for the app's routes and cycles the
59process, within seconds. Leaving the old key alive is the point of doing it
60in two halves — an upload that started under it gets to finish, and a second
61instance that has not converged yet keeps serving.
62
63Close the window when you are satisfied nothing is still using it:
64
65```sh
66carlos store rotate -finish -app hello
67```
68
69Until you do, `status` keeps telling you a rotation is pending.
70
71One habit worth forming. The secret never appears at your terminal — rotate
72prints the new key's id and that is the whole of what you see — so if the
73value ever turns up somewhere it shouldn't, it came out of the app. Whatever
74your app dumps at startup is the first place to look.
75
76[carlos store](https://carlosframework.com/docs/cli/#carlos-store) has the
77sub-verbs and the rest of their flags.
78