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

nomad.AclPolicy

Explore with Pulumi AI

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

    Manages an ACL policy registered in Nomad.

    Example Usage

    Registering a policy from a HCL file:

    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`, "utf8"),
    });
    
    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"))
    
    package main
    
    import (
    	"fmt"
    	"os"
    
    	"github.com/pulumi/pulumi-nomad/sdk/v2/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
    	})
    }
    
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    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 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());
    
        }
    }
    
    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:

    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"
    }
    
    `,
    });
    
    import pulumi
    import pulumi_nomad as nomad
    
    dev = nomad.AclPolicy("dev",
        description="Submit jobs to the dev environment.",
        rules_hcl="""namespace "dev" {
      policy = "write"
    }
    
    """)
    
    package main
    
    import (
    	"fmt"
    
    	"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.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
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    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 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());
    
        }
    }
    
    resources:
      dev:
        type: nomad:AclPolicy
        properties:
          description: Submit jobs to the dev environment.
          rulesHcl: |+
            namespace "dev" {
              policy = "write"
            }        
    

    Create AclPolicy Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new AclPolicy(name: string, args: AclPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def AclPolicy(resource_name: str,
                  args: AclPolicyArgs,
                  opts: Optional[ResourceOptions] = None)
    
    @overload
    def AclPolicy(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  rules_hcl: Optional[str] = None,
                  description: Optional[str] = None,
                  job_acl: Optional[AclPolicyJobAclArgs] = None,
                  name: Optional[str] = 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.
    
    

    Parameters

    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.

    Example

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

    var aclPolicyResource = new Nomad.AclPolicy("aclPolicyResource", new()
    {
        RulesHcl = "string",
        Description = "string",
        JobAcl = new Nomad.Inputs.AclPolicyJobAclArgs
        {
            JobId = "string",
            Group = "string",
            Namespace = "string",
            Task = "string",
        },
        Name = "string",
    });
    
    example, err := nomad.NewAclPolicy(ctx, "aclPolicyResource", &nomad.AclPolicyArgs{
    	RulesHcl:    pulumi.String("string"),
    	Description: pulumi.String("string"),
    	JobAcl: &nomad.AclPolicyJobAclArgs{
    		JobId:     pulumi.String("string"),
    		Group:     pulumi.String("string"),
    		Namespace: pulumi.String("string"),
    		Task:      pulumi.String("string"),
    	},
    	Name: pulumi.String("string"),
    })
    
    var aclPolicyResource = new AclPolicy("aclPolicyResource", AclPolicyArgs.builder()        
        .rulesHcl("string")
        .description("string")
        .jobAcl(AclPolicyJobAclArgs.builder()
            .jobId("string")
            .group("string")
            .namespace("string")
            .task("string")
            .build())
        .name("string")
        .build());
    
    acl_policy_resource = nomad.AclPolicy("aclPolicyResource",
        rules_hcl="string",
        description="string",
        job_acl=nomad.AclPolicyJobAclArgs(
            job_id="string",
            group="string",
            namespace="string",
            task="string",
        ),
        name="string")
    
    const aclPolicyResource = new nomad.AclPolicy("aclPolicyResource", {
        rulesHcl: "string",
        description: "string",
        jobAcl: {
            jobId: "string",
            group: "string",
            namespace: "string",
            task: "string",
        },
        name: "string",
    });
    
    type: nomad:AclPolicy
    properties:
        description: string
        jobAcl:
            group: string
            jobId: string
            namespace: string
            task: string
        name: string
        rulesHcl: string
    

    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.
    JobAcl AclPolicyJobAcl
    (``JobACL``: <optional>) - Options for assigning the ACL rules to a job, group, or task.
    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.
    JobAcl AclPolicyJobAclArgs
    (``JobACL``: <optional>) - Options for assigning the ACL rules to a job, group, or task.
    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.
    jobAcl AclPolicyJobAcl
    (``JobACL``: <optional>) - Options for assigning the ACL rules to a job, group, or task.
    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.
    jobAcl AclPolicyJobAcl
    (``JobACL``: <optional>) - Options for assigning the ACL rules to a job, group, or task.
    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.
    job_acl AclPolicyJobAclArgs
    (``JobACL``: <optional>) - Options for assigning the ACL rules to a job, group, or task.
    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.
    jobAcl Property Map
    (``JobACL``: <optional>) - Options for assigning the ACL rules to a job, group, or task.
    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,
            job_acl: Optional[AclPolicyJobAclArgs] = 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.
    JobAcl AclPolicyJobAcl
    (``JobACL``: <optional>) - Options for assigning the ACL rules to a job, group, or task.
    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.
    JobAcl AclPolicyJobAclArgs
    (``JobACL``: <optional>) - Options for assigning the ACL rules to a job, group, or task.
    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.
    jobAcl AclPolicyJobAcl
    (``JobACL``: <optional>) - Options for assigning the ACL rules to a job, group, or task.
    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.
    jobAcl AclPolicyJobAcl
    (``JobACL``: <optional>) - Options for assigning the ACL rules to a job, group, or task.
    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.
    job_acl AclPolicyJobAclArgs
    (``JobACL``: <optional>) - Options for assigning the ACL rules to a job, group, or task.
    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.
    jobAcl Property Map
    (``JobACL``: <optional>) - Options for assigning the ACL rules to a job, group, or task.
    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.

    Supporting Types

    AclPolicyJobAcl, AclPolicyJobAclArgs

    JobId string
    (string: <optional> - The job to attach the policy. Required if group is set.
    Group string
    (string: <optional> - The group to attach the policy. Required if task is set.
    Namespace string
    (string: "default") - The namespace to attach the policy. Required if job_id is set.
    Task string
    (string: <optional> - The task to attach the policy.
    JobId string
    (string: <optional> - The job to attach the policy. Required if group is set.
    Group string
    (string: <optional> - The group to attach the policy. Required if task is set.
    Namespace string
    (string: "default") - The namespace to attach the policy. Required if job_id is set.
    Task string
    (string: <optional> - The task to attach the policy.
    jobId String
    (string: <optional> - The job to attach the policy. Required if group is set.
    group String
    (string: <optional> - The group to attach the policy. Required if task is set.
    namespace String
    (string: "default") - The namespace to attach the policy. Required if job_id is set.
    task String
    (string: <optional> - The task to attach the policy.
    jobId string
    (string: <optional> - The job to attach the policy. Required if group is set.
    group string
    (string: <optional> - The group to attach the policy. Required if task is set.
    namespace string
    (string: "default") - The namespace to attach the policy. Required if job_id is set.
    task string
    (string: <optional> - The task to attach the policy.
    job_id str
    (string: <optional> - The job to attach the policy. Required if group is set.
    group str
    (string: <optional> - The group to attach the policy. Required if task is set.
    namespace str
    (string: "default") - The namespace to attach the policy. Required if job_id is set.
    task str
    (string: <optional> - The task to attach the policy.
    jobId String
    (string: <optional> - The job to attach the policy. Required if group is set.
    group String
    (string: <optional> - The group to attach the policy. Required if task is set.
    namespace String
    (string: "default") - The namespace to attach the policy. Required if job_id is set.
    task String
    (string: <optional> - The task to attach the policy.

    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