consul.KeyPrefix
Explore with Pulumi AI
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as consul from "@pulumi/consul";
const myappConfig = new consul.KeyPrefix("myapp_config", {
datacenter: "nyc1",
token: "abcd",
pathPrefix: "myapp/config/",
subkeys: {
elb_cname: appAwsElb.dnsName,
s3_bucket_name: appAwsS3Bucket.bucket,
"database/hostname": app.address,
"database/port": app.port,
"database/username": app.username,
"database/name": app.name,
},
subkeyCollection: [{
path: "database/password",
value: app.password,
flags: 2,
}],
});
import pulumi
import pulumi_consul as consul
myapp_config = consul.KeyPrefix("myapp_config",
datacenter="nyc1",
token="abcd",
path_prefix="myapp/config/",
subkeys={
"elb_cname": app_aws_elb["dnsName"],
"s3_bucket_name": app_aws_s3_bucket["bucket"],
"database/hostname": app["address"],
"database/port": app["port"],
"database/username": app["username"],
"database/name": app["name"],
},
subkey_collection=[{
"path": "database/password",
"value": app["password"],
"flags": 2,
}])
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.NewKeyPrefix(ctx, "myapp_config", &consul.KeyPrefixArgs{
Datacenter: pulumi.String("nyc1"),
Token: pulumi.String("abcd"),
PathPrefix: pulumi.String("myapp/config/"),
Subkeys: pulumi.StringMap{
"elb_cname": pulumi.Any(appAwsElb.DnsName),
"s3_bucket_name": pulumi.Any(appAwsS3Bucket.Bucket),
"database/hostname": pulumi.Any(app.Address),
"database/port": pulumi.Any(app.Port),
"database/username": pulumi.Any(app.Username),
"database/name": pulumi.Any(app.Name),
},
SubkeyCollection: consul.KeyPrefixSubkeyCollectionArray{
&consul.KeyPrefixSubkeyCollectionArgs{
Path: pulumi.String("database/password"),
Value: pulumi.Any(app.Password),
Flags: pulumi.Int(2),
},
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Consul = Pulumi.Consul;
return await Deployment.RunAsync(() =>
{
var myappConfig = new Consul.KeyPrefix("myapp_config", new()
{
Datacenter = "nyc1",
Token = "abcd",
PathPrefix = "myapp/config/",
Subkeys =
{
{ "elb_cname", appAwsElb.DnsName },
{ "s3_bucket_name", appAwsS3Bucket.Bucket },
{ "database/hostname", app.Address },
{ "database/port", app.Port },
{ "database/username", app.Username },
{ "database/name", app.Name },
},
SubkeyCollection = new[]
{
new Consul.Inputs.KeyPrefixSubkeyCollectionArgs
{
Path = "database/password",
Value = app.Password,
Flags = 2,
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.consul.KeyPrefix;
import com.pulumi.consul.KeyPrefixArgs;
import com.pulumi.consul.inputs.KeyPrefixSubkeyCollectionArgs;
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 myappConfig = new KeyPrefix("myappConfig", KeyPrefixArgs.builder()
.datacenter("nyc1")
.token("abcd")
.pathPrefix("myapp/config/")
.subkeys(Map.ofEntries(
Map.entry("elb_cname", appAwsElb.dnsName()),
Map.entry("s3_bucket_name", appAwsS3Bucket.bucket()),
Map.entry("database/hostname", app.address()),
Map.entry("database/port", app.port()),
Map.entry("database/username", app.username()),
Map.entry("database/name", app.name())
))
.subkeyCollection(KeyPrefixSubkeyCollectionArgs.builder()
.path("database/password")
.value(app.password())
.flags(2)
.build())
.build());
}
}
resources:
myappConfig:
type: consul:KeyPrefix
name: myapp_config
properties:
datacenter: nyc1
token: abcd
pathPrefix: myapp/config/
subkeys:
elb_cname: ${appAwsElb.dnsName}
s3_bucket_name: ${appAwsS3Bucket.bucket}
database/hostname: ${app.address}
database/port: ${app.port}
database/username: ${app.username}
database/name: ${app.name}
subkeyCollection:
- path: database/password
value: ${app.password}
flags: 2
Create KeyPrefix Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new KeyPrefix(name: string, args: KeyPrefixArgs, opts?: CustomResourceOptions);
@overload
def KeyPrefix(resource_name: str,
args: KeyPrefixArgs,
opts: Optional[ResourceOptions] = None)
@overload
def KeyPrefix(resource_name: str,
opts: Optional[ResourceOptions] = None,
path_prefix: Optional[str] = None,
datacenter: Optional[str] = None,
namespace: Optional[str] = None,
partition: Optional[str] = None,
subkey_collection: Optional[Sequence[KeyPrefixSubkeyCollectionArgs]] = None,
subkeys: Optional[Mapping[str, str]] = None,
token: Optional[str] = None)
func NewKeyPrefix(ctx *Context, name string, args KeyPrefixArgs, opts ...ResourceOption) (*KeyPrefix, error)
public KeyPrefix(string name, KeyPrefixArgs args, CustomResourceOptions? opts = null)
public KeyPrefix(String name, KeyPrefixArgs args)
public KeyPrefix(String name, KeyPrefixArgs args, CustomResourceOptions options)
type: consul:KeyPrefix
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args KeyPrefixArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args KeyPrefixArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args KeyPrefixArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args KeyPrefixArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args KeyPrefixArgs
- 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 keyPrefixResource = new Consul.KeyPrefix("keyPrefixResource", new()
{
PathPrefix = "string",
Datacenter = "string",
Namespace = "string",
Partition = "string",
SubkeyCollection = new[]
{
new Consul.Inputs.KeyPrefixSubkeyCollectionArgs
{
Path = "string",
Value = "string",
Flags = 0,
},
},
Subkeys =
{
{ "string", "string" },
},
});
example, err := consul.NewKeyPrefix(ctx, "keyPrefixResource", &consul.KeyPrefixArgs{
PathPrefix: pulumi.String("string"),
Datacenter: pulumi.String("string"),
Namespace: pulumi.String("string"),
Partition: pulumi.String("string"),
SubkeyCollection: consul.KeyPrefixSubkeyCollectionArray{
&consul.KeyPrefixSubkeyCollectionArgs{
Path: pulumi.String("string"),
Value: pulumi.String("string"),
Flags: pulumi.Int(0),
},
},
Subkeys: pulumi.StringMap{
"string": pulumi.String("string"),
},
})
var keyPrefixResource = new KeyPrefix("keyPrefixResource", KeyPrefixArgs.builder()
.pathPrefix("string")
.datacenter("string")
.namespace("string")
.partition("string")
.subkeyCollection(KeyPrefixSubkeyCollectionArgs.builder()
.path("string")
.value("string")
.flags(0)
.build())
.subkeys(Map.of("string", "string"))
.build());
key_prefix_resource = consul.KeyPrefix("keyPrefixResource",
path_prefix="string",
datacenter="string",
namespace="string",
partition="string",
subkey_collection=[consul.KeyPrefixSubkeyCollectionArgs(
path="string",
value="string",
flags=0,
)],
subkeys={
"string": "string",
})
const keyPrefixResource = new consul.KeyPrefix("keyPrefixResource", {
pathPrefix: "string",
datacenter: "string",
namespace: "string",
partition: "string",
subkeyCollection: [{
path: "string",
value: "string",
flags: 0,
}],
subkeys: {
string: "string",
},
});
type: consul:KeyPrefix
properties:
datacenter: string
namespace: string
partition: string
pathPrefix: string
subkeyCollection:
- flags: 0
path: string
value: string
subkeys:
string: string
KeyPrefix Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The KeyPrefix resource accepts the following input properties:
- Path
Prefix string - Specifies the common prefix shared by all keys that will be managed by this resource instance. In most cases this will end with a slash, to manage a "folder" of keys.
- Datacenter string
- The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
- Namespace string
- The namespace to create the keys within.
- Partition string
- The admin partition to create the keys within.
- Subkey
Collection List<KeyPrefix Subkey Collection> - A subkey to add. Supported values documented below. Multiple blocks supported.
- Subkeys Dictionary<string, string>
- A mapping from subkey name (which will be appended
to the given
path_prefix
) to the value that should be stored at that key. Use slashes, as shown in the above example, to create "sub-folders" under the given path prefix. - Token string
- The ACL token to use. This overrides the token that the agent provides by default.
- Path
Prefix string - Specifies the common prefix shared by all keys that will be managed by this resource instance. In most cases this will end with a slash, to manage a "folder" of keys.
- Datacenter string
- The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
- Namespace string
- The namespace to create the keys within.
- Partition string
- The admin partition to create the keys within.
- Subkey
Collection []KeyPrefix Subkey Collection Args - A subkey to add. Supported values documented below. Multiple blocks supported.
- Subkeys map[string]string
- A mapping from subkey name (which will be appended
to the given
path_prefix
) to the value that should be stored at that key. Use slashes, as shown in the above example, to create "sub-folders" under the given path prefix. - Token string
- The ACL token to use. This overrides the token that the agent provides by default.
- path
Prefix String - Specifies the common prefix shared by all keys that will be managed by this resource instance. In most cases this will end with a slash, to manage a "folder" of keys.
- datacenter String
- The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
- namespace String
- The namespace to create the keys within.
- partition String
- The admin partition to create the keys within.
- subkey
Collection List<KeyPrefix Subkey Collection> - A subkey to add. Supported values documented below. Multiple blocks supported.
- subkeys Map<String,String>
- A mapping from subkey name (which will be appended
to the given
path_prefix
) to the value that should be stored at that key. Use slashes, as shown in the above example, to create "sub-folders" under the given path prefix. - token String
- The ACL token to use. This overrides the token that the agent provides by default.
- path
Prefix string - Specifies the common prefix shared by all keys that will be managed by this resource instance. In most cases this will end with a slash, to manage a "folder" of keys.
- datacenter string
- The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
- namespace string
- The namespace to create the keys within.
- partition string
- The admin partition to create the keys within.
- subkey
Collection KeyPrefix Subkey Collection[] - A subkey to add. Supported values documented below. Multiple blocks supported.
- subkeys {[key: string]: string}
- A mapping from subkey name (which will be appended
to the given
path_prefix
) to the value that should be stored at that key. Use slashes, as shown in the above example, to create "sub-folders" under the given path prefix. - token string
- The ACL token to use. This overrides the token that the agent provides by default.
- path_
prefix str - Specifies the common prefix shared by all keys that will be managed by this resource instance. In most cases this will end with a slash, to manage a "folder" of keys.
- datacenter str
- The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
- namespace str
- The namespace to create the keys within.
- partition str
- The admin partition to create the keys within.
- subkey_
collection Sequence[KeyPrefix Subkey Collection Args] - A subkey to add. Supported values documented below. Multiple blocks supported.
- subkeys Mapping[str, str]
- A mapping from subkey name (which will be appended
to the given
path_prefix
) to the value that should be stored at that key. Use slashes, as shown in the above example, to create "sub-folders" under the given path prefix. - token str
- The ACL token to use. This overrides the token that the agent provides by default.
- path
Prefix String - Specifies the common prefix shared by all keys that will be managed by this resource instance. In most cases this will end with a slash, to manage a "folder" of keys.
- datacenter String
- The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
- namespace String
- The namespace to create the keys within.
- partition String
- The admin partition to create the keys within.
- subkey
Collection List<Property Map> - A subkey to add. Supported values documented below. Multiple blocks supported.
- subkeys Map<String>
- A mapping from subkey name (which will be appended
to the given
path_prefix
) to the value that should be stored at that key. Use slashes, as shown in the above example, to create "sub-folders" under the given path prefix. - token String
- The ACL token to use. This overrides the token that the agent provides by default.
Outputs
All input properties are implicitly available as output properties. Additionally, the KeyPrefix resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing KeyPrefix Resource
Get an existing KeyPrefix 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?: KeyPrefixState, opts?: CustomResourceOptions): KeyPrefix
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
datacenter: Optional[str] = None,
namespace: Optional[str] = None,
partition: Optional[str] = None,
path_prefix: Optional[str] = None,
subkey_collection: Optional[Sequence[KeyPrefixSubkeyCollectionArgs]] = None,
subkeys: Optional[Mapping[str, str]] = None,
token: Optional[str] = None) -> KeyPrefix
func GetKeyPrefix(ctx *Context, name string, id IDInput, state *KeyPrefixState, opts ...ResourceOption) (*KeyPrefix, error)
public static KeyPrefix Get(string name, Input<string> id, KeyPrefixState? state, CustomResourceOptions? opts = null)
public static KeyPrefix get(String name, Output<String> id, KeyPrefixState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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.
- Datacenter string
- The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
- Namespace string
- The namespace to create the keys within.
- Partition string
- The admin partition to create the keys within.
- Path
Prefix string - Specifies the common prefix shared by all keys that will be managed by this resource instance. In most cases this will end with a slash, to manage a "folder" of keys.
- Subkey
Collection List<KeyPrefix Subkey Collection> - A subkey to add. Supported values documented below. Multiple blocks supported.
- Subkeys Dictionary<string, string>
- A mapping from subkey name (which will be appended
to the given
path_prefix
) to the value that should be stored at that key. Use slashes, as shown in the above example, to create "sub-folders" under the given path prefix. - Token string
- The ACL token to use. This overrides the token that the agent provides by default.
- Datacenter string
- The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
- Namespace string
- The namespace to create the keys within.
- Partition string
- The admin partition to create the keys within.
- Path
Prefix string - Specifies the common prefix shared by all keys that will be managed by this resource instance. In most cases this will end with a slash, to manage a "folder" of keys.
- Subkey
Collection []KeyPrefix Subkey Collection Args - A subkey to add. Supported values documented below. Multiple blocks supported.
- Subkeys map[string]string
- A mapping from subkey name (which will be appended
to the given
path_prefix
) to the value that should be stored at that key. Use slashes, as shown in the above example, to create "sub-folders" under the given path prefix. - Token string
- The ACL token to use. This overrides the token that the agent provides by default.
- datacenter String
- The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
- namespace String
- The namespace to create the keys within.
- partition String
- The admin partition to create the keys within.
- path
Prefix String - Specifies the common prefix shared by all keys that will be managed by this resource instance. In most cases this will end with a slash, to manage a "folder" of keys.
- subkey
Collection List<KeyPrefix Subkey Collection> - A subkey to add. Supported values documented below. Multiple blocks supported.
- subkeys Map<String,String>
- A mapping from subkey name (which will be appended
to the given
path_prefix
) to the value that should be stored at that key. Use slashes, as shown in the above example, to create "sub-folders" under the given path prefix. - token String
- The ACL token to use. This overrides the token that the agent provides by default.
- datacenter string
- The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
- namespace string
- The namespace to create the keys within.
- partition string
- The admin partition to create the keys within.
- path
Prefix string - Specifies the common prefix shared by all keys that will be managed by this resource instance. In most cases this will end with a slash, to manage a "folder" of keys.
- subkey
Collection KeyPrefix Subkey Collection[] - A subkey to add. Supported values documented below. Multiple blocks supported.
- subkeys {[key: string]: string}
- A mapping from subkey name (which will be appended
to the given
path_prefix
) to the value that should be stored at that key. Use slashes, as shown in the above example, to create "sub-folders" under the given path prefix. - token string
- The ACL token to use. This overrides the token that the agent provides by default.
- datacenter str
- The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
- namespace str
- The namespace to create the keys within.
- partition str
- The admin partition to create the keys within.
- path_
prefix str - Specifies the common prefix shared by all keys that will be managed by this resource instance. In most cases this will end with a slash, to manage a "folder" of keys.
- subkey_
collection Sequence[KeyPrefix Subkey Collection Args] - A subkey to add. Supported values documented below. Multiple blocks supported.
- subkeys Mapping[str, str]
- A mapping from subkey name (which will be appended
to the given
path_prefix
) to the value that should be stored at that key. Use slashes, as shown in the above example, to create "sub-folders" under the given path prefix. - token str
- The ACL token to use. This overrides the token that the agent provides by default.
- datacenter String
- The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
- namespace String
- The namespace to create the keys within.
- partition String
- The admin partition to create the keys within.
- path
Prefix String - Specifies the common prefix shared by all keys that will be managed by this resource instance. In most cases this will end with a slash, to manage a "folder" of keys.
- subkey
Collection List<Property Map> - A subkey to add. Supported values documented below. Multiple blocks supported.
- subkeys Map<String>
- A mapping from subkey name (which will be appended
to the given
path_prefix
) to the value that should be stored at that key. Use slashes, as shown in the above example, to create "sub-folders" under the given path prefix. - token String
- The ACL token to use. This overrides the token that the agent provides by default.
Supporting Types
KeyPrefixSubkeyCollection, KeyPrefixSubkeyCollectionArgs
- Path string
- This is the path (which will be appended to the given
path_prefix
) in Consul that should be written to. - Value string
- The value to write to the given path.
- Flags int
- An unsigned integer value to attach to the key (defaults to 0).
- Path string
- This is the path (which will be appended to the given
path_prefix
) in Consul that should be written to. - Value string
- The value to write to the given path.
- Flags int
- An unsigned integer value to attach to the key (defaults to 0).
- path String
- This is the path (which will be appended to the given
path_prefix
) in Consul that should be written to. - value String
- The value to write to the given path.
- flags Integer
- An unsigned integer value to attach to the key (defaults to 0).
- path string
- This is the path (which will be appended to the given
path_prefix
) in Consul that should be written to. - value string
- The value to write to the given path.
- flags number
- An unsigned integer value to attach to the key (defaults to 0).
- path str
- This is the path (which will be appended to the given
path_prefix
) in Consul that should be written to. - value str
- The value to write to the given path.
- flags int
- An unsigned integer value to attach to the key (defaults to 0).
- path String
- This is the path (which will be appended to the given
path_prefix
) in Consul that should be written to. - value String
- The value to write to the given path.
- flags Number
- An unsigned integer value to attach to the key (defaults to 0).
Import
consul_key_prefix
can be imported. This is useful when the path already exists and
you know all keys in path should be managed by Terraform.
$ pulumi import consul:index/keyPrefix:KeyPrefix myapp_config myapp/config/
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- HashiCorp Consul pulumi/pulumi-consul
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
consul
Terraform Provider.