nomad.SentinelPolicy

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

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

return await Deployment.RunAsync(() => 
{
    var exec_only = new Nomad.SentinelPolicy("exec-only", new()
    {
        Description = "Only allow jobs that are based on an exec driver.",
        EnforcementLevel = "soft-mandatory",
        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",
    });

});
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.NewSentinelPolicy(ctx, "exec-only", &nomad.SentinelPolicyArgs{
			Description:      pulumi.String("Only allow jobs that are based on an exec driver."),
			EnforcementLevel: pulumi.String("soft-mandatory"),
			Policy: pulumi.String(fmt.Sprintf(`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"),
		})
		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.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()        
            .description("Only allow jobs that are based on an exec driver.")
            .enforcementLevel("soft-mandatory")
            .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")
            .build());

    }
}
import pulumi
import pulumi_nomad as nomad

exec_only = nomad.SentinelPolicy("exec-only",
    description="Only allow jobs that are based on an exec driver.",
    enforcement_level="soft-mandatory",
    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")
import * as pulumi from "@pulumi/pulumi";
import * as nomad from "@pulumi/nomad";

const exec_only = new nomad.SentinelPolicy("exec-only", {
    description: "Only allow jobs that are based on an exec driver.",
    enforcementLevel: "soft-mandatory",
    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",
});
resources:
  exec-only:
    type: nomad:SentinelPolicy
    properties:
      description: Only allow jobs that are based on an exec driver.
      # allow administrators to override
      enforcementLevel: soft-mandatory
      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

Create SentinelPolicy Resource

new SentinelPolicy(name: string, args: SentinelPolicyArgs, opts?: CustomResourceOptions);
@overload
def SentinelPolicy(resource_name: 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)
@overload
def SentinelPolicy(resource_name: str,
                   args: SentinelPolicyArgs,
                   opts: Optional[ResourceOptions] = 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.

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

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

The SentinelPolicy resource accepts the following input properties:

EnforcementLevel string

(strings: <required>) - The [enforcement level][enforcement-level] for this 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.

Name string

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

EnforcementLevel string

(strings: <required>) - The [enforcement level][enforcement-level] for this 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.

Name string

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

enforcementLevel String

(strings: <required>) - The [enforcement level][enforcement-level] for this 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.

name String

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

enforcementLevel string

(strings: <required>) - The [enforcement level][enforcement-level] for this 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.

name string

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

enforcement_level str

(strings: <required>) - The [enforcement level][enforcement-level] for this policy.

policy str

(string: <required>) - The contents of the policy to register.

scope str

(strings: <required>) - The [scope][scope] for this policy.

description str

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

name str

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

enforcementLevel String

(strings: <required>) - The [enforcement level][enforcement-level] for this 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.

name 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)
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.

EnforcementLevel string

(strings: <required>) - The [enforcement level][enforcement-level] for this policy.

Name 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 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 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 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 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 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.