1. Packages
  2. Consul Provider
  3. API Docs
  4. Keys
Consul v3.12.4 published on Wednesday, Feb 12, 2025 by Pulumi

consul.Keys

Explore with Pulumi AI

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as consul from "@pulumi/consul";

const app = new consul.Keys("app", {
    datacenter: "nyc1",
    token: "abcd",
    keys: [{
        path: "service/app/elb_address",
        value: appAwsElb.dnsName,
    }],
});
Copy
import pulumi
import pulumi_consul as consul

app = consul.Keys("app",
    datacenter="nyc1",
    token="abcd",
    keys=[{
        "path": "service/app/elb_address",
        "value": app_aws_elb["dnsName"],
    }])
Copy
package main

import (
	"github.com/pulumi/pulumi-consul/sdk/v3/go/consul"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := consul.NewKeys(ctx, "app", &consul.KeysArgs{
			Datacenter: pulumi.String("nyc1"),
			Token:      pulumi.String("abcd"),
			Keys: consul.KeysKeyArray{
				&consul.KeysKeyArgs{
					Path:  pulumi.String("service/app/elb_address"),
					Value: pulumi.Any(appAwsElb.DnsName),
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Consul = Pulumi.Consul;

return await Deployment.RunAsync(() => 
{
    var app = new Consul.Keys("app", new()
    {
        Datacenter = "nyc1",
        Token = "abcd",
        KeysCollection = new[]
        {
            new Consul.Inputs.KeysKeyArgs
            {
                Path = "service/app/elb_address",
                Value = appAwsElb.DnsName,
            },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.consul.Keys;
import com.pulumi.consul.KeysArgs;
import com.pulumi.consul.inputs.KeysKeyArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var app = new Keys("app", KeysArgs.builder()
            .datacenter("nyc1")
            .token("abcd")
            .keys(KeysKeyArgs.builder()
                .path("service/app/elb_address")
                .value(appAwsElb.dnsName())
                .build())
            .build());

    }
}
Copy
resources:
  app:
    type: consul:Keys
    properties:
      datacenter: nyc1
      token: abcd
      keys:
        - path: service/app/elb_address
          value: ${appAwsElb.dnsName}
Copy

Create Keys Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Keys(name: string, args?: KeysArgs, opts?: CustomResourceOptions);
@overload
def Keys(resource_name: str,
         args: Optional[KeysArgs] = None,
         opts: Optional[ResourceOptions] = None)

@overload
def Keys(resource_name: str,
         opts: Optional[ResourceOptions] = None,
         datacenter: Optional[str] = None,
         keys: Optional[Sequence[KeysKeyArgs]] = None,
         namespace: Optional[str] = None,
         partition: Optional[str] = None,
         token: Optional[str] = None)
func NewKeys(ctx *Context, name string, args *KeysArgs, opts ...ResourceOption) (*Keys, error)
public Keys(string name, KeysArgs? args = null, CustomResourceOptions? opts = null)
public Keys(String name, KeysArgs args)
public Keys(String name, KeysArgs args, CustomResourceOptions options)
type: consul:Keys
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args KeysArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args KeysArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args KeysArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args KeysArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. KeysArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var keysResource = new Consul.Keys("keysResource", new()
{
    Datacenter = "string",
    KeysCollection = new[]
    {
        new Consul.Inputs.KeysKeyArgs
        {
            Path = "string",
            Default = "string",
            Delete = false,
            Flags = 0,
            Value = "string",
        },
    },
    Namespace = "string",
    Partition = "string",
});
Copy
example, err := consul.NewKeys(ctx, "keysResource", &consul.KeysArgs{
	Datacenter: pulumi.String("string"),
	Keys: consul.KeysKeyArray{
		&consul.KeysKeyArgs{
			Path:    pulumi.String("string"),
			Default: pulumi.String("string"),
			Delete:  pulumi.Bool(false),
			Flags:   pulumi.Int(0),
			Value:   pulumi.String("string"),
		},
	},
	Namespace: pulumi.String("string"),
	Partition: pulumi.String("string"),
})
Copy
var keysResource = new Keys("keysResource", KeysArgs.builder()
    .datacenter("string")
    .keys(KeysKeyArgs.builder()
        .path("string")
        .default_("string")
        .delete(false)
        .flags(0)
        .value("string")
        .build())
    .namespace("string")
    .partition("string")
    .build());
Copy
keys_resource = consul.Keys("keysResource",
    datacenter="string",
    keys=[{
        "path": "string",
        "default": "string",
        "delete": False,
        "flags": 0,
        "value": "string",
    }],
    namespace="string",
    partition="string")
Copy
const keysResource = new consul.Keys("keysResource", {
    datacenter: "string",
    keys: [{
        path: "string",
        "default": "string",
        "delete": false,
        flags: 0,
        value: "string",
    }],
    namespace: "string",
    partition: "string",
});
Copy
type: consul:Keys
properties:
    datacenter: string
    keys:
        - default: string
          delete: false
          flags: 0
          path: string
          value: string
    namespace: string
    partition: string
Copy

Keys Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The Keys resource accepts the following input properties:

Datacenter Changes to this property will trigger replacement. string
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
KeysCollection List<KeysKey>
Specifies a key in Consul to be written. Supported values documented below.
Namespace Changes to this property will trigger replacement. string
The namespace to create the keys within.
Partition Changes to this property will trigger replacement. string
The partition to create the keys within.
Token string
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

Datacenter Changes to this property will trigger replacement. string
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
Keys []KeysKeyArgs
Specifies a key in Consul to be written. Supported values documented below.
Namespace Changes to this property will trigger replacement. string
The namespace to create the keys within.
Partition Changes to this property will trigger replacement. string
The partition to create the keys within.
Token string
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

datacenter Changes to this property will trigger replacement. String
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
keys List<KeysKey>
Specifies a key in Consul to be written. Supported values documented below.
namespace Changes to this property will trigger replacement. String
The namespace to create the keys within.
partition Changes to this property will trigger replacement. String
The partition to create the keys within.
token String
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

datacenter Changes to this property will trigger replacement. string
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
keys KeysKey[]
Specifies a key in Consul to be written. Supported values documented below.
namespace Changes to this property will trigger replacement. string
The namespace to create the keys within.
partition Changes to this property will trigger replacement. string
The partition to create the keys within.
token string
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

datacenter Changes to this property will trigger replacement. str
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
keys Sequence[KeysKeyArgs]
Specifies a key in Consul to be written. Supported values documented below.
namespace Changes to this property will trigger replacement. str
The namespace to create the keys within.
partition Changes to this property will trigger replacement. str
The partition to create the keys within.
token str
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

datacenter Changes to this property will trigger replacement. String
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
keys List<Property Map>
Specifies a key in Consul to be written. Supported values documented below.
namespace Changes to this property will trigger replacement. String
The namespace to create the keys within.
partition Changes to this property will trigger replacement. String
The partition to create the keys within.
token String
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

Outputs

All input properties are implicitly available as output properties. Additionally, the Keys resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Var Dictionary<string, string>
Id string
The provider-assigned unique ID for this managed resource.
Var map[string]string
id String
The provider-assigned unique ID for this managed resource.
var_ Map<String,String>
id string
The provider-assigned unique ID for this managed resource.
var {[key: string]: string}
id str
The provider-assigned unique ID for this managed resource.
var Mapping[str, str]
id String
The provider-assigned unique ID for this managed resource.
var Map<String>

Look up Existing Keys Resource

Get an existing Keys resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: KeysState, opts?: CustomResourceOptions): Keys
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        datacenter: Optional[str] = None,
        keys: Optional[Sequence[KeysKeyArgs]] = None,
        namespace: Optional[str] = None,
        partition: Optional[str] = None,
        token: Optional[str] = None,
        var: Optional[Mapping[str, str]] = None) -> Keys
func GetKeys(ctx *Context, name string, id IDInput, state *KeysState, opts ...ResourceOption) (*Keys, error)
public static Keys Get(string name, Input<string> id, KeysState? state, CustomResourceOptions? opts = null)
public static Keys get(String name, Output<String> id, KeysState state, CustomResourceOptions options)
resources:  _:    type: consul:Keys    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Datacenter Changes to this property will trigger replacement. string
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
KeysCollection List<KeysKey>
Specifies a key in Consul to be written. Supported values documented below.
Namespace Changes to this property will trigger replacement. string
The namespace to create the keys within.
Partition Changes to this property will trigger replacement. string
The partition to create the keys within.
Token string
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

Var Dictionary<string, string>
Datacenter Changes to this property will trigger replacement. string
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
Keys []KeysKeyArgs
Specifies a key in Consul to be written. Supported values documented below.
Namespace Changes to this property will trigger replacement. string
The namespace to create the keys within.
Partition Changes to this property will trigger replacement. string
The partition to create the keys within.
Token string
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

Var map[string]string
datacenter Changes to this property will trigger replacement. String
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
keys List<KeysKey>
Specifies a key in Consul to be written. Supported values documented below.
namespace Changes to this property will trigger replacement. String
The namespace to create the keys within.
partition Changes to this property will trigger replacement. String
The partition to create the keys within.
token String
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

var_ Map<String,String>
datacenter Changes to this property will trigger replacement. string
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
keys KeysKey[]
Specifies a key in Consul to be written. Supported values documented below.
namespace Changes to this property will trigger replacement. string
The namespace to create the keys within.
partition Changes to this property will trigger replacement. string
The partition to create the keys within.
token string
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

var {[key: string]: string}
datacenter Changes to this property will trigger replacement. str
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
keys Sequence[KeysKeyArgs]
Specifies a key in Consul to be written. Supported values documented below.
namespace Changes to this property will trigger replacement. str
The namespace to create the keys within.
partition Changes to this property will trigger replacement. str
The partition to create the keys within.
token str
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

var Mapping[str, str]
datacenter Changes to this property will trigger replacement. String
The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
keys List<Property Map>
Specifies a key in Consul to be written. Supported values documented below.
namespace Changes to this property will trigger replacement. String
The namespace to create the keys within.
partition Changes to this property will trigger replacement. String
The partition to create the keys within.
token String
The ACL token to use. This overrides the token that the agent provides by default.

Deprecated: The token argument has been deprecated and will be removed in a future release. Please use the token argument in the provider configuration

var Map<String>

Supporting Types

KeysKey
, KeysKeyArgs

Path This property is required. string
This is the path in Consul that should be written to.
Default string
Delete bool
If true, then the key will be deleted when either its configuration block is removed from the configuration or the entire resource is destroyed. Otherwise, it will be left in Consul. Defaults to false.
Flags int
An unsigned integer value to attach to the key (defaults to 0).
Name string

Deprecated: Using consul.Keys resource to read is deprecated; please use consul.Keys data source instead

Value string
The value to write to the given path.
Path This property is required. string
This is the path in Consul that should be written to.
Default string
Delete bool
If true, then the key will be deleted when either its configuration block is removed from the configuration or the entire resource is destroyed. Otherwise, it will be left in Consul. Defaults to false.
Flags int
An unsigned integer value to attach to the key (defaults to 0).
Name string

Deprecated: Using consul.Keys resource to read is deprecated; please use consul.Keys data source instead

Value string
The value to write to the given path.
path This property is required. String
This is the path in Consul that should be written to.
default_ String
delete Boolean
If true, then the key will be deleted when either its configuration block is removed from the configuration or the entire resource is destroyed. Otherwise, it will be left in Consul. Defaults to false.
flags Integer
An unsigned integer value to attach to the key (defaults to 0).
name String

Deprecated: Using consul.Keys resource to read is deprecated; please use consul.Keys data source instead

value String
The value to write to the given path.
path This property is required. string
This is the path in Consul that should be written to.
default string
delete boolean
If true, then the key will be deleted when either its configuration block is removed from the configuration or the entire resource is destroyed. Otherwise, it will be left in Consul. Defaults to false.
flags number
An unsigned integer value to attach to the key (defaults to 0).
name string

Deprecated: Using consul.Keys resource to read is deprecated; please use consul.Keys data source instead

value string
The value to write to the given path.
path This property is required. str
This is the path in Consul that should be written to.
default str
delete bool
If true, then the key will be deleted when either its configuration block is removed from the configuration or the entire resource is destroyed. Otherwise, it will be left in Consul. Defaults to false.
flags int
An unsigned integer value to attach to the key (defaults to 0).
name str

Deprecated: Using consul.Keys resource to read is deprecated; please use consul.Keys data source instead

value str
The value to write to the given path.
path This property is required. String
This is the path in Consul that should be written to.
default String
delete Boolean
If true, then the key will be deleted when either its configuration block is removed from the configuration or the entire resource is destroyed. Otherwise, it will be left in Consul. Defaults to false.
flags Number
An unsigned integer value to attach to the key (defaults to 0).
name String

Deprecated: Using consul.Keys resource to read is deprecated; please use consul.Keys data source instead

value String
The value to write to the given path.

Package Details

Repository
HashiCorp Consul pulumi/pulumi-consul
License
Apache-2.0
Notes
This Pulumi package is based on the consul Terraform Provider.