Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Terraform Couchbase Capella Provider: Deploy, update and manage Couchbase Capella resources as code through HashiCorp Terraform

License

Notifications You must be signed in to change notification settings

couchbasecloud/terraform-provider-couchbasecapella

Repository files navigation

⛔ [UNSUPPORTED]: This repository is no longer maintained by Couchbase. Please refer to https://github.com/couchbasecloud/terraform-provider-couchbase-capella for latest supported version of Capella Terraform Provider


Couchbase Capella Provider

This is the repository for the Terraform Couchbase Capella Provider which allows you to use Terraform with Couchbase Capella.

Requirements

Using the provider

Configuring Programmatic Access

In order to set up authentication with the Couchbase Capella provider a programmatic API key must be generated. Instructions to generate your API key can be found in the Couchbase Capella Public API documentation.

Authenticating the Provider

You will need to provide your credentials for authentication via the environment variables, CBC_ACCESS_KEY and CBC_SECRET_KEY, for your access and secret API Key Pair respectively.

Usage (prefix the export commands with a space to avoid the keys being recorded in OS history):

$  export CBC_ACCESS_KEY="xxxx"
$  export CBC_SECRET_KEY="xxxx"

Example Usage

# Pull Couchbase Capella Provider from Terraform Registry
terraform {
  required_providers {
    couchbasecapella = {
      source  = "couchbasecloud/couchbasecapella"
      version = "<version>"
    }
  }
}

# Configure the Couchbase Capella Provider
provider "couchbasecapella" {}

# Create example project resource
resource "couchbasecapella_project" "project" {
  name = "project1"
}

1. Initialise the Terraform provider

Execute the following command to initialise the terraform provider.

$ terraform init

2. Review the Terraform plan

Execute the following command to review the resources that will be deployed.

$ terraform plan

3. Execute the Terraform apply

Execute the plan to deploy the Couchbase Capella resources.

$ terraform apply

4. Destroy the resources

Execute the following command to destroy the resources so you avoid unnecessary charges.

$ terraform destroy

Getting Started

Please also visit the get_started directory for an example configuration for provisioning a project, cluster, bucket and database user.

Developing the Provider

If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above). You will also need to have access to a Couchbase Capella account.

Building The Provider

  1. Clone the repository
  2. Enter the repository directory
  3. Build the provider using the Go build command:
$ make build

After the provider has been built locally it must be placed in the user plugins directory so it can be discovered by the Terraform CLI. Please execute the following command to move the provider binary to this directory:

$ make install

The terraform provider is installed and can now be discovered by Terraform through the following HCL block.

terraform {
  required_providers {
    couchbasecapella = {
      source  = "github.com/couchbasecloud/couchbasecapella"
      version = "0.1.0"
    }
  }
}

Testing the Provider

Configuring the environment variables

You must also configure the following environment variables before running the tests:

export CBC_AWS_CLOUD_ID=<YOUR_CLOUD_ID>
export CBC_AZURE_CLOUD_ID=<YOUR_CLOUD_ID>
export CBC_PROJECT_ID=<YOUR_PROJECT_ID>
export CBC_CLUSTER_ID=<YOUR_CLUSTER_ID>
export CBC_CLUSTER_CIDR=<YOUR_CLUSTER_CIDR>
export CBC_BUCKET_NAME=<YOUR_BUCKET_NAME>

In order to run the full suite of Acceptance tests, you will need to have a deployed in-vpc cluster available in AWS and Azure so that you can configure a cluster ID in the environment variables. You will also need to have a bucket created in that cluster so you can configure CBC_BUCKET_NAME. To run the tests, run make testacc.

$ make testacc

Note: Running all tests will take approximately 1 hour to complete.

To run individual tests, run the following command:

go test -v -timeout 60m -run ^NameOfTestFunction$ github.com/couchbasecloud/terraform-provider-couchbasecapella/provider

Note: Acceptance tests create real resources, and often cost money to run.

About

Terraform Couchbase Capella Provider: Deploy, update and manage Couchbase Capella resources as code through HashiCorp Terraform

Resources

License

Stars

Watchers

Forks

Packages

No packages published