- Cloudflare Account with Workers Paid Plan.
wrangler
CLI installed and configured.
-
Fork this repository and clone it to your local machine.
-
Create a Cloudflare R2 Bucket and D1 Database and update the
wrangler.toml
with appropriate values. -
Run all the migrations in the migrations folder against the D1 Database.
-
Run
wrangler publish
to create the Worker. -
For each of the following environment variables, create a secret using
wrangler secret put
command.
Key | Value |
---|---|
INIT_PASSWORD |
Token for creating the first user |
TOKEN_SALT |
Secure value which is used to salt API tokens |
-
Make a POST request to the
/api/init
endpoint using Bearer Auth with theINIT_PASSWORD
as the token and a JSON body of `{"username": "", "password": ""}. This will create the first admin user. The init endpoint can only be used while there is no other users. -
Make a POST request to the
/api/token
endpoint using Basic Auth with the username and password of the user you just created. This will return a token which can be used to authenticate future requests. -
Make a POST request to the
/api/user
endpoint using Bearer Auth with the token you just received and a JSON body of{"username": "", "password": ""}
. This will create a new user. -
You can now configure your Terraform projects to use this API to store state files. See the example and the http backend docs for more details.