1. Packages
  2. Nomad Provider
  3. API Docs
  4. Variable
Nomad v2.5.0 published on Thursday, Apr 17, 2025 by Pulumi

nomad.Variable

Explore with Pulumi AI

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",
    },
});
Copy
import pulumi
import pulumi_nomad as nomad

example = nomad.Variable("example",
    path="some/path/of/your/choosing",
    items={
        "example_key": "example_value",
    })
Copy
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
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Nomad = Pulumi.Nomad;

return await Deployment.RunAsync(() => 
{
    var example = new Nomad.Variable("example", new()
    {
        Path = "some/path/of/your/choosing",
        Items = 
        {
            { "example_key", "example_value" },
        },
    });

});
Copy
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());

    }
}
Copy
resources:
  example:
    type: nomad:Variable
    properties:
      path: some/path/of/your/choosing
      items:
        example_key: example_value
Copy

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",
    },
});
Copy
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",
    })
Copy
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
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Nomad = Pulumi.Nomad;

return await Deployment.RunAsync(() => 
{
    var example = new Nomad.Namespace("example", new()
    {
        Name = "example",
        Description = "Example namespace.",
    });

    var exampleVariable = new Nomad.Variable("example", new()
    {
        Path = "some/path/of/your/choosing",
        Namespace = example.Name,
        Items = 
        {
            { "example_key", "example_value" },
        },
    });

});
Copy
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());

    }
}
Copy
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
Copy

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,
             items: Optional[Mapping[str, str]] = None,
             path: Optional[str] = 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 This property is required. string
The unique name of the resource.
args This property is required. VariableArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. 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 This property is required. string
The unique name of the resource.
args This property is required. VariableArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. VariableArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. 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()
{
    Items = 
    {
        { "string", "string" },
    },
    Path = "string",
    Namespace = "string",
});
Copy
example, err := nomad.NewVariable(ctx, "variableResource", &nomad.VariableArgs{
	Items: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	Path:      pulumi.String("string"),
	Namespace: pulumi.String("string"),
})
Copy
var variableResource = new Variable("variableResource", VariableArgs.builder()
    .items(Map.of("string", "string"))
    .path("string")
    .namespace("string")
    .build());
Copy
variable_resource = nomad.Variable("variableResource",
    items={
        "string": "string",
    },
    path="string",
    namespace="string")
Copy
const variableResource = new nomad.Variable("variableResource", {
    items: {
        string: "string",
    },
    path: "string",
    namespace: "string",
});
Copy
type: nomad:Variable
properties:
    items:
        string: string
    namespace: string
    path: string
Copy

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:

Items This property is required. Dictionary<string, string>
(map[string]string: <required>) - An arbitrary map of items to create in the variable.
Path
This property is required.
Changes to this property will trigger replacement.
string
(string: <required>) - A unique path to create the variable at.
Namespace Changes to this property will trigger replacement. string
(string: "default") - The namepsace to create the variable in.
Items This property is required. map[string]string
(map[string]string: <required>) - An arbitrary map of items to create in the variable.
Path
This property is required.
Changes to this property will trigger replacement.
string
(string: <required>) - A unique path to create the variable at.
Namespace Changes to this property will trigger replacement. string
(string: "default") - The namepsace to create the variable in.
items This property is required. Map<String,String>
(map[string]string: <required>) - An arbitrary map of items to create in the variable.
path
This property is required.
Changes to this property will trigger replacement.
String
(string: <required>) - A unique path to create the variable at.
namespace Changes to this property will trigger replacement. String
(string: "default") - The namepsace to create the variable in.
items This property is required. {[key: string]: string}
(map[string]string: <required>) - An arbitrary map of items to create in the variable.
path
This property is required.
Changes to this property will trigger replacement.
string
(string: <required>) - A unique path to create the variable at.
namespace Changes to this property will trigger replacement. string
(string: "default") - The namepsace to create the variable in.
items This property is required. Mapping[str, str]
(map[string]string: <required>) - An arbitrary map of items to create in the variable.
path
This property is required.
Changes to this property will trigger replacement.
str
(string: <required>) - A unique path to create the variable at.
namespace Changes to this property will trigger replacement. str
(string: "default") - The namepsace to create the variable in.
items This property is required. Map<String>
(map[string]string: <required>) - An arbitrary map of items to create in the variable.
path
This property is required.
Changes to this property will trigger replacement.
String
(string: <required>) - A unique path to create the variable at.
namespace Changes to this property will trigger replacement. 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,
        namespace: Optional[str] = None,
        path: Optional[str] = None) -> Variable
func 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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
Items Dictionary<string, string>
(map[string]string: <required>) - An arbitrary map of items to create in the variable.
Namespace Changes to this property will trigger replacement. string
(string: "default") - The namepsace to create the variable in.
Path Changes to this property will trigger replacement. string
(string: <required>) - A unique path to create the variable at.
Items map[string]string
(map[string]string: <required>) - An arbitrary map of items to create in the variable.
Namespace Changes to this property will trigger replacement. string
(string: "default") - The namepsace to create the variable in.
Path Changes to this property will trigger replacement. string
(string: <required>) - A unique path to create the variable at.
items Map<String,String>
(map[string]string: <required>) - An arbitrary map of items to create in the variable.
namespace Changes to this property will trigger replacement. String
(string: "default") - The namepsace to create the variable in.
path Changes to this property will trigger replacement. String
(string: <required>) - A unique path to create the variable at.
items {[key: string]: string}
(map[string]string: <required>) - An arbitrary map of items to create in the variable.
namespace Changes to this property will trigger replacement. string
(string: "default") - The namepsace to create the variable in.
path Changes to this property will trigger replacement. string
(string: <required>) - A unique path to create the variable at.
items Mapping[str, str]
(map[string]string: <required>) - An arbitrary map of items to create in the variable.
namespace Changes to this property will trigger replacement. str
(string: "default") - The namepsace to create the variable in.
path Changes to this property will trigger replacement. str
(string: <required>) - A unique path to create the variable at.
items Map<String>
(map[string]string: <required>) - An arbitrary map of items to create in the variable.
namespace Changes to this property will trigger replacement. String
(string: "default") - The namepsace to create the variable in.
path Changes to this property will trigger replacement. 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 nomad Terraform Provider.