FEATURES OPEN SOURCE ABOUT DOCS LOGIN REGISTER

consul_key_prefix

Allows Terraform to manage a “namespace” of Consul keys that share a common name prefix.

Like consul_keys, this resource can write values into the Consul key/value store, but unlike consul_keys this resource can detect and remove extra keys that have been added some other way, thus ensuring that rogue data added outside of Terraform will be removed on the next run.

This resource is thus useful in the case where Terraform is exclusively managing a set of related keys.

To avoid accidentally clobbering matching data that existed in Consul before a consul_key_prefix resource was created, creation of a key prefix instance will fail if any matching keys are already present in the key/value store. If any conflicting data is present, you must first delete it manually.

~> Warning After this resource is instantiated, Terraform takes control over all keys with the given path prefix, and will remove any matching keys that are not present in the configuration. It will also delete all keys under the given prefix when a consul_key_prefix resource is destroyed, even if those keys were created outside of Terraform.

Example Usage

resource "consul_key_prefix" "myapp_config" {
    datacenter = "nyc1"
    token = "abcd"

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

    subkeys = {
        "elb_cname" = "${aws_elb.app.dns_name}"
        "s3_bucket_name" = "${aws_s3_bucket.app.bucket}"
        "database/hostname" = "${aws_db_instance.app.address}"
        "database/port" = "${aws_db_instance.app.port}"
        "database/username" = "${aws_db_instance.app.username}"
        "database/password" = "${aws_db_instance.app.password}"
        "database/name" = "${aws_db_instance.app.name}"
    }
}

Argument Reference

The following arguments are supported:

Attributes Reference

The following attributes are exported:


See the source of this document at Terraform.io