nomad.AclPolicy

Manages an ACL policy registered in Nomad.

Example Usage

Registering a policy from a HCL file

using System.Collections.Generic;
using System.IO;
using Pulumi;
using Nomad = Pulumi.Nomad;

return await Deployment.RunAsync(() => 
{
    var dev = new Nomad.AclPolicy("dev", new()
    {
        Description = "Submit jobs to the dev environment.",
        RulesHcl = File.ReadAllText($"{path.Module}/dev.hcl"),
    });

});
package main

import (
	"fmt"
	"os"

	"github.com/pulumi/pulumi-nomad/sdk/go/nomad"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func readFileOrPanic(path string) pulumi.StringPtrInput {
	data, err := os.ReadFile(path)
	if err != nil {
		panic(err.Error())
	}
	return pulumi.String(string(data))
}

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := nomad.NewAclPolicy(ctx, "dev", &nomad.AclPolicyArgs{
			Description: pulumi.String("Submit jobs to the dev environment."),
			RulesHcl:    readFileOrPanic(fmt.Sprintf("%v/dev.hcl", path.Module)),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.nomad.AclPolicy;
import com.pulumi.nomad.AclPolicyArgs;
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 dev = new AclPolicy("dev", AclPolicyArgs.builder()        
            .description("Submit jobs to the dev environment.")
            .rulesHcl(Files.readString(Paths.get(String.format("%s/dev.hcl", path.module()))))
            .build());

    }
}
import pulumi
import pulumi_nomad as nomad

dev = nomad.AclPolicy("dev",
    description="Submit jobs to the dev environment.",
    rules_hcl=(lambda path: open(path).read())(f"{path['module']}/dev.hcl"))
import * as pulumi from "@pulumi/pulumi";
import * as fs from "fs";
import * as nomad from "@pulumi/nomad";

const dev = new nomad.AclPolicy("dev", {
    description: "Submit jobs to the dev environment.",
    rulesHcl: fs.readFileSync(`${path.module}/dev.hcl`),
});
resources:
  dev:
    type: nomad:AclPolicy
    properties:
      description: Submit jobs to the dev environment.
      rulesHcl:
        fn::readFile: ${path.module}/dev.hcl

Registering a policy from inline HCL

using System.Collections.Generic;
using Pulumi;
using Nomad = Pulumi.Nomad;

return await Deployment.RunAsync(() => 
{
    var dev = new Nomad.AclPolicy("dev", new()
    {
        Description = "Submit jobs to the dev environment.",
        RulesHcl = @"namespace ""dev"" {
  policy = ""write""
}

",
    });

});
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-nomad/sdk/go/nomad"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := nomad.NewAclPolicy(ctx, "dev", &nomad.AclPolicyArgs{
			Description: pulumi.String("Submit jobs to the dev environment."),
			RulesHcl:    pulumi.String(fmt.Sprintf("namespace \"dev\" {\n  policy = \"write\"\n}\n\n")),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.nomad.AclPolicy;
import com.pulumi.nomad.AclPolicyArgs;
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 dev = new AclPolicy("dev", AclPolicyArgs.builder()        
            .description("Submit jobs to the dev environment.")
            .rulesHcl("""
namespace "dev" {
  policy = "write"
}

            """)
            .build());

    }
}
import pulumi
import pulumi_nomad as nomad

dev = nomad.AclPolicy("dev",
    description="Submit jobs to the dev environment.",
    rules_hcl="""namespace "dev" {
  policy = "write"
}

""")
import * as pulumi from "@pulumi/pulumi";
import * as nomad from "@pulumi/nomad";

const dev = new nomad.AclPolicy("dev", {
    description: "Submit jobs to the dev environment.",
    rulesHcl: `namespace "dev" {
  policy = "write"
}

`,
});
resources:
  dev:
    type: nomad:AclPolicy
    properties:
      description: Submit jobs to the dev environment.
      rulesHcl: |+
        namespace "dev" {
          policy = "write"
        }        

Create AclPolicy Resource

