Browse the Repo

file-type-icon.circleci
file-type-icon_docs
file-type-iconexamples
file-type-iconcouchbase-ami
file-type-iconREADME.md
file-type-iconcouchbase.json
file-type-iconsync_gateway.json
file-type-iconcouchbase-cluster-mds
file-type-iconcouchbase-cluster-simple-dns-tls
file-type-iconcouchbase-cluster-simple
file-type-iconcouchbase-multi-datacenter-replication
file-type-iconlocal-mocks
file-type-iconmodules
file-type-icontest
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-icon.pre-commit-hooks.yaml
file-type-iconCODEOWNERS
file-type-iconCONTRIBUTING.md
file-type-iconLICENSE
file-type-iconNOTICE
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.tf

Browse the Repo

file-type-icon.circleci
file-type-icon_docs
file-type-iconexamples
file-type-iconcouchbase-ami
file-type-iconREADME.md
file-type-iconcouchbase.json
file-type-iconsync_gateway.json
file-type-iconcouchbase-cluster-mds
file-type-iconcouchbase-cluster-simple-dns-tls
file-type-iconcouchbase-cluster-simple
file-type-iconcouchbase-multi-datacenter-replication
file-type-iconlocal-mocks
file-type-iconmodules
file-type-icontest
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-icon.pre-commit-hooks.yaml
file-type-iconCODEOWNERS
file-type-iconCONTRIBUTING.md
file-type-iconLICENSE
file-type-iconNOTICE
file-type-iconREADME.md
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.tf
Couchbase

Couchbase

Deploy a Couchbase cluster. Supports automatic bootstrapping, Sync Gateway, Web Console UI, cross-region replication, and auto healing.

Code Preview

Preview the Code

mobile file icon

README.md

down

Couchbase AMI

This folder shows an example of how to use the install-couchbase-server and install-sync-gateway modules with Packer to create Amazon Machine Images (AMIs) that have Couchbase, Sync Gateway, and their dependencies installed on top of:

  1. Ubuntu 16.04
  2. Amazon Linux 2

Quick start

To build the Couchbase AMI:

  1. git clone this repo to your computer.
  2. Install Packer.
  3. Configure your AWS credentials using one of the options supported by the AWS SDK. Usually, the easiest option is to set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.
  4. Update the variables section of the couchbase.json Packer template to specify the AWS region and Couchbase version you wish to use.
  5. To build an Ubuntu AMI for Couchbase Enterprise: packer build -only=ubuntu-ami -var edition=enterprise couchbase.json.
  6. To build an Ubuntu AMI for Couchbase Community: packer build -only=ubuntu-ami -var edition=community couchbase.json.
  7. To build an Amazon Linux AMI for Couchbase Enterprise: packer build -only=amazon-linux-ami -var edition=enterprise couchbase.json.
  8. To build an Amazon Linux AMI for Couchbase Community: packer build -only=amazon-linux-ami -var edition=community couchbase.json.

When the build finishes, it will output the IDs of the new AMIs. To see how to deploy this AMI, check out the couchbase-cluster-simple, couchbase-cluster-mds, and couchbase-multi-datacenter-replication examples.

Creating your own Packer template for production usage

When creating your own Packer template for production usage, you can copy the example in this folder more or less exactly, except for one change: we recommend replacing the file provisioner with a call to git clone in a shell provisioner. Instead of:

{
  "provisioners": [{
    "type": "file",
    "source": "{{template_dir}}/../../../terraform-aws-couchbase",
    "destination": "/tmp"
  },{
    "type": "shell",
    "inline": [
      "/tmp/terraform-aws-couchbase/modules/install-couchbase-server/install-couchbase-server --version {{user `couchbase_version`}}",
      "/tmp/terraform-aws-couchbase/modules/install-sync-gateway/install-sync-gateway"
    ],
    "pause_before": "30s"
  }]
}

Your code should look more like this:

{
  "provisioners": [{
    "type": "shell",
    "inline": [
      "git clone --branch <MODULE_VERSION> https://github.com/gruntwork-io/terraform-aws-couchbase.git /tmp/terraform-aws-couchbase",
      "/tmp/terraform-aws-couchbase/modules/install-couchbase-server/install-couchbase-server --version {{user `couchbase_version`}}",
      "/tmp/terraform-aws-couchbase/modules/install-sync-gateway/install-sync-gateway"
    ],
    "pause_before": "30s"
  }]
}

You should replace <MODULE_VERSION> in the code above with the version of this module that you want to use (see the Releases Page for all available versions). That's because for production usage, you should always use a fixed, known version of this Module, downloaded from the official Git repo via git clone. On the other hand, when you're just experimenting with the Module, it's OK to use a local checkout of the Module, uploaded from your own computer via the file provisioner.

Local testing

The Packer template in this example folder can build not only AMIs, but also Docker images for local testing. This is convenient for testing out the various scripts in the modules folder without having to wait for an AMI to build and a bunch of EC2 Instances to boot up. See the local-mocks folder for instructions.

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?