0.2.6 • Published 4 years ago

@triangularcube/fauna-pulumi-provider v0.2.6

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Faunadb Dynamic Provider for Pulumi

Experimental FaunaDB Dynamic Provider for Pulumi. The goal of this library is to provide a simple way to provision and maintain resources in FaunaDB, using Typescript/Javascript, with Pulumi.

How to use

First, you need to install the Pulumi CLI in your system. This CLI will be needed to create any resources. Please refer to this link.

You can install this library using npm:

npm install faunadb-pulumi-provider

After installation, you will need to configure access to FaunaDB using an access token.

Note: As currently this project only supports the creation of Collections and Indexes, only a Server Access Key is required. As more features are implemented an Admin Key may be needed to configure roles.

This library will look for the key in the environment variable FAUNA_ADMIN_KEY. Once Pulumi starts supporting stack configurations in dynamic providers, this library will fallback to a key in the stack configuration.

API

Collections:

import { Collection, query as q } from 'faunadb-pulumi-provider'

const collection = new Collection('myCollection', {
  // All fields optional

  name: 'myCollection', // inferred from logical name if missing
  history_days: 30,
  ttl_days: null,
  data: {
    description: 'This is an arbitrary object'
  }
})

export const collectionName = collection.name
export const collectionTs = collection.ts
export const collectionHistoryDays = collection.history_days
export const collectionTtlDays = collection.ttl_days

Indexes:

import { Index } from 'faunadb-pulumi-provider'

const index = new Index('myIndex', {
  // Required
  source: myCollection.name

  // Optional
  name: 'my-index' // inferred from logical name if missing
  terms: [
    {
      binding: 'my-binding-name'
    },
    // And / Or
    {
      field: ['data', 'my-field']
    }
  ],
  values: [
    {
      binding: 'my-binding-name'
    },
    // And / Or
    {
      field: ['data', 'my-field']
    }
  ],
  unique: true, // Defaults to false
  serialized: false, // Defaults to true
  data: {
    description: 'This is an arbitrary object'
  }
})

export const indexTs = index.ts
export const indexPartitions = index.partitions

source is the only field to significantly deviate from faunadb. Since wrapping names into Refs are trivial, this library has opted to use names instead. So source will take

{
  source: 'name-string'
}

// Or
import { query as q } from 'faunadb-pulumi-provider'
{
  source: [
    {
      collection: 'collection-name',
      
      // and optionally
      fields: {
        binding1: q.Query(
          q.Lambda(
            ...
          )
        )
        binding2: ...
      }
    }
  ]
}

TODOs

  • Functions
  • Roles
  • Documents
  • Tokens
  • Better input validation
  • Better typing for FQL expressions instead of the generic EXPR
  • Deep object comparison for non-primative input fields
0.2.6

4 years ago

0.2.5

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.4

4 years ago

0.2.1

4 years ago