Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

ConfigEntry

The Configuration Entry resource can be used to provide cluster-wide defaults for various aspects of Consul.

Example Usage

using System.Collections.Generic;
using System.Text.Json;
using Pulumi;
using Consul = Pulumi.Consul;

class MyStack : Stack
{
    public MyStack()
    {
        var proxyDefaults = new Consul.ConfigEntry("proxyDefaults", new Consul.ConfigEntryArgs
        {
            Kind = "proxy-defaults",
            ConfigJson = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                { "Config", new Dictionary<string, object?>
                {
                    { "local_connect_timeout_ms", 1000 },
                    { "handshake_timeout_ms", 10000 },
                } },
            }),
        });
        var web = new Consul.ConfigEntry("web", new Consul.ConfigEntryArgs
        {
            Kind = "service-defaults",
            ConfigJson = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                { "Protocol", "http" },
            }),
        });
        var admin = new Consul.ConfigEntry("admin", new Consul.ConfigEntryArgs
        {
            Kind = "service-defaults",
            ConfigJson = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                { "Protocol", "http" },
            }),
        });
        var serviceResolver = new Consul.ConfigEntry("serviceResolver", new Consul.ConfigEntryArgs
        {
            Kind = "service-resolver",
            ConfigJson = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                { "DefaultSubset", "v1" },
                { "Subsets", new Dictionary<string, object?>
                {
                    { "v1", new Dictionary<string, object?>
                    {
                        { "Filter", "Service.Meta.version == v1" },
                    } },
                    { "v2", new Dictionary<string, object?>
                    {
                        { "Filter", "Service.Meta.version == v2" },
                    } },
                } },
            }),
        });
        var serviceSplitter = new Consul.ConfigEntry("serviceSplitter", new Consul.ConfigEntryArgs
        {
            Kind = "service-splitter",
            ConfigJson = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                { "Splits", new[]
                    {
                        new Dictionary<string, object?>
                        {
                            { "Weight", 90 },
                            { "ServiceSubset", "v1" },
                        },
                        new Dictionary<string, object?>
                        {
                            { "Weight", 10 },
                            { "ServiceSubset", "v2" },
                        },
                    }
                 },
            }),
        });
        var serviceRouter = new Consul.ConfigEntry("serviceRouter", new Consul.ConfigEntryArgs
        {
            Kind = "service-router",
            ConfigJson = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                { "Routes", new[]
                    {
                        new Dictionary<string, object?>
                        {
                            { "Match", new Dictionary<string, object?>
                            {
                                { "HTTP", new Dictionary<string, object?>
                                {
                                    { "PathPrefix", "/admin" },
                                } },
                            } },
                            { "Destination", new Dictionary<string, object?>
                            {
                                { "Service", "admin" },
                            } },
                        },
                    }
                 },
            }),
        });
        var ingressGateway = new Consul.ConfigEntry("ingressGateway", new Consul.ConfigEntryArgs
        {
            Kind = "ingress-gateway",
            ConfigJson = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                { "TLS", new Dictionary<string, object?>
                {
                    { "Enabled", true },
                } },
                { "Listeners", new[]
                    {
                        new Dictionary<string, object?>
                        {
                            { "Port", 8000 },
                            { "Protocol", "http" },
                            { "Services", new[]
                                {
                                    new Dictionary<string, object?>
                                    {
                                        { "Name", "*" },
                                    },
                                }
                             },
                        },
                    }
                 },
            }),
        });
        var terminatingGateway = new Consul.ConfigEntry("terminatingGateway", new Consul.ConfigEntryArgs
        {
            Kind = "terminating-gateway",
            ConfigJson = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                { "Services", new[]
                    {
                        new Dictionary<string, object?>
                        {
                            { "Name", "billing" },
                        },
                    }
                 },
            }),
        });
    }

}
package main

