consul_key_prefix

Allows Terraform to read values from a "namespace" of Consul keys that share a common name prefix.

Example Usage

data "consul_key_prefix" "app" {
  datacenter = "nyc1"
  token      = "abcd"

  # Prefix to add to prepend to all of the subkey names below.
  path_prefix = "myapp/config/"

  # Read the ami subkey
  subkey {
    name    = "ami"
    path    = "app/launch_ami"
    default = "ami-1234"
  }
}

# Start our instance with the dynamic ami value
resource "aws_instance" "app" {
  ami = "${data.consul_key_prefix.app.var.ami}"

  # ...
}
data "consul_key_prefix" "web" {
  datacenter = "nyc1"
  token      = "efgh"

  # Prefix to add to prepend to all of the subkey names below.
  path_prefix = "myapp/config/"
}

# Start our instance with the dynamic ami value
resource "aws_instance" "web" {
  ami = "${data.consul_key_prefix.web.subkeys["app/launch_ami"]}"

  # ...
}

Argument Reference

The following arguments are supported:

The subkey block supports the following:

Attributes Reference

The following attributes are exported: