Connect a bucket to a service
Give a service six variables that point at a bucket, so its code reaches the bucket without copying keys.
All pages
- Open a web service in the console, press ⌘K and choose Settings › Connect a bucket. Pick a bucket, and the connection waits as a staged change.
Every bucket in the workspace is listed with its site. You need a bucket first.
A connection belongs to the environment you are in. Connect the bucket in each environment that needs it.
- Press ⌘K, choose Review changes, then press ⌘↵ to apply it.
Applying it deploys the service, and its code sees the bucket.
From the CLI, ghaym cloud buckets connect <bucket> <service> stages the connection in the environment --env names, and --apply applies it.
A connection stages six variables on the service, each a reference to the bucket's own (${{bucket:<name>.S3_*}}):
| Variable | Value |
|---|---|
S3_ENDPOINT | http://s3, the in-project endpoint |
S3_PUBLIC_ENDPOINT | the bucket's public endpoint, for presigning and public reads |
S3_BUCKET | the bucket's name |
S3_ACCESS_KEY_ID | the access key ID |
S3_SECRET_ACCESS_KEY | the secret access key |
S3_REGION | the country code, such as jo |
You can rename or delete them.
A bucket connects only to a service in its own site. A connect across sites is refused, and nothing is staged.
A service's first bucket takes the bare names. When the six names are taken on the service, the console asks you to give the next bucket a prefix. The prefix leads every name: MEDIA_S3_BUCKET. It starts with a capital, then capitals, digits and underscores, at most 21 characters.
The variables point at the bucket instead of copying its keys. After someone rotates the keys, the old pair keeps working until the connected services are redeployed, for a day at most, and the bucket's page names the services still using it. Redeploy them to give them the new pair.
Press ⌘K on the service, choose Settings › Disconnect a bucket and pick the bucket. The disconnection is staged too. The service loses every variable in this environment that references the bucket, renamed ones too, once the changes are applied. Nothing in the bucket is deleted.