Skip to content

lukasbudisky/terraform-provider-couchbase

Repository files navigation

Terraform provider for couchbase

GitHub release (with filter) GitHub Workflow Status (with event) GitHub all releases GitHub contributors GitHub Repo stars

Terraform provider for Couchbase allow manage resources in couchbase cluster

Requirements

  • terraform 1.7.4
  • go 1.22.1 (for plugin build)
  • docker-compose v2.24.6-desktop.1
  • docker desktop 4.28.0

Run couchbase on localhost

In terraform_example folder is docker-compose.yml with couchbase server.

How to run couchbase on localhost. (Works on Ubuntu)

# Add couchbase to your /etc/hosts file
echo "127.0.0.1 couchbase" >> /etc/hosts

# Create couchbase network
make cbnetup

# Create couchbase
make cbup

# Couchbase initialization
make cbinit

How to destroy local infrastructure

# Destroy couchbase
make cbdown

# Destroy couchbase network
make cbnetdown

Provider

WARNING

If you create multiple query indexes at once you can get internal server failure error because you can't create next index until previous is created.

Suggested solution is to reduce parallelism. Add -parallelism=1 parameter during terraform apply

Example:

terraform apply -parallelism=1

Base provider configuration

terraform {
  required_version = ">= 1.7.4"
  required_providers {
    couchbase = {
      version = "~> 1.1.1"
      source  = "lukasbudisky/couchbase"
    }
  }
}

provider "couchbase" {
  address                   = "couchbase.couchbase"
  client_port               = 8091
  node_port                 = 11210
  username                  = "Administrator"
  password                  = "123456"
  management_timeout        = 10
  tls_root_cert_skip_verify = false
}

TLS provider configuration

terraform {
  required_version = ">= 1.7.4"
  required_providers {
    couchbase = {
      version = "~> 1.1.1"
      source  = "lukasbudisky/couchbase"
    }
  }
}

provider "couchbase" {
  address                   = "couchbase.couchbase"
  client_port               = 18091
  node_port                 = 11207
  username                  = "Administrator"
  password                  = "123456"
  management_timeout        = 10
  tls_root_cert_skip_verify = true
  tls_root_cert             = "certificate.pem"
  allow_sasl_mechanism      = "SCRAM-SHA1,SCRAM-SHA256,SCRAM-SHA512"
}

Resources

We currently manage these operations via terraform resources

  • buckets: couchbase_bucket_manager
  • groups: couchbase_security_group
  • users: couchbase_security_user
  • primary: query indexes couchbase_primary_query_index
  • query indexes: couchbase_query_index

Developing provider

Provider tests

make test

Acceptance tests

make testacc

Build provider

make build

Install provider

make install