Creating a repo on S3
To really make Sprout work for your team, you’ll probably want to store your content somewhere central. Amazon S3 (or other S3 compatible services) can be a great choice. Let’s set up a new repo on S3!
1. Create the repo definition
Let’s create a new repo definition. Let’s call it something unique, like my-s3-repo
…
Sprout will now fire up an editor, allowing you to modify the repo definition. As we’re going to use S3, we need to use opendal:s3
as our repository
, and set some other options:
Make sure to save and exit the editor when you’re done.
2. Initialise the repo
Now initialise the repo by running:
Let Sprout create and set a repo key for you. This is your encryption key for your repo, not your S3 access key. They should be unique.
If all goes well, you should see success.
3. Test!
Now everything is set up, let’s push a snapshot.
Switch to an existing Sprout project (or initialise a new one with sprout init
), then edit the sprout.yaml
file to point to our new repo definition.
It’s also a good idea to clear the snapshot
ID field too when changing repo:
Now we are ready to snapshot. Let’s run:
The initial snapshot should complete - it may take a little while. There is no parent present, so the first snapshot will need to upload all of your content. Subsequent snapshots will be faster.
Let’s check and see if we can see the snapshot in our repo. List the snapshots by running:
You should see your new snapshot! That’s all there is to it.
4. Sharing your repo definition
When using a remote storage backend for a repo, we often want to share our repo definitions with the rest of our team. All your repo definitions exist at ~/.sprout/repos
.
It’s not a good idea to send our S3 access keys and secrets around as part of the definition, so you should replace any sensitive keys with an environment variable. For example: