1. Packages
  2. HashiCorp Nomad
  3. API Docs
  4. Variable
Nomad v2.2.0 published on Wednesday, Mar 13, 2024 by Pulumi

nomad.Variable

Explore with Pulumi AI

nomad logo
Nomad v2.2.0 published on Wednesday, Mar 13, 2024 by Pulumi

    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", {
        items: {
            example_key: "example_value",
        },
        path: "some/path/of/your/choosing",
    });
    
    import pulumi
    import pulumi_nomad as nomad
    
    example = nomad.Variable("example",
        items={
            "example_key": "example_value",
        },
        path="some/path/of/your/choosing")
    
    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{
    			Items: pulumi.Map{
    				"example_key": pulumi.Any("example_value"),
    			},
    			Path: pulumi.String("some/path/of/your/choosing"),
    		})
    		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.Variable("example", new()
        {
            Items = 
            {
                { "example_key", "example_value" },
            },
            Path = "some/path/of/your/choosing",
        });
    
    });
    
    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()        
                .items(Map.of("example_key", "example_value"))
                .path("some/path/of/your/choosing")
                .build());
    
        }
    }
    
    resources:
      example:
        type: nomad:Variable
        properties:
          items:
            example_key: example_value
          path: some/path/of/your/choosing
    

    Creating a variable in a custom namespace:

    import * as pulumi from "@pulumi/pulumi";
    import * as nomad from "@pulumi/nomad";
    
    const exampleNamespace = new nomad.Namespace("exampleNamespace", {description: "Example namespace."});
    const exampleVariable = new nomad.Variable("exampleVariable", {
        path: "some/path/of/your/choosing",
        namespace: exampleNamespace.name,
        items: {
            example_key: "example_value",
        },
    });
    
    import pulumi
    import pulumi_nomad as nomad
    
    example_namespace = nomad.Namespace("exampleNamespace", description="Example namespace.")
    example_variable = nomad.Variable("exampleVariable",
        path="some/path/of/your/choosing",
        namespace=example_namespace.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 {
    		exampleNamespace, err := nomad.NewNamespace(ctx, "exampleNamespace", &nomad.NamespaceArgs{
    			Description: pulumi.String("Example namespace."),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = nomad.NewVariable(ctx, "exampleVariable", &nomad.VariableArgs{
    			Path:      pulumi.String("some/path/of/your/choosing"),
    			Namespace: exampleNamespace.Name,
    			Items: pulumi.Map{
    				"example_key": pulumi.Any("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 exampleNamespace = new Nomad.Namespace("exampleNamespace", new()
        {
            Description = "Example namespace.",
        });
    
        var exampleVariable = new Nomad.Variable("exampleVariable", new()
        {
            Path = "some/path/of/your/choosing",
            Namespace = exampleNamespace.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 exampleNamespace = new Namespace("exampleNamespace", NamespaceArgs.builder()        
                .description("Example namespace.")
                .build());
    
            var exampleVariable = new Variable("exampleVariable", VariableArgs.builder()        
                .path("some/path/of/your/choosing")
                .namespace(exampleNamespace.name())
                .items(Map.of("example_key", "example_value"))
                .build());
    
        }
    }
    
    resources:
      exampleNamespace:
        type: nomad:Namespace
        properties:
          description: Example namespace.
      exampleVariable:
        type: nomad:Variable
        properties:
          path: some/path/of/your/choosing
          namespace: ${exampleNamespace.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,
                 items: Optional[Mapping[str, Any]] = 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 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.

    Example

    The following reference example uses placeholder values for all input properties.

    var variableResource = new Nomad.Variable("variableResource", new()
    {
        Items = 
        {
            { "string", "any" },
        },
        Path = "string",
        Namespace = "string",
    });
    
    example, err := nomad.NewVariable(ctx, "variableResource", &nomad.VariableArgs{
    	Items: pulumi.Map{
    		"string": pulumi.Any("any"),
    	},
    	Path:      pulumi.String("string"),
    	Namespace: pulumi.String("string"),
    })
    
    var variableResource = new Variable("variableResource", VariableArgs.builder()        
        .items(Map.of("string", "any"))
        .path("string")
        .namespace("string")
        .build());
    
    variable_resource = nomad.Variable("variableResource",
        items={
            "string": "any",
        },
        path="string",
        namespace="string")
    
    const variableResource = new nomad.Variable("variableResource", {
        items: {
            string: "any",
        },
        path: "string",
        namespace: "string",
    });
    
    type: nomad:Variable
    properties:
        items:
            string: any
        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

    The Variable resource accepts the following input properties:

    Items Dictionary<string, object>
    (map[string]string: <required>) - An arbitrary map of items to create in the variable.
    Path string
    (string: <required>) - A unique path to create the variable at.
    Namespace string
    (string: "default") - The namepsace to create the variable in.
    Items map[string]interface{}
    (map[string]string: <required>) - An arbitrary map of items to create in the variable.
    Path string
    (string: <required>) - A unique path to create the variable at.
    Namespace string
    (string: "default") - The namepsace to create the variable in.
    items Map<String,Object>
    (map[string]string: <required>) - An arbitrary map of items to create in the variable.
    path String
    (string: <required>) - A unique path to create the variable at.
    namespace String
    (string: "default") - The namepsace to create the variable in.
    items {[key: string]: any}
    (map[string]string: <required>) - An arbitrary map of items to create in the variable.
    path string
    (string: <required>) - A unique path to create the variable at.
    namespace string
    (string: "default") - The namepsace to create the variable in.
    items Mapping[str, Any]
    (map[string]string: <required>) - An arbitrary map of items to create in the variable.
    path str
    (string: <required>) - A unique path to create the variable at.
    namespace str
    (string: "default") - The namepsace to create the variable in.
    items Map<Any>
    (map[string]string: <required>) - An arbitrary map of items to create in the variable.
    path String
    (string: <required>) - A unique path to create the variable at.
    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, Any]] = 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)
    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:
    Items Dictionary<string, object>
    (map[string]string: <required>) - An arbitrary map of items to create in the variable.
    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]interface{}
    (map[string]string: <required>) - An arbitrary map of items to create in the variable.
    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,Object>
    (map[string]string: <required>) - An arbitrary map of items to create in the variable.
    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]: any}
    (map[string]string: <required>) - An arbitrary map of items to create in the variable.
    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, Any]
    (map[string]string: <required>) - An arbitrary map of items to create in the variable.
    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<Any>
    (map[string]string: <required>) - An arbitrary map of items to create in the variable.
    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 nomad Terraform Provider.
    nomad logo
    Nomad v2.2.0 published on Wednesday, Mar 13, 2024 by Pulumi