new AclPolicy(name: string, args: AclPolicyArgs, opts?: CustomResourceOptions);
@overload
def AclPolicy(resource_name: str,
              opts: Optional[ResourceOptions] = None,
              description: Optional[str] = None,
              name: Optional[str] = None,
              rules_hcl: Optional[str] = None)
@overload
def AclPolicy(resource_name: str,
              args: AclPolicyArgs,
              opts: Optional[ResourceOptions] = None)
func NewAclPolicy(ctx *Context, name string, args AclPolicyArgs, opts ...ResourceOption) (*AclPolicy, error)
public AclPolicy(string name, AclPolicyArgs args, CustomResourceOptions? opts = null)
public AclPolicy(String name, AclPolicyArgs args)
public AclPolicy(String name, AclPolicyArgs args, CustomResourceOptions options)
type: nomad:AclPolicy
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args AclPolicyArgs
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 AclPolicyArgs
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 AclPolicyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args AclPolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args AclPolicyArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

AclPolicy 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 AclPolicy resource accepts the following input properties:

RulesHcl string

(string: <required>) - The contents of the policy to register, as HCL or JSON.

Description string

(string: "") - A description of the policy.

Name string

(string: <required>) - A unique name for the policy.

RulesHcl string

(string: <required>) - The contents of the policy to register, as HCL or JSON.

Description string

(string: "") - A description of the policy.

Name string

(string: <required>) - A unique name for the policy.

rulesHcl String

(string: <required>) - The contents of the policy to register, as HCL or JSON.

description String

(string: "") - A description of the policy.

name String

(string: <required>) - A unique name for the policy.

rulesHcl string

(string: <required>) - The contents of the policy to register, as HCL or JSON.

description string

(string: "") - A description of the policy.

name string

(string: <required>) - A unique name for the policy.

rules_hcl str

(string: <required>) - The contents of the policy to register, as HCL or JSON.

description str

(string: "") - A description of the policy.

name str

(string: <required>) - A unique name for the policy.

rulesHcl String

(string: <required>) - The contents of the policy to register, as HCL or JSON.

description String

(string: "") - A description of the policy.

name String

(string: <required>) - A unique name for the policy.

Outputs

All input properties are implicitly available as output properties. Additionally, the AclPolicy 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 AclPolicy Resource

Get an existing AclPolicy 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?: AclPolicyState, opts?: CustomResourceOptions): AclPolicy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        description: Optional[str] = None,
        name: Optional[str] = None,
        rules_hcl: Optional[str] = None) -> AclPolicy
func GetAclPolicy(ctx *Context, name string, id IDInput, state *AclPolicyState, opts ...ResourceOption) (*AclPolicy, error)
public static AclPolicy Get(string name, Input<string> id, AclPolicyState? state, CustomResourceOptions? opts = null)
public static AclPolicy get(String name, Output<String> id, AclPolicyState 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:
Description string

(string: "") - A description of the policy.

Name string

(string: <required>) - A unique name for the policy.

RulesHcl string

(string: <required>) - The contents of the policy to register, as HCL or JSON.

Description string

(string: "") - A description of the policy.

Name string

(string: <required>) - A unique name for the policy.

RulesHcl string

(string: <required>) - The contents of the policy to register, as HCL or JSON.

description String

(string: "") - A description of the policy.

name String

(string: <required>) - A unique name for the policy.

rulesHcl String

(string: <required>) - The contents of the policy to register, as HCL or JSON.

description string

(string: "") - A description of the policy.

name string

(string: <required>) - A unique name for the policy.

rulesHcl string

(string: <required>) - The contents of the policy to register, as HCL or JSON.

description str

(string: "") - A description of the policy.

name str

(string: <required>) - A unique name for the policy.

rules_hcl str

(string: <required>) - The contents of the policy to register, as HCL or JSON.

description String

(string: "") - A description of the policy.

name String

(string: <required>) - A unique name for the policy.

rulesHcl String

(string: <required>) - The contents of the policy to register, as HCL or JSON.

Package Details

Repository
HashiCorp Nomad pulumi/pulumi-nomad
License
Apache-2.0
Notes

This Pulumi package is based on the nomad Terraform Provider.