An open API service indexing awesome lists of open source software.

https://github.com/makeomatic/tf_consul

Terraform module for consul
https://github.com/makeomatic/tf_consul

Last synced: about 1 year ago
JSON representation

Terraform module for consul

Awesome Lists containing this project

README

          

# Consul Terraform module

Consul Terraform module is used to bring up a consul cluster in a cloud provider.

- *Supported cloud providers*: **AWS, GCE**
- *Terraform version supported* **>= 0.7**

## Module configuration

The correct list of configuration variables is available in `variables.tf`, down here only the most important configuration variables are described.

### General

|Variable|Description|Default|
|---|---|---|
|**servers**|Number of consul servers to bootstrap.|3|
|**key_name**|Specifies cloud provider key name (**required**).|`""`|
|**key_path**|Specifies local path to the private ssh key used to connect to a cloud provider (**required**).|`""`|

### Consul

|Variable|Description|Default|
|---|---|---|
|**consul_image**|Docker container used to bootstrap consul server.|*stackfeed/consul:0.6-server*|
|**consul_args**|Arguments passed to consul server agent, can be used to override default configuration (ex. specifying atlas options).|`""`|
|**consul_dnsport**|Sets port (tcp/udp) where consul will listen for DNS queries.|8600|

### Nomad

|Variable|Description|Default|
|---|---|---|
|**nomad_enabled**|Specifies whether to start nomad or not.|`true`|
|**nomad_image**|Specifies image used for nomad.|*makeomatic/nomad:0.4*|
|**nomad_region**|Specifies nomad region.|*global*|
|**nomad_datacenter**|Specifies nomad datacenter.|*dc1*|
|**nomad_sgname**|Specifies nomad security group name.|*nomad*|

### Swarm (docker swarm)

|Variable|Description|Default|
|---|---|---|
|**swarm_enabled**|Specifies whether to start nomad or not.|`false`|
|**swarm_image**|Specifies image used for nomad.|*swarm*|

### AWS variables

|Variable|Description|Default|
|---|---|---|
|**SGAllow_ConsulAPInDNS**|List of security groups allowed to access consul API and DNS.|`[]`|
|**SGAllow_NomadAPI**|List of security groups allowed to access nomad REST API.|`[]`|
|**SGAllow_SwarmAPI**|List of security groups allowed to access swarm REST API.|`[]`|

For the list of variables configuring deployment on AWS please refer to [aws defaults](https://github.com/stackfeed/tf_default_compute#aws).

### GCE

For the list of variables configuring deployment on GCE please refer to [gce defaults](https://github.com/stackfeed/tf_default_compute#gce).

## Usage

### AWS usage

First we need to set the AWS credentials via environment.
```
export AWS_ACCESS_KEY_ID="AKIxxxZUT"
export AWS_SECRET_ACCESS_KEY="HAVxxxbNL"
```

Next define the module configuration:

```
provider "aws" {
...
}

module "consul" {
source = "github.com/stackfeed/tf_consul//aws"
servers = 3
key_name = "aws_key_name"
key_path = "~/.ssh/some_pkey_path"
}
```

Note that `consul_args` is optional and can be omitted in this case a consul cluster will be brought up with `-bootstrap-expect 3` and perform automated cluster setup.

### GCE usage

Include module:

```
provider "google" {
...
}

module "consul" {
source = "github.com/stackfeed/tf_consul//gce"
servers = 3

region = "set gce region"
zone = "set gce availability zone"
}
```

Note that `consul_args` is optional and can be omitted in this case a consul cluster will be brought up with `-bootstrap-expect 3` and perform automated cluster setup.
Also it's worth emphasizing that default private and public key paths for GCE are `~/.ssh/google_compute_engine` and `~/.ssh/google_compute_engine.pub` which are generated by `gcloud` CLI. However to use the module you will have to **decrypt the private key otherwise terraform won't be able to operate**.

# Authors

- Denis Baryshev ()