com.pulumi.nomad.kotlin.SentinelPolicyArgs.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-nomad-kotlin Show documentation
Show all versions of pulumi-nomad-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.nomad.kotlin
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.nomad.SentinelPolicyArgs.builder
import kotlin.String
import kotlin.Suppress
import kotlin.jvm.JvmName
/**
* 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
*
* ```typescript
* 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",
* });
* ```
* ```python
* 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")
* ```
* ```csharp
* 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",
* });
* });
* ```
* ```go
* 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
* })
* }
* ```
* ```java
* 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());
* }
* }
* ```
* ```yaml
* 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
* ```
*
* @property description `(string: "")` - A description of the policy.
* [scope]: https://www.nomadproject.io/guides/sentinel-policy.html#policy-scope
* [enforcement-level]: https://www.nomadproject.io/guides/sentinel-policy.html#enforcement-level
* @property enforcementLevel `(strings: )` - The [enforcement level][enforcement-level]
* for this policy.
* @property name `(string: )` - A unique name for the policy.
* @property policy `(string: )` - The contents of the policy to register.
* @property scope `(strings: )` - The [scope][scope] for this policy.
*/
public data class SentinelPolicyArgs(
public val description: Output? = null,
public val enforcementLevel: Output? = null,
public val name: Output? = null,
public val policy: Output? = null,
public val scope: Output? = null,
) : ConvertibleToJava {
override fun toJava(): com.pulumi.nomad.SentinelPolicyArgs =
com.pulumi.nomad.SentinelPolicyArgs.builder()
.description(description?.applyValue({ args0 -> args0 }))
.enforcementLevel(enforcementLevel?.applyValue({ args0 -> args0 }))
.name(name?.applyValue({ args0 -> args0 }))
.policy(policy?.applyValue({ args0 -> args0 }))
.scope(scope?.applyValue({ args0 -> args0 })).build()
}
/**
* Builder for [SentinelPolicyArgs].
*/
@PulumiTagMarker
public class SentinelPolicyArgsBuilder internal constructor() {
private var description: Output? = null
private var enforcementLevel: Output? = null
private var name: Output? = null
private var policy: Output? = null
private var scope: Output? = null
/**
* @param value `(string: "")` - A description of the policy.
* [scope]: https://www.nomadproject.io/guides/sentinel-policy.html#policy-scope
* [enforcement-level]: https://www.nomadproject.io/guides/sentinel-policy.html#enforcement-level
*/
@JvmName("qtmicweehbxpghiu")
public suspend fun description(`value`: Output) {
this.description = value
}
/**
* @param value `(strings: )` - The [enforcement level][enforcement-level]
* for this policy.
*/
@JvmName("daafaphxobvlixvi")
public suspend fun enforcementLevel(`value`: Output) {
this.enforcementLevel = value
}
/**
* @param value `(string: )` - A unique name for the policy.
*/
@JvmName("nyrwclalvppyjtiv")
public suspend fun name(`value`: Output) {
this.name = value
}
/**
* @param value `(string: )` - The contents of the policy to register.
*/
@JvmName("pxbapffawobocxcm")
public suspend fun policy(`value`: Output) {
this.policy = value
}
/**
* @param value `(strings: )` - The [scope][scope] for this policy.
*/
@JvmName("kubfbvewxbuwrkff")
public suspend fun scope(`value`: Output) {
this.scope = value
}
/**
* @param value `(string: "")` - A description of the policy.
* [scope]: https://www.nomadproject.io/guides/sentinel-policy.html#policy-scope
* [enforcement-level]: https://www.nomadproject.io/guides/sentinel-policy.html#enforcement-level
*/
@JvmName("mldjuqdhuxmkqobx")
public suspend fun description(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.description = mapped
}
/**
* @param value `(strings: )` - The [enforcement level][enforcement-level]
* for this policy.
*/
@JvmName("wnypoxifradktasn")
public suspend fun enforcementLevel(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.enforcementLevel = mapped
}
/**
* @param value `(string: )` - A unique name for the policy.
*/
@JvmName("hqwdkdcywskcdsnq")
public suspend fun name(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.name = mapped
}
/**
* @param value `(string: )` - The contents of the policy to register.
*/
@JvmName("dsmvjliklmlxyxsj")
public suspend fun policy(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.policy = mapped
}
/**
* @param value `(strings: )` - The [scope][scope] for this policy.
*/
@JvmName("ugcnclysoxohoxym")
public suspend fun scope(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.scope = mapped
}
internal fun build(): SentinelPolicyArgs = SentinelPolicyArgs(
description = description,
enforcementLevel = enforcementLevel,
name = name,
policy = policy,
scope = scope,
)
}