1. Packages
  2. HashiCorp Consul
  3. API Docs
  4. KeyPrefix
Consul v3.11.1 published on Friday, Jan 19, 2024 by Pulumi

consul.KeyPrefix

Explore with Pulumi AI

consul logo
Consul v3.11.1 published on Friday, Jan 19, 2024 by Pulumi

    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/
    

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Consul = Pulumi.Consul;
    
    return await Deployment.RunAsync(() => 
    {
        var myappConfig = new Consul.KeyPrefix("myappConfig", new()
        {
            Datacenter = "nyc1",
            PathPrefix = "myapp/config/",
            SubkeyCollection = new[]
            {
                new Consul.Inputs.KeyPrefixSubkeyCollectionArgs
                {
                    Flags = 2,
                    Path = "database/password",
                    Value = aws_db_instance.App.Password,
                },
            },
            Subkeys = 
            {
                { "database/hostname", aws_db_instance.App.Address },
                { "database/name", aws_db_instance.App.Name },
                { "database/port", aws_db_instance.App.Port },
                { "database/username", aws_db_instance.App.Username },
                { "elb_cname", aws_elb.App.Dns_name },
                { "s3_bucket_name", aws_s3_bucket.App.Bucket },
            },
            Token = "abcd",
        });
    
    });
    
    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, "myappConfig", &consul.KeyPrefixArgs{
    			Datacenter: pulumi.String("nyc1"),
    			PathPrefix: pulumi.String("myapp/config/"),
    			SubkeyCollection: consul.KeyPrefixSubkeyCollectionArray{
    				&consul.KeyPrefixSubkeyCollectionArgs{
    					Flags: pulumi.Int(2),
    					Path:  pulumi.String("database/password"),
    					Value: pulumi.Any(aws_db_instance.App.Password),
    				},
    			},
    			Subkeys: pulumi.StringMap{
    				"database/hostname": pulumi.Any(aws_db_instance.App.Address),
    				"database/name":     pulumi.Any(aws_db_instance.App.Name),
    				"database/port":     pulumi.Any(aws_db_instance.App.Port),
    				"database/username": pulumi.Any(aws_db_instance.App.Username),
    				"elb_cname":         pulumi.Any(aws_elb.App.Dns_name),
    				"s3_bucket_name":    pulumi.Any(aws_s3_bucket.App.Bucket),
    			},
    			Token: pulumi.String("abcd"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    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")
                .pathPrefix("myapp/config/")
                .subkeyCollection(KeyPrefixSubkeyCollectionArgs.builder()
                    .flags(2)
                    .path("database/password")
                    .value(aws_db_instance.app().password())
                    .build())
                .subkeys(Map.ofEntries(
                    Map.entry("database/hostname", aws_db_instance.app().address()),
                    Map.entry("database/name", aws_db_instance.app().name()),
                    Map.entry("database/port", aws_db_instance.app().port()),
                    Map.entry("database/username", aws_db_instance.app().username()),
                    Map.entry("elb_cname", aws_elb.app().dns_name()),
                    Map.entry("s3_bucket_name", aws_s3_bucket.app().bucket())
                ))
                .token("abcd")
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_consul as consul
    
    myapp_config = consul.KeyPrefix("myappConfig",
        datacenter="nyc1",
        path_prefix="myapp/config/",
        subkey_collection=[consul.KeyPrefixSubkeyCollectionArgs(
            flags=2,
            path="database/password",
            value=aws_db_instance["app"]["password"],
        )],
        subkeys={
            "database/hostname": aws_db_instance["app"]["address"],
            "database/name": aws_db_instance["app"]["name"],
            "database/port": aws_db_instance["app"]["port"],
            "database/username": aws_db_instance["app"]["username"],
            "elb_cname": aws_elb["app"]["dns_name"],
            "s3_bucket_name": aws_s3_bucket["app"]["bucket"],
        },
        token="abcd")
    
    import * as pulumi from "@pulumi/pulumi";
    import * as consul from "@pulumi/consul";
    
    const myappConfig = new consul.KeyPrefix("myappConfig", {
        datacenter: "nyc1",
        pathPrefix: "myapp/config/",
        subkeyCollection: [{
            flags: 2,
            path: "database/password",
            value: aws_db_instance.app.password,
        }],
        subkeys: {
            "database/hostname": aws_db_instance.app.address,
            "database/name": aws_db_instance.app.name,
            "database/port": aws_db_instance.app.port,
            "database/username": aws_db_instance.app.username,
            elb_cname: aws_elb.app.dns_name,
            s3_bucket_name: aws_s3_bucket.app.bucket,
        },
        token: "abcd",
    });
    
    resources:
      myappConfig:
        type: consul:KeyPrefix
        properties:
          datacenter: nyc1
          # Prefix to add to prepend to all of the subkey names below.
          pathPrefix: myapp/config/
          subkeyCollection:
            - flags: 2
              path: database/password
              value: ${aws_db_instance.app.password}
          subkeys:
            database/hostname: ${aws_db_instance.app.address}
            database/name: ${aws_db_instance.app.name}
            database/port: ${aws_db_instance.app.port}
            database/username: ${aws_db_instance.app.username}
            elb_cname: ${aws_elb.app.dns_name}
            s3_bucket_name: ${aws_s3_bucket.app.bucket}
          token: abcd
    

    Create KeyPrefix Resource

    new KeyPrefix(name: string, args: KeyPrefixArgs, opts?: CustomResourceOptions);
    @overload
    def KeyPrefix(resource_name: 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)
    @overload
    def KeyPrefix(resource_name: str,
                  args: KeyPrefixArgs,
                  opts: Optional[ResourceOptions] = 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.
    
    
    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.

    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:

    PathPrefix 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.
    SubkeyCollection List<KeyPrefixSubkeyCollection>
    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.

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

    PathPrefix 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.
    SubkeyCollection []KeyPrefixSubkeyCollectionArgs
    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.

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

    pathPrefix 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.
    subkeyCollection List<KeyPrefixSubkeyCollection>
    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.

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

    pathPrefix 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.
    subkeyCollection KeyPrefixSubkeyCollection[]
    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.

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

    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[KeyPrefixSubkeyCollectionArgs]
    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.

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

    pathPrefix 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.
    subkeyCollection 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.

    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 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.
    The following state arguments are supported:
    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.
    PathPrefix 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.
    SubkeyCollection List<KeyPrefixSubkeyCollection>
    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.

    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 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.
    PathPrefix 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.
    SubkeyCollection []KeyPrefixSubkeyCollectionArgs
    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.

    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 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.
    pathPrefix 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.
    subkeyCollection List<KeyPrefixSubkeyCollection>
    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.

    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 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.
    pathPrefix 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.
    subkeyCollection KeyPrefixSubkeyCollection[]
    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.

    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 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[KeyPrefixSubkeyCollectionArgs]
    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.

    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 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.
    pathPrefix 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.
    subkeyCollection 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.

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

    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).

    Package Details

    Repository
    HashiCorp Consul pulumi/pulumi-consul
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the consul Terraform Provider.
    consul logo
    Consul v3.11.1 published on Friday, Jan 19, 2024 by Pulumi