import (
    "encoding/json"

    "github.com/pulumi/pulumi-consul/sdk/v2/go/consul"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        tmpJSON0, err := json.Marshal(map[string]interface{}{
            "Config": map[string]interface{}{
                "local_connect_timeout_ms": 1000,
                "handshake_timeout_ms":     10000,
            },
        })
        if err != nil {
            return err
        }
        json0 := string(tmpJSON0)
        _, err := consul.NewConfigEntry(ctx, "proxyDefaults", &consul.ConfigEntryArgs{
            Kind:       pulumi.String("proxy-defaults"),
            ConfigJson: pulumi.String(json0),
        })
        if err != nil {
            return err
        }
        tmpJSON1, err := json.Marshal(map[string]interface{}{
            "Protocol": "http",
        })
        if err != nil {
            return err
        }
        json1 := string(tmpJSON1)
        _, err = consul.NewConfigEntry(ctx, "web", &consul.ConfigEntryArgs{
            Kind:       pulumi.String("service-defaults"),
            ConfigJson: pulumi.String(json1),
        })
        if err != nil {
            return err
        }
        tmpJSON2, err := json.Marshal(map[string]interface{}{
            "Protocol": "http",
        })
        if err != nil {
            return err
        }
        json2 := string(tmpJSON2)
        _, err = consul.NewConfigEntry(ctx, "admin", &consul.ConfigEntryArgs{
            Kind:       pulumi.String("service-defaults"),
            ConfigJson: pulumi.String(json2),
        })
        if err != nil {
            return err
        }
        tmpJSON3, err := json.Marshal(map[string]interface{}{
            "DefaultSubset": "v1",
            "Subsets": map[string]interface{}{
                "v1": map[string]interface{}{
                    "Filter": "Service.Meta.version == v1",
                },
                "v2": map[string]interface{}{
                    "Filter": "Service.Meta.version == v2",
                },
            },
        })
        if err != nil {
            return err
        }
        json3 := string(tmpJSON3)
        _, err = consul.NewConfigEntry(ctx, "serviceResolver", &consul.ConfigEntryArgs{
            Kind:       pulumi.String("service-resolver"),
            ConfigJson: pulumi.String(json3),
        })
        if err != nil {
            return err
        }
        tmpJSON4, err := json.Marshal(map[string]interface{}{
            "Splits": []map[string]interface{}{
                map[string]interface{}{
                    "Weight":        90,
                    "ServiceSubset": "v1",
                },
                map[string]interface{}{
                    "Weight":        10,
                    "ServiceSubset": "v2",
                },
            },
        })
        if err != nil {
            return err
        }
        json4 := string(tmpJSON4)
        _, err = consul.NewConfigEntry(ctx, "serviceSplitter", &consul.ConfigEntryArgs{
            Kind:       pulumi.String("service-splitter"),
            ConfigJson: pulumi.String(json4),
        })
        if err != nil {
            return err
        }
        tmpJSON5, err := json.Marshal(map[string]interface{}{
            "Routes": []map[string]interface{}{
                map[string]interface{}{
                    "Match": map[string]interface{}{
                        "HTTP": map[string]interface{}{
                            "PathPrefix": "/admin",
                        },
                    },
                    "Destination": map[string]interface{}{
                        "Service": "admin",
                    },
                },
            },
        })
        if err != nil {
            return err
        }
        json5 := string(tmpJSON5)
        _, err = consul.NewConfigEntry(ctx, "serviceRouter", &consul.ConfigEntryArgs{
            Kind:       pulumi.String("service-router"),
            ConfigJson: pulumi.String(json5),
        })
        if err != nil {
            return err
        }
        tmpJSON6, err := json.Marshal(map[string]interface{}{
            "TLS": map[string]interface{}{
                "Enabled": true,
            },
            "Listeners": []map[string]interface{}{
                map[string]interface{}{
                    "Port":     8000,
                    "Protocol": "http",
                    "Services": []map[string]interface{}{
                        map[string]interface{}{
                            "Name": "*",
                        },
                    },
                },
            },
        })
        if err != nil {
            return err
        }
        json6 := string(tmpJSON6)
        _, err = consul.NewConfigEntry(ctx, "ingressGateway", &consul.ConfigEntryArgs{
            Kind:       pulumi.String("ingress-gateway"),
            ConfigJson: pulumi.String(json6),
        })
        if err != nil {
            return err
        }
        tmpJSON7, err := json.Marshal(map[string]interface{}{
            "Services": []map[string]interface{}{
                map[string]interface{}{
                    "Name": "billing",
                },
            },
        })
        if err != nil {
            return err
        }
        json7 := string(tmpJSON7)
        _, err = consul.NewConfigEntry(ctx, "terminatingGateway", &consul.ConfigEntryArgs{
            Kind:       pulumi.String("terminating-gateway"),
            ConfigJson: pulumi.String(json7),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import json
import pulumi_consul as consul

proxy_defaults = consul.ConfigEntry("proxyDefaults",
    kind="proxy-defaults",
    config_json=json.dumps({
        "Config": {
            "local_connect_timeout_ms": 1000,
            "handshake_timeout_ms": 10000,
        },
    }))
web = consul.ConfigEntry("web",
    kind="service-defaults",
    config_json=json.dumps({
        "Protocol": "http",
    }))
admin = consul.ConfigEntry("admin",
    kind="service-defaults",
    config_json=json.dumps({
        "Protocol": "http",
    }))
service_resolver = consul.ConfigEntry("serviceResolver",
    kind="service-resolver",
    config_json=json.dumps({
        "DefaultSubset": "v1",
        "Subsets": {
            "v1": {
                "Filter": "Service.Meta.version == v1",
            },
            "v2": {
                "Filter": "Service.Meta.version == v2",
            },
        },
    }))
service_splitter = consul.ConfigEntry("serviceSplitter",
    kind="service-splitter",
    config_json=json.dumps({
        "Splits": [
            {
                "Weight": 90,
                "ServiceSubset": "v1",
            },
            {
                "Weight": 10,
                "ServiceSubset": "v2",
            },
        ],
    }))
service_router = consul.ConfigEntry("serviceRouter",
    kind="service-router",
    config_json=json.dumps({
        "Routes": [{
            "Match": {
                "HTTP": {
                    "PathPrefix": "/admin",
                },
            },
            "Destination": {
                "Service": "admin",
            },
        }],
    }))
ingress_gateway = consul.ConfigEntry("ingressGateway",
    kind="ingress-gateway",
    config_json=json.dumps({
        "TLS": {
            "Enabled": True,
        },
        "Listeners": [{
            "Port": 8000,
            "Protocol": "http",
            "Services": [{
                "Name": "*",
            }],
        }],
    }))
terminating_gateway = consul.ConfigEntry("terminatingGateway",
    kind="terminating-gateway",
    config_json=json.dumps({
        "Services": [{
            "Name": "billing",
        }],
    }))
import * as pulumi from "@pulumi/pulumi";
import * as consul from "@pulumi/consul";

const proxyDefaults = new consul.ConfigEntry("proxyDefaults", {
    kind: "proxy-defaults",
    configJson: JSON.stringify({
        Config: {
            local_connect_timeout_ms: 1000,
            handshake_timeout_ms: 10000,
        },
    }),
});
const web = new consul.ConfigEntry("web", {
    kind: "service-defaults",
    configJson: JSON.stringify({
        Protocol: "http",
    }),
});
const admin = new consul.ConfigEntry("admin", {
    kind: "service-defaults",
    configJson: JSON.stringify({
        Protocol: "http",
    }),
});
const serviceResolver = new consul.ConfigEntry("serviceResolver", {
    kind: "service-resolver",
    configJson: JSON.stringify({
        DefaultSubset: "v1",
        Subsets: {
            v1: {
                Filter: "Service.Meta.version == v1",
            },
            v2: {
                Filter: "Service.Meta.version == v2",
            },
        },
    }),
});
const serviceSplitter = new consul.ConfigEntry("serviceSplitter", {
    kind: "service-splitter",
    configJson: JSON.stringify({
        Splits: [
            {
                Weight: 90,
                ServiceSubset: "v1",
            },
            {
                Weight: 10,
                ServiceSubset: "v2",
            },
        ],
    }),
});
const serviceRouter = new consul.ConfigEntry("serviceRouter", {
    kind: "service-router",
    configJson: JSON.stringify({
        Routes: [{
            Match: {
                HTTP: {
                    PathPrefix: "/admin",
                },
            },
            Destination: {
                Service: "admin",
            },
        }],
    }),
});
const ingressGateway = new consul.ConfigEntry("ingressGateway", {
    kind: "ingress-gateway",
    configJson: JSON.stringify({
        TLS: {
            Enabled: true,
        },
        Listeners: [{
            Port: 8000,
            Protocol: "http",
            Services: [{
                Name: "*",
            }],
        }],
    }),
});
const terminatingGateway = new consul.ConfigEntry("terminatingGateway", {
    kind: "terminating-gateway",
    configJson: JSON.stringify({
        Services: [{
            Name: "billing",
        }],
    }),
});

service-intentions config entry

using System.Collections.Generic;
using System.Text.Json;
using Pulumi;
using Consul = Pulumi.Consul;

class MyStack : Stack
{
    public MyStack()
    {
        var serviceIntentions = new Consul.ConfigEntry("serviceIntentions", new Consul.ConfigEntryArgs
        {
            Kind = "service-intentions",
            ConfigJson = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                { "Sources", new[]
                    {
                        new Dictionary<string, object?>
                        {
                            { "Action", "allow" },
                            { "Name", "frontend-webapp" },
                            { "Precedence", 9 },
                            { "Type", "consul" },
                        },
                        new Dictionary<string, object?>
                        {
                            { "Action", "allow" },
                            { "Name", "nightly-cronjob" },
                            { "Precedence", 9 },
                            { "Type", "consul" },
                        },
                    }
                 },
            }),
        });
    }

}
package main

import (
    "encoding/json"

    "github.com/pulumi/pulumi-consul/sdk/v2/go/consul"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        tmpJSON0, err := json.Marshal(map[string]interface{}{
            "Sources": []map[string]interface{}{
                map[string]interface{}{
                    "Action":     "allow",
                    "Name":       "frontend-webapp",
                    "Precedence": 9,
                    "Type":       "consul",
                },
                map[string]interface{}{
                    "Action":     "allow",
                    "Name":       "nightly-cronjob",
                    "Precedence": 9,
                    "Type":       "consul",
                },
            },
        })
        if err != nil {
            return err
        }
        json0 := string(tmpJSON0)
        _, err := consul.NewConfigEntry(ctx, "serviceIntentions", &consul.ConfigEntryArgs{
            Kind:       pulumi.String("service-intentions"),
            ConfigJson: pulumi.String(json0),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import json
import pulumi_consul as consul

service_intentions = consul.ConfigEntry("serviceIntentions",
    kind="service-intentions",
    config_json=json.dumps({
        "Sources": [
            {
                "Action": "allow",
                "Name": "frontend-webapp",
                "Precedence": 9,
                "Type": "consul",
            },
            {
                "Action": "allow",
                "Name": "nightly-cronjob",
                "Precedence": 9,
                "Type": "consul",
            },
        ],
    }))
import * as pulumi from "@pulumi/pulumi";
import * as consul from "@pulumi/consul";

const serviceIntentions = new consul.ConfigEntry("serviceIntentions", {
    kind: "service-intentions",
    configJson: JSON.stringify({
        Sources: [
            {
                Action: "allow",
                Name: "frontend-webapp",
                Precedence: 9,
                Type: "consul",
            },
            {
                Action: "allow",
                Name: "nightly-cronjob",
                Precedence: 9,
                Type: "consul",
            },
        ],
    }),
});

Create a ConfigEntry Resource

new ConfigEntry(name: string, args: ConfigEntryArgs, opts?: CustomResourceOptions);
def ConfigEntry(resource_name: str, opts: Optional[ResourceOptions] = None, config_json: Optional[str] = None, kind: Optional[str] = None, name: Optional[str] = None)
func NewConfigEntry(ctx *Context, name string, args ConfigEntryArgs, opts ...ResourceOption) (*ConfigEntry, error)
public ConfigEntry(string name, ConfigEntryArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args ConfigEntryArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args ConfigEntryArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args ConfigEntryArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

ConfigEntry Resource Properties

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

Inputs

The ConfigEntry resource accepts the following input properties:

Kind string

The kind of configuration entry to register.

ConfigJson string

An arbitrary map of configuration values.

Name string

The name of the configuration entry being registred.

Kind string

The kind of configuration entry to register.

ConfigJson string

An arbitrary map of configuration values.

Name string

The name of the configuration entry being registred.

kind string

The kind of configuration entry to register.

configJson string

An arbitrary map of configuration values.

name string

The name of the configuration entry being registred.

kind str

The kind of configuration entry to register.

config_json str

An arbitrary map of configuration values.

name str

The name of the configuration entry being registred.

Outputs

All input properties are implicitly available as output properties. Additionally, the ConfigEntry 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 str
The provider-assigned unique ID for this managed resource.

Look up an Existing ConfigEntry Resource

Get an existing ConfigEntry 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?: ConfigEntryState, opts?: CustomResourceOptions): ConfigEntry
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, config_json: Optional[str] = None, kind: Optional[str] = None, name: Optional[str] = None) -> ConfigEntry
func GetConfigEntry(ctx *Context, name string, id IDInput, state *ConfigEntryState, opts ...ResourceOption) (*ConfigEntry, error)
public static ConfigEntry Get(string name, Input<string> id, ConfigEntryState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

ConfigJson string

An arbitrary map of configuration values.

Kind string

The kind of configuration entry to register.

Name string

The name of the configuration entry being registred.

ConfigJson string

An arbitrary map of configuration values.

Kind string

The kind of configuration entry to register.

Name string

The name of the configuration entry being registred.

configJson string

An arbitrary map of configuration values.

kind string

The kind of configuration entry to register.

name string

The name of the configuration entry being registred.

config_json str

An arbitrary map of configuration values.

kind str

The kind of configuration entry to register.

name str

The name of the configuration entry being registred.

Package Details

Repository
https://github.com/pulumi/pulumi-consul
License
Apache-2.0
Notes
This Pulumi package is based on the consul Terraform Provider.