published on Tuesday, Apr 21, 2026 by Pulumi
published on Tuesday, Apr 21, 2026 by Pulumi
Creates and manages a variable, including it’s contents, within a Nomad cluster.
Warning: this resource will store the sensitive values placed in
itemsin the Terraform’s state file. Take care to protect your state file.
Note: Use
itemsWowithitemsWoVersionwhen you want Terraform to write variable items without storing those values in the state file.
Example Usage
Creating a variable in the default namespace:
import * as pulumi from "@pulumi/pulumi";
import * as nomad from "@pulumi/nomad";
const example = new nomad.Variable("example", {
path: "some/path/of/your/choosing",
items: {
example_key: "example_value",
},
});
import pulumi
import pulumi_nomad as nomad
example = nomad.Variable("example",
path="some/path/of/your/choosing",
items={
"example_key": "example_value",
})
package main
import (
"github.com/pulumi/pulumi-nomad/sdk/v2/go/nomad"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := nomad.NewVariable(ctx, "example", &nomad.VariableArgs{
Path: pulumi.String("some/path/of/your/choosing"),
Items: pulumi.StringMap{
"example_key": pulumi.String("example_value"),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Nomad = Pulumi.Nomad;
return await Deployment.RunAsync(() =>
{
var example = new Nomad.Index.Variable("example", new()
{
Path = "some/path/of/your/choosing",
Items =
{
{ "example_key", "example_value" },
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.nomad.Variable;
import com.pulumi.nomad.VariableArgs;
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 example = new Variable("example", VariableArgs.builder()
.path("some/path/of/your/choosing")
.items(Map.of("example_key", "example_value"))
.build());
}
}
resources:
example:
type: nomad:Variable
properties:
path: some/path/of/your/choosing
items:
example_key: example_value
Creating a variable with write-only items:
import * as pulumi from "@pulumi/pulumi";
import * as nomad from "@pulumi/nomad";
const example = new nomad.Variable("example", {
path: "some/path/of/your/choosing",
itemsWo: JSON.stringify({
example_key: "example_value",
}),
itemsWoVersion: 1,
});
import pulumi
import json
import pulumi_nomad as nomad
example = nomad.Variable("example",
path="some/path/of/your/choosing",
items_wo=json.dumps({
"example_key": "example_value",
}),
items_wo_version=1)
package main
import (
"encoding/json"
"github.com/pulumi/pulumi-nomad/sdk/v2/go/nomad"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
tmpJSON0, err := json.Marshal(map[string]interface{}{
"example_key": "example_value",
})
if err != nil {
return err
}
json0 := string(tmpJSON0)
_, err = nomad.NewVariable(ctx, "example", &nomad.VariableArgs{
Path: pulumi.String("some/path/of/your/choosing"),
ItemsWo: pulumi.String(pulumi.String(json0)),
ItemsWoVersion: pulumi.Int(1),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Nomad = Pulumi.Nomad;
return await Deployment.RunAsync(() =>
{
var example = new Nomad.Index.Variable("example", new()
{
Path = "some/path/of/your/choosing",
ItemsWo = JsonSerializer.Serialize(new Dictionary<string, object?>
{
["example_key"] = "example_value",
}),
ItemsWoVersion = 1,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.nomad.Variable;
import com.pulumi.nomad.VariableArgs;
import static com.pulumi.codegen.internal.Serialization.*;
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 example = new Variable("example", VariableArgs.builder()
.path("some/path/of/your/choosing")
.itemsWo(serializeJson(
jsonObject(
jsonProperty("example_key", "example_value")
)))
.itemsWoVersion(1)
.build());
}
}
resources:
example:
type: nomad:Variable
properties:
path: some/path/of/your/choosing
itemsWo:
fn::toJSON:
example_key: example_value
itemsWoVersion: 1
Creating a variable in a custom namespace:
import * as pulumi from "@pulumi/pulumi";
import * as nomad from "@pulumi/nomad";
const example = new nomad.Namespace("example", {
name: "example",
description: "Example namespace.",
});
const exampleVariable = new nomad.Variable("example", {
path: "some/path/of/your/choosing",
namespace: example.name,
items: {
example_key: "example_value",
},
});
import pulumi
import pulumi_nomad as nomad
example = nomad.Namespace("example",
name="example",
description="Example namespace.")
example_variable = nomad.Variable("example",
path="some/path/of/your/choosing",
namespace=example.name,
items={
"example_key": "example_value",
})
package main
import (
"github.com/pulumi/pulumi-nomad/sdk/v2/go/nomad"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := nomad.NewNamespace(ctx, "example", &nomad.NamespaceArgs{
Name: pulumi.String("example"),
Description: pulumi.String("Example namespace."),
})
if err != nil {
return err
}
_, err = nomad.NewVariable(ctx, "example", &nomad.VariableArgs{
Path: pulumi.String("some/path/of/your/choosing"),
Namespace: example.Name,
Items: pulumi.StringMap{
"example_key": pulumi.String("example_value"),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Nomad = Pulumi.Nomad;
return await Deployment.RunAsync(() =>
{
var example = new Nomad.Index.Namespace("example", new()
{
Name = "example",
Description = "Example namespace.",
});
var exampleVariable = new Nomad.Index.Variable("example", new()
{
Path = "some/path/of/your/choosing",
Namespace = example.Name,
Items =
{
{ "example_key", "example_value" },
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.nomad.Namespace;
import com.pulumi.nomad.NamespaceArgs;
import com.pulumi.nomad.Variable;
import com.pulumi.nomad.VariableArgs;
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 example = new Namespace("example", NamespaceArgs.builder()
.name("example")
.description("Example namespace.")
.build());
var exampleVariable = new Variable("exampleVariable", VariableArgs.builder()
.path("some/path/of/your/choosing")
.namespace(example.name())
.items(Map.of("example_key", "example_value"))
.build());
}
}
resources:
example:
type: nomad:Namespace
properties:
name: example
description: Example namespace.
exampleVariable:
type: nomad:Variable
name: example
properties:
path: some/path/of/your/choosing
namespace: ${example.name}
items:
example_key: example_value
Create Variable Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Variable(name: string, args: VariableArgs, opts?: CustomResourceOptions);@overload
def Variable(resource_name: str,
args: VariableArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Variable(resource_name: str,
opts: Optional[ResourceOptions] = None,
path: Optional[str] = None,
items: Optional[Mapping[str, str]] = None,
items_wo: Optional[str] = None,
items_wo_version: Optional[int] = None,
namespace: Optional[str] = None)func NewVariable(ctx *Context, name string, args VariableArgs, opts ...ResourceOption) (*Variable, error)public Variable(string name, VariableArgs args, CustomResourceOptions? opts = null)
public Variable(String name, VariableArgs args)
public Variable(String name, VariableArgs args, CustomResourceOptions options)
type: nomad:Variable
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 VariableArgs
- 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 VariableArgs
- 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 VariableArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args VariableArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args VariableArgs
- 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 variableResource = new Nomad.Variable("variableResource", new()
{
Path = "string",
Items =
{
{ "string", "string" },
},
ItemsWo = "string",
ItemsWoVersion = 0,
Namespace = "string",
});
example, err := nomad.NewVariable(ctx, "variableResource", &nomad.VariableArgs{
Path: pulumi.String("string"),
Items: pulumi.StringMap{
"string": pulumi.String("string"),
},
ItemsWo: pulumi.String("string"),
ItemsWoVersion: pulumi.Int(0),
Namespace: pulumi.String("string"),
})
var variableResource = new Variable("variableResource", VariableArgs.builder()
.path("string")
.items(Map.of("string", "string"))
.itemsWo("string")
.itemsWoVersion(0)
.namespace("string")
.build());
variable_resource = nomad.Variable("variableResource",
path="string",
items={
"string": "string",
},
items_wo="string",
items_wo_version=0,
namespace="string")
const variableResource = new nomad.Variable("variableResource", {
path: "string",
items: {
string: "string",
},
itemsWo: "string",
itemsWoVersion: 0,
namespace: "string",
});
type: nomad:Variable
properties:
items:
string: string
itemsWo: string
itemsWoVersion: 0
namespace: string
path: string
Variable 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 Variable resource accepts the following input properties:
- Path string
(string: <required>)- A unique path to create the variable at.- Items Dictionary<string, string>
(map[string]string)- An arbitrary map of items to create in the variable. Conflicts withitemsWoanditemsWoVersion.- Items
Wo string - NOTE: This field is write-only and its value will not be updated in state as part of read operations.
(string)- A JSON-encoded map of variable items to write without storing those values in Terraform state. Conflicts withitemsand requiresitemsWoVersion. - Items
Wo intVersion (number)- A version marker foritemsWo. Required when usingitemsWo, conflicts withitems, and should be incremented to apply a new write-only payload.- Namespace string
(string: "default")- The namepsace to create the variable in.
- Path string
(string: <required>)- A unique path to create the variable at.- Items map[string]string
(map[string]string)- An arbitrary map of items to create in the variable. Conflicts withitemsWoanditemsWoVersion.- Items
Wo string - NOTE: This field is write-only and its value will not be updated in state as part of read operations.
(string)- A JSON-encoded map of variable items to write without storing those values in Terraform state. Conflicts withitemsand requiresitemsWoVersion. - Items
Wo intVersion (number)- A version marker foritemsWo. Required when usingitemsWo, conflicts withitems, and should be incremented to apply a new write-only payload.- Namespace string
(string: "default")- The namepsace to create the variable in.
- path String
(string: <required>)- A unique path to create the variable at.- items Map<String,String>
(map[string]string)- An arbitrary map of items to create in the variable. Conflicts withitemsWoanditemsWoVersion.- items
Wo String - NOTE: This field is write-only and its value will not be updated in state as part of read operations.
(string)- A JSON-encoded map of variable items to write without storing those values in Terraform state. Conflicts withitemsand requiresitemsWoVersion. - items
Wo IntegerVersion (number)- A version marker foritemsWo. Required when usingitemsWo, conflicts withitems, and should be incremented to apply a new write-only payload.- namespace String
(string: "default")- The namepsace to create the variable in.
- path string
(string: <required>)- A unique path to create the variable at.- items {[key: string]: string}
(map[string]string)- An arbitrary map of items to create in the variable. Conflicts withitemsWoanditemsWoVersion.- items
Wo string - NOTE: This field is write-only and its value will not be updated in state as part of read operations.
(string)- A JSON-encoded map of variable items to write without storing those values in Terraform state. Conflicts withitemsand requiresitemsWoVersion. - items
Wo numberVersion (number)- A version marker foritemsWo. Required when usingitemsWo, conflicts withitems, and should be incremented to apply a new write-only payload.- namespace string
(string: "default")- The namepsace to create the variable in.
- path str
(string: <required>)- A unique path to create the variable at.- items Mapping[str, str]
(map[string]string)- An arbitrary map of items to create in the variable. Conflicts withitemsWoanditemsWoVersion.- items_
wo str - NOTE: This field is write-only and its value will not be updated in state as part of read operations.
(string)- A JSON-encoded map of variable items to write without storing those values in Terraform state. Conflicts withitemsand requiresitemsWoVersion. - items_
wo_ intversion (number)- A version marker foritemsWo. Required when usingitemsWo, conflicts withitems, and should be incremented to apply a new write-only payload.- namespace str
(string: "default")- The namepsace to create the variable in.
- path String
(string: <required>)- A unique path to create the variable at.- items Map<String>
(map[string]string)- An arbitrary map of items to create in the variable. Conflicts withitemsWoanditemsWoVersion.- items
Wo String - NOTE: This field is write-only and its value will not be updated in state as part of read operations.
(string)- A JSON-encoded map of variable items to write without storing those values in Terraform state. Conflicts withitemsand requiresitemsWoVersion. - items
Wo NumberVersion (number)- A version marker foritemsWo. Required when usingitemsWo, conflicts withitems, and should be incremented to apply a new write-only payload.- namespace String
(string: "default")- The namepsace to create the variable in.
Outputs
All input properties are implicitly available as output properties. Additionally, the Variable 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 Variable Resource
Get an existing Variable 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?: VariableState, opts?: CustomResourceOptions): Variable@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
items: Optional[Mapping[str, str]] = None,
items_wo: Optional[str] = None,
items_wo_version: Optional[int] = None,
namespace: Optional[str] = None,
path: Optional[str] = None) -> Variablefunc GetVariable(ctx *Context, name string, id IDInput, state *VariableState, opts ...ResourceOption) (*Variable, error)public static Variable Get(string name, Input<string> id, VariableState? state, CustomResourceOptions? opts = null)public static Variable get(String name, Output<String> id, VariableState state, CustomResourceOptions options)resources: _: type: nomad:Variable get: id: ${id}- 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.
- Items Dictionary<string, string>
(map[string]string)- An arbitrary map of items to create in the variable. Conflicts withitemsWoanditemsWoVersion.- Items
Wo string - NOTE: This field is write-only and its value will not be updated in state as part of read operations.
(string)- A JSON-encoded map of variable items to write without storing those values in Terraform state. Conflicts withitemsand requiresitemsWoVersion. - Items
Wo intVersion (number)- A version marker foritemsWo. Required when usingitemsWo, conflicts withitems, and should be incremented to apply a new write-only payload.- Namespace string
(string: "default")- The namepsace to create the variable in.- Path string
(string: <required>)- A unique path to create the variable at.
- Items map[string]string
(map[string]string)- An arbitrary map of items to create in the variable. Conflicts withitemsWoanditemsWoVersion.- Items
Wo string - NOTE: This field is write-only and its value will not be updated in state as part of read operations.
(string)- A JSON-encoded map of variable items to write without storing those values in Terraform state. Conflicts withitemsand requiresitemsWoVersion. - Items
Wo intVersion (number)- A version marker foritemsWo. Required when usingitemsWo, conflicts withitems, and should be incremented to apply a new write-only payload.- Namespace string
(string: "default")- The namepsace to create the variable in.- Path string
(string: <required>)- A unique path to create the variable at.
- items Map<String,String>
(map[string]string)- An arbitrary map of items to create in the variable. Conflicts withitemsWoanditemsWoVersion.- items
Wo String - NOTE: This field is write-only and its value will not be updated in state as part of read operations.
(string)- A JSON-encoded map of variable items to write without storing those values in Terraform state. Conflicts withitemsand requiresitemsWoVersion. - items
Wo IntegerVersion (number)- A version marker foritemsWo. Required when usingitemsWo, conflicts withitems, and should be incremented to apply a new write-only payload.- namespace String
(string: "default")- The namepsace to create the variable in.- path String
(string: <required>)- A unique path to create the variable at.
- items {[key: string]: string}
(map[string]string)- An arbitrary map of items to create in the variable. Conflicts withitemsWoanditemsWoVersion.- items
Wo string - NOTE: This field is write-only and its value will not be updated in state as part of read operations.
(string)- A JSON-encoded map of variable items to write without storing those values in Terraform state. Conflicts withitemsand requiresitemsWoVersion. - items
Wo numberVersion (number)- A version marker foritemsWo. Required when usingitemsWo, conflicts withitems, and should be incremented to apply a new write-only payload.- namespace string
(string: "default")- The namepsace to create the variable in.- path string
(string: <required>)- A unique path to create the variable at.
- items Mapping[str, str]
(map[string]string)- An arbitrary map of items to create in the variable. Conflicts withitemsWoanditemsWoVersion.- items_
wo str - NOTE: This field is write-only and its value will not be updated in state as part of read operations.
(string)- A JSON-encoded map of variable items to write without storing those values in Terraform state. Conflicts withitemsand requiresitemsWoVersion. - items_
wo_ intversion (number)- A version marker foritemsWo. Required when usingitemsWo, conflicts withitems, and should be incremented to apply a new write-only payload.- namespace str
(string: "default")- The namepsace to create the variable in.- path str
(string: <required>)- A unique path to create the variable at.
- items Map<String>
(map[string]string)- An arbitrary map of items to create in the variable. Conflicts withitemsWoanditemsWoVersion.- items
Wo String - NOTE: This field is write-only and its value will not be updated in state as part of read operations.
(string)- A JSON-encoded map of variable items to write without storing those values in Terraform state. Conflicts withitemsand requiresitemsWoVersion. - items
Wo NumberVersion (number)- A version marker foritemsWo. Required when usingitemsWo, conflicts withitems, and should be incremented to apply a new write-only payload.- namespace String
(string: "default")- The namepsace to create the variable in.- path String
(string: <required>)- A unique path to create the variable at.
Package Details
- Repository
- HashiCorp Nomad pulumi/pulumi-nomad
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
nomadTerraform Provider.
published on Tuesday, Apr 21, 2026 by Pulumi
