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.

Connect a bucket

  1. 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.

  2. 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_*}}):

VariableValue
S3_ENDPOINThttp://s3, the in-project endpoint
S3_PUBLIC_ENDPOINTthe bucket's public endpoint, for presigning and public reads
S3_BUCKETthe bucket's name
S3_ACCESS_KEY_IDthe access key ID
S3_SECRET_ACCESS_KEYthe secret access key
S3_REGIONthe 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.

Connect a second bucket

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.

When the keys rotate

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.

Disconnect it

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.