Terraform provider for SQLite database engine

Terraform provider for SQLite database engine

!!! WARNING !!!
This is an educational project. Not intended for any production use!
!!! WARNING !!!

Here is my first implemetation of SQLite plugin (provider) for Terraform.

There's no many docs and tests yet. The code is intended for local development and use for now.

Plugin was tested on MacOS X, but should work on any other platform as well.

Prequisites:

  • Go >= 1.16
  • Terraform >= 1.0

Provider supports:

  • Creating database tables with basic constraints like NOT NULL, PRIMARY KEY and DEFAULT
  • Creating database basic indexes

Provider does not support:

  • Table/index schema upgrades (in case of schema changes resources will be recreated)
  • Resources import

Known issues:

  • If you delete/recreate table having any indexes on it, provider will not automatically recreate indexes; it will be recreated on the next run of terraform apply

How to build

  1. Clone repository and make Go download dependencies
    git clone https://github.com/Burmuley/terraform-provider-sqlite
    cd terraform-provider-sqlite
    go get
  2. Run script build.sh to build and install provider to the Terraform local cache, or run these commands to achieve the same
    go build -o terraform-provider-sqlite
    mkdir -p ~/.terraform.d/plugins/burmuley.com/edu/sqlite/0.1/darwin_amd64
    mv terraform-provider-sqlite ~/.terraform.d/plugins/burmuley.com/edu/sqlite/0.1/darwin_amd64

How to use

And example code is located in the example directory.

cd example
terraform init

Then Terraform should find local provider and successfully initialize the local module.

Initializing the backend...

Initializing provider plugins...
- Reusing previous version of burmuley.com/edu/sqlite from the dependency lock file
- Installing burmuley.com/edu/sqlite v0.1.0...
- Installed burmuley.com/edu/sqlite v0.1.0 (unauthenticated)

Terraform has been successfully initialized!

Simply run the apply command and confirm you want to provision "the infrastructure". :)

terraform apply
Terraform will perform the following actions:

  # sqlite_index.test_index1 will be created
  + resource "sqlite_index" "test_index1" {
      + columns = [
          + "id",
          + "name",
        ]
      + created = (known after apply)
      + id      = (known after apply)
      + name    = "users_index"
      + table   = "users"
    }

  # sqlite_table.test_table will be created
  + resource "sqlite_table" "test_table" {
      + created = (known after apply)
      + id      = (known after apply)
      + name    = "users"

      + column {
          + name = "id"
          + type = "INTEGER"

          + constraints {
              + not_null    = true
              + primary_key = true
            }
        }
      + column {
          + name = "name"
          + type = "TEXT"

          + constraints {
              + not_null    = true
              + primary_key = false
            }
        }
      + column {
          + name = "last_name"
          + type = "TEXT"

          + constraints {
              + not_null    = true
              + primary_key = false
            }
        }
      + column {
          + name = "password"
          + type = "TEXT"

          + constraints {
              + default     = "123"
              + not_null    = true
              + primary_key = false
            }
        }
    }

  # sqlite_table.test_table2 will be created
  + resource "sqlite_table" "test_table2" {
      + created = (known after apply)
      + id      = (known after apply)
      + name    = "projects"

      + column {
          + name = "id"
          + type = "INTEGER"

          + constraints {
              + not_null    = true
              + primary_key = true
            }
        }
      + column {
          + name = "user"
          + type = "INTEGER"

          + constraints {
              + not_null    = true
              + primary_key = false
            }
        }
      + column {
          + name = "name"
          + type = "TEXT"

          + constraints {
              + not_null    = true
              + primary_key = false
            }
        }
    }

Plan: 3 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

sqlite_table.test_table2: Creating...
sqlite_table.test_table: Creating...
sqlite_table.test_table2: Creation complete after 0s [id=projects]
sqlite_table.test_table: Creation complete after 0s [id=users]
sqlite_index.test_index1: Creating...
sqlite_index.test_index1: Creation complete after 0s [id=users_index]

Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
Owner
Konstantin Vasilev
DevOps, Cloud Engineer, Golang beginner
Konstantin Vasilev
Similar Resources

A GPU-powered real-time analytics storage and query engine.

A GPU-powered real-time analytics storage and query engine.

AresDB AresDB is a GPU-powered real-time analytics storage and query engine. It features low query latency, high data freshness and highly efficient i

