1. Packages
  2. Nomad Provider
  3. API Docs
  4. SentinelPolicy
Nomad v2.4.3 published on Saturday, Mar 15, 2025 by Pulumi

nomad.SentinelPolicy

Explore with Pulumi AI

Manages a Sentinel policy registered in Nomad.

Enterprise Only! This API endpoint and functionality only exists in Nomad Enterprise. This is not present in the open source version of Nomad.

Example Usage

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

const exec_only = new nomad.SentinelPolicy("exec-only", {
    name: "exec-only",
    description: "Only allow jobs that are based on an exec driver.",
    policy: `main = rule { all_drivers_exec }

# all_drivers_exec checks that all the drivers in use are exec
all_drivers_exec = rule {
    all job.task_groups as tg {
        all tg.tasks as task {
            task.driver is "exec"
        }
    }
}
`,
    scope: "submit-job",
    enforcementLevel: "soft-mandatory",
});
Copy
import pulumi
import pulumi_nomad as nomad

exec_only = nomad.SentinelPolicy("exec-only",
    name="exec-only",
    description="Only allow jobs that are based on an exec driver.",
    policy="""main = rule { all_drivers_exec }

# all_drivers_exec checks that all the drivers in use are exec
all_drivers_exec = rule {
    all job.task_groups as tg {
        all tg.tasks as task {
            task.driver is "exec"
        }
    }
}
""",
    scope="submit-job",
    enforcement_level="soft-mandatory")
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.NewSentinelPolicy(ctx, "exec-only", &nomad.SentinelPolicyArgs{
			Name:        pulumi.String("exec-only"),
			Description: pulumi.String("Only allow jobs that are based on an exec driver."),
			Policy: pulumi.String(`main = rule { all_drivers_exec }

# all_drivers_exec checks that all the drivers in use are exec
all_drivers_exec = rule {
    all job.task_groups as tg {
        all tg.tasks as task {
            task.driver is "exec"
        }
    }
}
`),
			Scope:            pulumi.String("submit-job"),
			EnforcementLevel: pulumi.String("soft-mandatory"),
		})
		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 exec_only = new Nomad.SentinelPolicy("exec-only", new()
    {
        Name = "exec-only",
        Description = "Only allow jobs that are based on an exec driver.",
        Policy = @"main = rule { all_drivers_exec }

# all_drivers_exec checks that all the drivers in use are exec
all_drivers_exec = rule {
    all job.task_groups as tg {
        all tg.tasks as task {
            task.driver is ""exec""
        }
    }
}
",
        Scope = "submit-job",
        EnforcementLevel = "soft-mandatory",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.nomad.SentinelPolicy;
import com.pulumi.nomad.SentinelPolicyArgs;
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 exec_only = new SentinelPolicy("exec-only", SentinelPolicyArgs.builder()
            .name("exec-only")
            .description("Only allow jobs that are based on an exec driver.")
            .policy("""
main = rule { all_drivers_exec }

# all_drivers_exec checks that all the drivers in use are exec
all_drivers_exec = rule {
    all job.task_groups as tg {
        all tg.tasks as task {
            task.driver is "exec"
        }
    }
}
            """)
            .scope("submit-job")
            .enforcementLevel("soft-mandatory")
            .build());

    }
}
Copy
resources:
  exec-only:
    type: nomad:SentinelPolicy
    properties:
      name: exec-only
      description: Only allow jobs that are based on an exec driver.
      policy: |
        main = rule { all_drivers_exec }

        # all_drivers_exec checks that all the drivers in use are exec
        all_drivers_exec = rule {
            all job.task_groups as tg {
                all tg.tasks as task {
                    task.driver is "exec"
                }
            }
        }        
      scope: submit-job
      enforcementLevel: soft-mandatory
Copy

Create SentinelPolicy Resource

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

Constructor syntax

new SentinelPolicy(name: string, args: SentinelPolicyArgs, opts?: CustomResourceOptions);
@overload
def SentinelPolicy(resource_name: str,
                   args: SentinelPolicyArgs,
                   opts: Optional[ResourceOptions] = None)

