DEV Community

Cover image for Storing Pulumi State on IPFS with Filebase
K for Fullstack Frontend

Posted on

Storing Pulumi State on IPFS with Filebase

I played around with my favourite infrastructure tool Pulumi and asked myself if I could use IPFS as storage backend the deployment state of my projects.

Pulumi is open source and allows to self-host your storage backend. Could be interesting to have your state publicly available on IPFS, and since the state doesn't include the deployment credentials it wouldn't leak anything critical.

Filebase is a file hosting provider which offers a Amazon S3 compatible API to store files that are then pinned to IPFS. Since Pulumi comes out-of-the-box with a S3 connector, I gave it a try.

Prerequistes

A Filebase account. It comes with a free tier that doesn't require a credit card.

A Node.js installation.

Setup

First, we create a S3 bucket on Filebase. Hop on the Filebase Console, click on "Create Bucket", name it "deployments", chose IPFS, and hit "Create Bucket".

Next, get the Filebase credentials here. We will need them later.

Then install Pulumi:

$ curl -fsSL https://get.pulumi.com | sh
Enter fullscreen mode Exit fullscreen mode

This might require a restart of the terminal so the pulumi command works.

And finally logging into the Filebase S3 bucket with Pulumi, but replace the keys.

$ export AWS_REGION='us-east-1' && \
  export AWS_ACCESS_KEY_ID='<FILEBASE_KEY>' && \
  export AWS_SECRET_ACCESS_KEY='<FILEBASE_SECRET>' && \
  pulumi login 's3://deployments?endpoint=s3.filebase.com&s3ForcePathStyle=true'
Enter fullscreen mode Exit fullscreen mode

Aaaand we're good to go.

Testing Everything

Let's create a Pulumi project. This will automatically upload a empty state to Filebase.

$ mkdir my-project && cd my-project
$ pulumi new aws-typescript
Enter fullscreen mode Exit fullscreen mode

After this, we can find the state in dev.json in the bucket we created here. This page will also show the "IPFS Gateway URL" with the CID of our file, so we can open it in the browser.

Top comments (0)