Jan 7, 2023

An embedded key/value database for Go.

bbolt bbolt is a fork of Ben Johnson's Bolt key/value store. The purpose of this fork is to provide the Go community with an active maintenance and de

Jan 1, 2023

BuntDB is an embeddable, in-memory key/value database for Go with custom indexing and geospatial support

BuntDB is an embeddable, in-memory key/value database for Go with custom indexing and geospatial support

BuntDB is a low-level, in-memory, key/value store in pure Go. It persists to disk, is ACID compliant, and uses locking for multiple readers and a sing

Dec 30, 2022

CockroachDB - the open source, cloud-native distributed SQL database.

CockroachDB - the open source, cloud-native distributed SQL database.

CockroachDB is a cloud-native SQL database for building global, scalable cloud services that survive disasters. What is CockroachDB? Docs Quickstart C

Jan 2, 2023

ACID key-value database.

Coffer Simply ACID* key-value database. At the medium or even low latency it tries to provide greater throughput without losing the ACID properties of

Dec 7, 2022

A decentralized, trusted, high performance, SQL database with blockchain features

A decentralized, trusted, high performance, SQL database with blockchain features

中文简介 CovenantSQL(CQL) is a Byzantine Fault Tolerant relational database built on SQLite: ServerLess: Free, High Availabile, Auto Sync Database Service

Jan 3, 2023

Native GraphQL Database with graph backend

Native GraphQL Database with graph backend

The Only Native GraphQL Database With A Graph Backend. Dgraph is a horizontally scalable and distributed GraphQL database with a graph backend. It pro

Jan 4, 2023

EliasDB a graph-based database.

EliasDB a graph-based database.

EliasDB EliasDB is a graph-based database which aims to provide a lightweight solution for projects which want to store their data as a graph. Feature

Jan 4, 2023

LevelDB key/value database in Go.

This is an implementation of the LevelDB key/value database in the Go programming language. Installation go get github.com/syndtr/goleveldb/leveldb R

Jan 1, 2023
The lightweight, distributed relational database built on SQLite.
The lightweight, distributed relational database built on SQLite.

rqlite is a lightweight, distributed relational database, which uses SQLite as its storage engine. Forming a cluster is very straightforward, it grace

Jan 5, 2023
DonutDB: A SQL database implemented on DynamoDB and SQLite

DonutDB: A SQL database implemented on DynamoDB and SQLite

Dec 21, 2022
A SQLite-based hierarchical key-value store written in Go

camellia ?? A lightweight hierarchical key-value store camellia is a Go library that implements a simple, hierarchical, persistent key-value store, ba

Nov 9, 2022
Lightweight RESTful database engine based on stack data structures
Lightweight RESTful database engine based on stack data structures

piladb [pee-lah-dee-bee]. pila means stack or battery in Spanish. piladb is a lightweight RESTful database engine based on stack data structures. Crea

Nov 27, 2022
A MySQL-compatible relational database with a storage agnostic query engine. Implemented in pure Go.

go-mysql-server is a SQL engine which parses standard SQL (based on MySQL syntax) and executes queries on data sources of your choice. A simple in-memory database and table implementation are provided, and you can query any data source you want by implementing a few interfaces.

Dec 27, 2022
Fast Database engine in Go.

gaeadb gaeadb is a pure Go Database engine designed by nnsgmsone. The goal of the project is to provide a database engine for table or other complex d

Oct 14, 2022
Owl is a db manager platform,committed to standardizing the data, index in the database and operations to the database, to avoid risks and failures.

Owl is a db manager platform,committed to standardizing the data, index in the database and operations to the database, to avoid risks and failures. capabilities which owl provides include Process approval、sql Audit、sql execute and execute as crontab、data backup and recover .

Nov 9, 2022
Hard Disk Database based on a former database

Hard Disk Database based on a former database

Nov 1, 2021
Simple key value database that use json files to store the database

KValDB Simple key value database that use json files to store the database, the key and the respective value. This simple database have two gRPC metho

Nov 13, 2021
Beerus-DB: a database operation framework, currently only supports Mysql, Use [go-sql-driver/mysql] to do database connection and basic operations

Beerus-DB · Beerus-DB is a database operation framework, currently only supports Mysql, Use [go-sql-driver/mysql] to do database connection and basic

Oct 29, 2022