/terraform-nomad-redis

Primary LanguageHCLApache License 2.0Apache-2.0

Terraform-nomad-redis

This module is IaC - infrastructure as code which contains a nomad job of Redis.

Content

  1. Compatibility
  2. Requirements
    1. Required modules
    2. Required software
  3. Usage
    1. Verifying setup
    2. Providers
  4. Example usage
  5. Inputs
  6. Outputs
  7. License

Compatibility

Software OSS Version Enterprise Version
Terraform 0.13.1 or newer
Consul 1.8.3 or newer 1.8.3 or newer
Vault 1.5.2.1 or newer 1.5.2.1 or newer
Nomad 0.12.3 or newer 0.12.3 or newer

Requirements

Required modules

Module Version
None -

Required software

All software is provided and run with docker. See the Makefile for inspiration.

Usage

The following command will run Redis in the example/standalone folder.

make up 

Verifying setup

You can verify the setup by connention to Redis using the Nomad UI at localhost:4646. Follow the steps below:

  1. Locate and click the redis nomad-job.
  2. Click the exec button and connect to the redis --> redis-service-task.
  3. Run redis-cli to connect to Redis Cli.
  4. Run ping. Your output should look like this:
127.0.0.1:6379> ping
PONG

Providers

Example usage

Example-code that shows how to use the module and, if applicable, its different use cases.

module "redis" {
  source = "../.."

  # nomad
  nomad_datacenters = ["dc1"]
  nomad_namespace   = "default"

  # redis
  service_name    = "redis"
  host            = "127.0.0.1"
  port            = 6379
  container_image = "redis:3-alpine"

}

Inputs

Name Description Type Default Required
nomad_datacenters Nomad data centers list(string) ["dc1"] yes
nomad_namespace [Enterprise] Nomad namespace string "default" yes
service_name Redis service name string "redis" yes
host Redis host string "127.0.0.1" yes
port Redis container port number 6379 yes
container_image Redis container image string "redis:3-alpine" yes
resource Resource allocations for cpu and memory obj(number, number) {
cpu = 200,
memory = 128
}
no
resource_proxy Resource allocations for proxy obj(number, number) {
cpu = 200,
memory = 128
}
no
use_canary Uses canary deployment for Redis bool false no

Outputs

Name Description Type
redis_service Redis service name string
redis_port Redis port number number
redis_host Redis host string

License

This work is licensed under Apache 2 License. See LICENSE for full details.