GetKeys
The consul..Keys resource reads values from the Consul key/value store.
This is a powerful way dynamically set values in templates.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
using Consul = Pulumi.Consul;
class MyStack : Stack
{
public MyStack()
{
var appKeys = Output.Create(Consul.GetKeys.InvokeAsync(new Consul.GetKeysArgs
{
Datacenter = "nyc1",
Keys =
{
new Consul.Inputs.GetKeysKeyArgs
{
Default = "ami-1234",
Name = "ami",
Path = "service/app/launch_ami",
},
},
Token = "abcd",
}));
// Start our instance with the dynamic ami value
var appInstance = new Aws.Ec2.Instance("appInstance", new Aws.Ec2.InstanceArgs
{
Ami = appKeys.Apply(appKeys => appKeys.Var.Ami),
});
}
}
Coming soon!
import pulumi
import pulumi_aws as aws
import pulumi_consul as consul
app_keys = consul.get_keys(datacenter="nyc1",
keys=[{
"default": "ami-1234",
"name": "ami",
"path": "service/app/launch_ami",
}],
token="abcd")
# Start our instance with the dynamic ami value
app_instance = aws.ec2.Instance("appInstance", ami=app_keys.var["ami"])import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as consul from "@pulumi/consul";
const appKeys = pulumi.output(consul.getKeys({
datacenter: "nyc1",
// Read the launch AMI from Consul
keys: [{
default: "ami-1234",
name: "ami",
path: "service/app/launch_ami",
}],
token: "abcd",
}, { async: true }));
// Start our instance with the dynamic ami value
const appInstance = new aws.ec2.Instance("app", {
ami: appKeys.var.ami,
});Using GetKeys
function getKeys(args: GetKeysArgs, opts?: InvokeOptions): Promise<GetKeysResult>function get_keys(datacenter=None, keys=None, namespace=None, token=None, opts=None)func LookupKeys(ctx *Context, args *LookupKeysArgs, opts ...InvokeOption) (*LookupKeysResult, error)Note: This function is named
LookupKeysin the Go SDK.
public static class GetKeys {
public static Task<GetKeysResult> InvokeAsync(GetKeysArgs args, InvokeOptions? opts = null)
}The following arguments are supported:
- Datacenter string
The datacenter to use. This overrides the agent’s default datacenter and the datacenter in the provider setup.
- Keys
List<Get
Keys Key Args> Specifies a key in Consul to be read. Supported values documented below. Multiple blocks supported.
- Namespace string
The namespace to lookup the keys.
- 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.
- Keys
[]Get
Keys Key Specifies a key in Consul to be read. Supported values documented below. Multiple blocks supported.
- Namespace string
The namespace to lookup the keys.
- 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.
- keys
Get
Keys Key[] Specifies a key in Consul to be read. Supported values documented below. Multiple blocks supported.
- namespace string
The namespace to lookup the keys.
- 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.
- keys
List[Get
Keys Key] Specifies a key in Consul to be read. Supported values documented below. Multiple blocks supported.
- namespace str
The namespace to lookup the keys.
- token str
The ACL token to use. This overrides the token that the agent provides by default.
GetKeys Result
The following output properties are available:
Supporting Types
GetKeysKey
- Name string
This is the name of the key. This value of the key is exposed as
var.<name>. This is not the path of the key in Consul.- Path string
This is the path in Consul that should be read or written to.
- Default string
This is the default value to set for
var.<name>if the key does not exist in Consul. Defaults to an empty string.
- Name string
This is the name of the key. This value of the key is exposed as
var.<name>. This is not the path of the key in Consul.- Path string
This is the path in Consul that should be read or written to.
- Default string
This is the default value to set for
var.<name>if the key does not exist in Consul. Defaults to an empty string.
- name string
This is the name of the key. This value of the key is exposed as
var.<name>. This is not the path of the key in Consul.- path string
This is the path in Consul that should be read or written to.
- default string
This is the default value to set for
var.<name>if the key does not exist in Consul. Defaults to an empty string.
- name str
This is the name of the key. This value of the key is exposed as
var.<name>. This is not the path of the key in Consul.- path str
This is the path in Consul that should be read or written to.
- default str
This is the default value to set for
var.<name>if the key does not exist in Consul. Defaults to an empty string.
Package Details
- Repository
- https://github.com/pulumi/pulumi-consul
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
consulTerraform Provider.