@overload
def SentinelPolicy(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   enforcement_level: Optional[str] = None,
                   policy: Optional[str] = None,
                   scope: Optional[str] = None,
                   description: Optional[str] = None,
                   name: Optional[str] = None)
func NewSentinelPolicy(ctx *Context, name string, args SentinelPolicyArgs, opts ...ResourceOption) (*SentinelPolicy, error)
public SentinelPolicy(string name, SentinelPolicyArgs args, CustomResourceOptions? opts = null)
public SentinelPolicy(String name, SentinelPolicyArgs args)
public SentinelPolicy(String name, SentinelPolicyArgs args, CustomResourceOptions options)
type: nomad:SentinelPolicy
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. SentinelPolicyArgs
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. SentinelPolicyArgs
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. SentinelPolicyArgs
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. SentinelPolicyArgs
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. SentinelPolicyArgs
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 sentinelPolicyResource = new Nomad.SentinelPolicy("sentinelPolicyResource", new()
{
    EnforcementLevel = "string",
    Policy = "string",
    Scope = "string",
    Description = "string",
    Name = "string",
});
Copy
example, err := nomad.NewSentinelPolicy(ctx, "sentinelPolicyResource", &nomad.SentinelPolicyArgs{
	EnforcementLevel: pulumi.String("string"),
	Policy:           pulumi.String("string"),
	Scope:            pulumi.String("string"),
	Description:      pulumi.String("string"),
	Name:             pulumi.String("string"),
})
Copy
var sentinelPolicyResource = new SentinelPolicy("sentinelPolicyResource", SentinelPolicyArgs.builder()
    .enforcementLevel("string")
    .policy("string")
    .scope("string")
    .description("string")
    .name("string")
    .build());
Copy
sentinel_policy_resource = nomad.SentinelPolicy("sentinelPolicyResource",
    enforcement_level="string",
    policy="string",
    scope="string",
    description="string",
    name="string")
Copy
const sentinelPolicyResource = new nomad.SentinelPolicy("sentinelPolicyResource", {
    enforcementLevel: "string",
    policy: "string",
    scope: "string",
    description: "string",
    name: "string",
});
Copy
type: nomad:SentinelPolicy
properties:
    description: string
    enforcementLevel: string
    name: string
    policy: string
    scope: string
Copy

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

EnforcementLevel This property is required. string
(strings: <required>) - The [enforcement level][enforcement-level] for this policy.
Policy This property is required. string
(string: <required>) - The contents of the policy to register.
Scope This property is required. string
(strings: <required>) - The [scope][scope] for this policy.
Description string
(string: "") - A description of the policy.
Name Changes to this property will trigger replacement. string
(string: <required>) - A unique name for the policy.
EnforcementLevel This property is required. string
(strings: <required>) - The [enforcement level][enforcement-level] for this policy.
Policy This property is required. string
(string: <required>) - The contents of the policy to register.
Scope This property is required. string
(strings: <required>) - The [scope][scope] for this policy.
Description string
(string: "") - A description of the policy.
Name Changes to this property will trigger replacement. string
(string: <required>) - A unique name for the policy.
enforcementLevel This property is required. String
(strings: <required>) - The [enforcement level][enforcement-level] for this policy.
policy This property is required. String
(string: <required>) - The contents of the policy to register.
scope This property is required. String
(strings: <required>) - The [scope][scope] for this policy.
description String
(string: "") - A description of the policy.
name Changes to this property will trigger replacement. String
(string: <required>) - A unique name for the policy.
enforcementLevel This property is required. string
(strings: <required>) - The [enforcement level][enforcement-level] for this policy.
policy This property is required. string
(string: <required>) - The contents of the policy to register.
scope This property is required. string
(strings: <required>) - The [scope][scope] for this policy.
description string
(string: "") - A description of the policy.
name Changes to this property will trigger replacement. string
(string: <required>) - A unique name for the policy.
enforcement_level This property is required. str
(strings: <required>) - The [enforcement level][enforcement-level] for this policy.
policy This property is required. str
(string: <required>) - The contents of the policy to register.
scope This property is required. str
(strings: <required>) - The [scope][scope] for this policy.
description str
(string: "") - A description of the policy.
name Changes to this property will trigger replacement. str
(string: <required>) - A unique name for the policy.
enforcementLevel This property is required. String
(strings: <required>) - The [enforcement level][enforcement-level] for this policy.
policy This property is required. String
(string: <required>) - The contents of the policy to register.
scope This property is required. String
(strings: <required>) - The [scope][scope] for this policy.
description String
(string: "") - A description of the policy.
name Changes to this property will trigger replacement. String
(string: <required>) - A unique name for the policy.

