This is the repository for the Terraform Couchbase Capella Provider which allows you to use Terraform with Couchbase Capella.
- Clone the repository
- Enter the repository directory
- Build the provider using the Go
build
command:
$ go 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:
$ mv terraform-provider-couchbasecapella ~/.terraform.d/plugins/terraform.couchbase.com/local/couchbasecapella/1.0.0/<OS_ARCH>
The terraform provider is installed and can now be discovered by Terraform through the following HCL block.
terraform {
required_providers {
couchbasecapella = {
source = "terraform.couchbase.com/local/couchbasecapella"
version = "1.0.0"
}
}
}
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.
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"
$ terraform plan
#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
Please also visit the get_started
directory for an example configuration for provisioning a project, cluster, bucket and database user.
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.
You must also configure the following environment variables before running the tests:
export CBC_CLOUD_ID=<YOUR_CLOUD_ID>
export CBC_PROJECT_ID=<YOUR_PROJECT_ID>
export CBC_CLUSTER_ID=<YOUR_CLUSTER_ID>
In order to run the full suite of Acceptance tests, run make testacc
.
Note: Acceptance tests create real resources, and often cost money to run.
$ make testacc