Outputs

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

Get an existing SentinelPolicy 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?: SentinelPolicyState, opts?: CustomResourceOptions): SentinelPolicy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        description: Optional[str] = None,
        enforcement_level: Optional[str] = None,
        name: Optional[str] = None,
        policy: Optional[str] = None,
        scope: Optional[str] = None) -> SentinelPolicy
func GetSentinelPolicy(ctx *Context, name string, id IDInput, state *SentinelPolicyState, opts ...ResourceOption) (*SentinelPolicy, error)
public static SentinelPolicy Get(string name, Input<string> id, SentinelPolicyState? state, CustomResourceOptions? opts = null)
public static SentinelPolicy get(String name, Output<String> id, SentinelPolicyState state, CustomResourceOptions options)
resources:  _:    type: nomad:SentinelPolicy    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:
Description string
(string: "") - A description of the policy.
EnforcementLevel string
(strings: <required>) - The [enforcement level][enforcement-level] for this policy.
Name Changes to this property will trigger replacement. string
(string: <required>) - A unique name for the policy.
Policy string
(string: <required>) - The contents of the policy to register.
Scope string
(strings: <required>) - The [scope][scope] for this policy.
Description string
(string: "") - A description of the policy.
EnforcementLevel string
(strings: <required>) - The [enforcement level][enforcement-level] for this policy.
Name Changes to this property will trigger replacement. string
(string: <required>) - A unique name for the policy.
Policy string
(string: <required>) - The contents of the policy to register.
Scope string
(strings: <required>) - The [scope][scope] for this policy.
description String
(string: "") - A description of the policy.
enforcementLevel String
(strings: <required>) - The [enforcement level][enforcement-level] for this policy.
name Changes to this property will trigger replacement. String
(string: <required>) - A unique name for the policy.
policy String
(string: <required>) - The contents of the policy to register.
scope String
(strings: <required>) - The [scope][scope] for this policy.
description string
(string: "") - A description of the policy.
enforcementLevel string
(strings: <required>) - The [enforcement level][enforcement-level] for this policy.
name Changes to this property will trigger replacement. string
(string: <required>) - A unique name for the policy.
policy string
(string: <required>) - The contents of the policy to register.
scope string
(strings: <required>) - The [scope][scope] for this policy.
description str
(string: "") - A description of the policy.
enforcement_level str
(strings: <required>) - The [enforcement level][enforcement-level] for this policy.
name Changes to this property will trigger replacement. str
(string: <required>) - A unique name for the policy.
policy str
(string: <required>) - The contents of the policy to register.
scope str
(strings: <required>) - The [scope][scope] for this policy.
description String
(string: "") - A description of the policy.
enforcementLevel String
(strings: <required>) - The [enforcement level][enforcement-level] for this policy.
name Changes to this property will trigger replacement. String
(string: <required>) - A unique name for the policy.
policy String
(string: <required>) - The contents of the policy to register.
scope String
(strings: <required>) - The [scope][scope] for this policy.

Package Details

Repository
HashiCorp Nomad pulumi/pulumi-nomad
License
Apache-2.0
Notes
This Pulumi package is based on the nomad Terraform Provider.