All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.vault.kubernetes.kotlin.SecretBackendRole.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 6.4.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.vault.kubernetes.kotlin

import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map

/**
 * Builder for [SecretBackendRole].
 */
@PulumiTagMarker
public class SecretBackendRoleResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: SecretBackendRoleArgs = SecretBackendRoleArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend SecretBackendRoleArgsBuilder.() -> Unit) {
        val builder = SecretBackendRoleArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): SecretBackendRole {
        val builtJavaResource = com.pulumi.vault.kubernetes.SecretBackendRole(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return SecretBackendRole(builtJavaResource)
    }
}

/**
 * ## Example Usage
 * Example using `service_account_name` mode:
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as std from "@pulumi/std";
 * import * as vault from "@pulumi/vault";
 * const config = new vault.kubernetes.SecretBackend("config", {
 *     path: "kubernetes",
 *     description: "kubernetes secrets engine description",
 *     kubernetesHost: "https://127.0.0.1:61233",
 *     kubernetesCaCert: std.file({
 *         input: "/path/to/cert",
 *     }).then(invoke => invoke.result),
 *     serviceAccountJwt: std.file({
 *         input: "/path/to/token",
 *     }).then(invoke => invoke.result),
 *     disableLocalCaJwt: false,
 * });
 * const sa_example = new vault.kubernetes.SecretBackendRole("sa-example", {
 *     backend: config.path,
 *     name: "service-account-name-role",
 *     allowedKubernetesNamespaces: ["*"],
 *     tokenMaxTtl: 43200,
 *     tokenDefaultTtl: 21600,
 *     serviceAccountName: "test-service-account-with-generated-token",
 *     extraLabels: {
 *         id: "abc123",
 *         name: "some_name",
 *     },
 *     extraAnnotations: {
 *         env: "development",
 *         location: "earth",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_std as std
 * import pulumi_vault as vault
 * config = vault.kubernetes.SecretBackend("config",
 *     path="kubernetes",
 *     description="kubernetes secrets engine description",
 *     kubernetes_host="https://127.0.0.1:61233",
 *     kubernetes_ca_cert=std.file(input="/path/to/cert").result,
 *     service_account_jwt=std.file(input="/path/to/token").result,
 *     disable_local_ca_jwt=False)
 * sa_example = vault.kubernetes.SecretBackendRole("sa-example",
 *     backend=config.path,
 *     name="service-account-name-role",
 *     allowed_kubernetes_namespaces=["*"],
 *     token_max_ttl=43200,
 *     token_default_ttl=21600,
 *     service_account_name="test-service-account-with-generated-token",
 *     extra_labels={
 *         "id": "abc123",
 *         "name": "some_name",
 *     },
 *     extra_annotations={
 *         "env": "development",
 *         "location": "earth",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Std = Pulumi.Std;
 * using Vault = Pulumi.Vault;
 * return await Deployment.RunAsync(() =>
 * {
 *     var config = new Vault.Kubernetes.SecretBackend("config", new()
 *     {
 *         Path = "kubernetes",
 *         Description = "kubernetes secrets engine description",
 *         KubernetesHost = "https://127.0.0.1:61233",
 *         KubernetesCaCert = Std.File.Invoke(new()
 *         {
 *             Input = "/path/to/cert",
 *         }).Apply(invoke => invoke.Result),
 *         ServiceAccountJwt = Std.File.Invoke(new()
 *         {
 *             Input = "/path/to/token",
 *         }).Apply(invoke => invoke.Result),
 *         DisableLocalCaJwt = false,
 *     });
 *     var sa_example = new Vault.Kubernetes.SecretBackendRole("sa-example", new()
 *     {
 *         Backend = config.Path,
 *         Name = "service-account-name-role",
 *         AllowedKubernetesNamespaces = new[]
 *         {
 *             "*",
 *         },
 *         TokenMaxTtl = 43200,
 *         TokenDefaultTtl = 21600,
 *         ServiceAccountName = "test-service-account-with-generated-token",
 *         ExtraLabels =
 *         {
 *             { "id", "abc123" },
 *             { "name", "some_name" },
 *         },
 *         ExtraAnnotations =
 *         {
 *             { "env", "development" },
 *             { "location", "earth" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-std/sdk/go/std"
 * 	"github.com/pulumi/pulumi-vault/sdk/v6/go/vault/kubernetes"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		invokeFile, err := std.File(ctx, &std.FileArgs{
 * 			Input: "/path/to/cert",
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		invokeFile1, err := std.File(ctx, &std.FileArgs{
 * 			Input: "/path/to/token",
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		config, err := kubernetes.NewSecretBackend(ctx, "config", &kubernetes.SecretBackendArgs{
 * 			Path:              pulumi.String("kubernetes"),
 * 			Description:       pulumi.String("kubernetes secrets engine description"),
 * 			KubernetesHost:    pulumi.String("https://127.0.0.1:61233"),
 * 			KubernetesCaCert:  pulumi.String(invokeFile.Result),
 * 			ServiceAccountJwt: pulumi.String(invokeFile1.Result),
 * 			DisableLocalCaJwt: pulumi.Bool(false),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = kubernetes.NewSecretBackendRole(ctx, "sa-example", &kubernetes.SecretBackendRoleArgs{
 * 			Backend: config.Path,
 * 			Name:    pulumi.String("service-account-name-role"),
 * 			AllowedKubernetesNamespaces: pulumi.StringArray{
 * 				pulumi.String("*"),
 * 			},
 * 			TokenMaxTtl:        pulumi.Int(43200),
 * 			TokenDefaultTtl:    pulumi.Int(21600),
 * 			ServiceAccountName: pulumi.String("test-service-account-with-generated-token"),
 * 			ExtraLabels: pulumi.StringMap{
 * 				"id":   pulumi.String("abc123"),
 * 				"name": pulumi.String("some_name"),
 * 			},
 * 			ExtraAnnotations: pulumi.StringMap{
 * 				"env":      pulumi.String("development"),
 * 				"location": pulumi.String("earth"),
 * 			},
 * 		})
 * 		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.vault.kubernetes.SecretBackend;
 * import com.pulumi.vault.kubernetes.SecretBackendArgs;
 * import com.pulumi.vault.kubernetes.SecretBackendRole;
 * import com.pulumi.vault.kubernetes.SecretBackendRoleArgs;
 * 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 config = new SecretBackend("config", SecretBackendArgs.builder()
 *             .path("kubernetes")
 *             .description("kubernetes secrets engine description")
 *             .kubernetesHost("https://127.0.0.1:61233")
 *             .kubernetesCaCert(StdFunctions.file(FileArgs.builder()
 *                 .input("/path/to/cert")
 *                 .build()).result())
 *             .serviceAccountJwt(StdFunctions.file(FileArgs.builder()
 *                 .input("/path/to/token")
 *                 .build()).result())
 *             .disableLocalCaJwt(false)
 *             .build());
 *         var sa_example = new SecretBackendRole("sa-example", SecretBackendRoleArgs.builder()
 *             .backend(config.path())
 *             .name("service-account-name-role")
 *             .allowedKubernetesNamespaces("*")
 *             .tokenMaxTtl(43200)
 *             .tokenDefaultTtl(21600)
 *             .serviceAccountName("test-service-account-with-generated-token")
 *             .extraLabels(Map.ofEntries(
 *                 Map.entry("id", "abc123"),
 *                 Map.entry("name", "some_name")
 *             ))
 *             .extraAnnotations(Map.ofEntries(
 *                 Map.entry("env", "development"),
 *                 Map.entry("location", "earth")
 *             ))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   config:
 *     type: vault:kubernetes:SecretBackend
 *     properties:
 *       path: kubernetes
 *       description: kubernetes secrets engine description
 *       kubernetesHost: https://127.0.0.1:61233
 *       kubernetesCaCert:
 *         fn::invoke:
 *           Function: std:file
 *           Arguments:
 *             input: /path/to/cert
 *           Return: result
 *       serviceAccountJwt:
 *         fn::invoke:
 *           Function: std:file
 *           Arguments:
 *             input: /path/to/token
 *           Return: result
 *       disableLocalCaJwt: false
 *   sa-example:
 *     type: vault:kubernetes:SecretBackendRole
 *     properties:
 *       backend: ${config.path}
 *       name: service-account-name-role
 *       allowedKubernetesNamespaces:
 *         - '*'
 *       tokenMaxTtl: 43200
 *       tokenDefaultTtl: 21600
 *       serviceAccountName: test-service-account-with-generated-token
 *       extraLabels:
 *         id: abc123
 *         name: some_name
 *       extraAnnotations:
 *         env: development
 *         location: earth
 * ```
 * 
 * Example using `kubernetes_role_name` mode:
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as std from "@pulumi/std";
 * import * as vault from "@pulumi/vault";
 * const config = new vault.kubernetes.SecretBackend("config", {
 *     path: "kubernetes",
 *     description: "kubernetes secrets engine description",
 *     kubernetesHost: "https://127.0.0.1:61233",
 *     kubernetesCaCert: std.file({
 *         input: "/path/to/cert",
 *     }).then(invoke => invoke.result),
 *     serviceAccountJwt: std.file({
 *         input: "/path/to/token",
 *     }).then(invoke => invoke.result),
 *     disableLocalCaJwt: false,
 * });
 * const name_example = new vault.kubernetes.SecretBackendRole("name-example", {
 *     backend: config.path,
 *     name: "service-account-name-role",
 *     allowedKubernetesNamespaces: ["*"],
 *     tokenMaxTtl: 43200,
 *     tokenDefaultTtl: 21600,
 *     kubernetesRoleName: "vault-k8s-secrets-role",
 *     extraLabels: {
 *         id: "abc123",
 *         name: "some_name",
 *     },
 *     extraAnnotations: {
 *         env: "development",
 *         location: "earth",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_std as std
 * import pulumi_vault as vault
 * config = vault.kubernetes.SecretBackend("config",
 *     path="kubernetes",
 *     description="kubernetes secrets engine description",
 *     kubernetes_host="https://127.0.0.1:61233",
 *     kubernetes_ca_cert=std.file(input="/path/to/cert").result,
 *     service_account_jwt=std.file(input="/path/to/token").result,
 *     disable_local_ca_jwt=False)
 * name_example = vault.kubernetes.SecretBackendRole("name-example",
 *     backend=config.path,
 *     name="service-account-name-role",
 *     allowed_kubernetes_namespaces=["*"],
 *     token_max_ttl=43200,
 *     token_default_ttl=21600,
 *     kubernetes_role_name="vault-k8s-secrets-role",
 *     extra_labels={
 *         "id": "abc123",
 *         "name": "some_name",
 *     },
 *     extra_annotations={
 *         "env": "development",
 *         "location": "earth",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Std = Pulumi.Std;
 * using Vault = Pulumi.Vault;
 * return await Deployment.RunAsync(() =>
 * {
 *     var config = new Vault.Kubernetes.SecretBackend("config", new()
 *     {
 *         Path = "kubernetes",
 *         Description = "kubernetes secrets engine description",
 *         KubernetesHost = "https://127.0.0.1:61233",
 *         KubernetesCaCert = Std.File.Invoke(new()
 *         {
 *             Input = "/path/to/cert",
 *         }).Apply(invoke => invoke.Result),
 *         ServiceAccountJwt = Std.File.Invoke(new()
 *         {
 *             Input = "/path/to/token",
 *         }).Apply(invoke => invoke.Result),
 *         DisableLocalCaJwt = false,
 *     });
 *     var name_example = new Vault.Kubernetes.SecretBackendRole("name-example", new()
 *     {
 *         Backend = config.Path,
 *         Name = "service-account-name-role",
 *         AllowedKubernetesNamespaces = new[]
 *         {
 *             "*",
 *         },
 *         TokenMaxTtl = 43200,
 *         TokenDefaultTtl = 21600,
 *         KubernetesRoleName = "vault-k8s-secrets-role",
 *         ExtraLabels =
 *         {
 *             { "id", "abc123" },
 *             { "name", "some_name" },
 *         },
 *         ExtraAnnotations =
 *         {
 *             { "env", "development" },
 *             { "location", "earth" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-std/sdk/go/std"
 * 	"github.com/pulumi/pulumi-vault/sdk/v6/go/vault/kubernetes"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		invokeFile, err := std.File(ctx, &std.FileArgs{
 * 			Input: "/path/to/cert",
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		invokeFile1, err := std.File(ctx, &std.FileArgs{
 * 			Input: "/path/to/token",
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		config, err := kubernetes.NewSecretBackend(ctx, "config", &kubernetes.SecretBackendArgs{
 * 			Path:              pulumi.String("kubernetes"),
 * 			Description:       pulumi.String("kubernetes secrets engine description"),
 * 			KubernetesHost:    pulumi.String("https://127.0.0.1:61233"),
 * 			KubernetesCaCert:  pulumi.String(invokeFile.Result),
 * 			ServiceAccountJwt: pulumi.String(invokeFile1.Result),
 * 			DisableLocalCaJwt: pulumi.Bool(false),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = kubernetes.NewSecretBackendRole(ctx, "name-example", &kubernetes.SecretBackendRoleArgs{
 * 			Backend: config.Path,
 * 			Name:    pulumi.String("service-account-name-role"),
 * 			AllowedKubernetesNamespaces: pulumi.StringArray{
 * 				pulumi.String("*"),
 * 			},
 * 			TokenMaxTtl:        pulumi.Int(43200),
 * 			TokenDefaultTtl:    pulumi.Int(21600),
 * 			KubernetesRoleName: pulumi.String("vault-k8s-secrets-role"),
 * 			ExtraLabels: pulumi.StringMap{
 * 				"id":   pulumi.String("abc123"),
 * 				"name": pulumi.String("some_name"),
 * 			},
 * 			ExtraAnnotations: pulumi.StringMap{
 * 				"env":      pulumi.String("development"),
 * 				"location": pulumi.String("earth"),
 * 			},
 * 		})
 * 		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.vault.kubernetes.SecretBackend;
 * import com.pulumi.vault.kubernetes.SecretBackendArgs;
 * import com.pulumi.vault.kubernetes.SecretBackendRole;
 * import com.pulumi.vault.kubernetes.SecretBackendRoleArgs;
 * 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 config = new SecretBackend("config", SecretBackendArgs.builder()
 *             .path("kubernetes")
 *             .description("kubernetes secrets engine description")
 *             .kubernetesHost("https://127.0.0.1:61233")
 *             .kubernetesCaCert(StdFunctions.file(FileArgs.builder()
 *                 .input("/path/to/cert")
 *                 .build()).result())
 *             .serviceAccountJwt(StdFunctions.file(FileArgs.builder()
 *                 .input("/path/to/token")
 *                 .build()).result())
 *             .disableLocalCaJwt(false)
 *             .build());
 *         var name_example = new SecretBackendRole("name-example", SecretBackendRoleArgs.builder()
 *             .backend(config.path())
 *             .name("service-account-name-role")
 *             .allowedKubernetesNamespaces("*")
 *             .tokenMaxTtl(43200)
 *             .tokenDefaultTtl(21600)
 *             .kubernetesRoleName("vault-k8s-secrets-role")
 *             .extraLabels(Map.ofEntries(
 *                 Map.entry("id", "abc123"),
 *                 Map.entry("name", "some_name")
 *             ))
 *             .extraAnnotations(Map.ofEntries(
 *                 Map.entry("env", "development"),
 *                 Map.entry("location", "earth")
 *             ))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   config:
 *     type: vault:kubernetes:SecretBackend
 *     properties:
 *       path: kubernetes
 *       description: kubernetes secrets engine description
 *       kubernetesHost: https://127.0.0.1:61233
 *       kubernetesCaCert:
 *         fn::invoke:
 *           Function: std:file
 *           Arguments:
 *             input: /path/to/cert
 *           Return: result
 *       serviceAccountJwt:
 *         fn::invoke:
 *           Function: std:file
 *           Arguments:
 *             input: /path/to/token
 *           Return: result
 *       disableLocalCaJwt: false
 *   name-example:
 *     type: vault:kubernetes:SecretBackendRole
 *     properties:
 *       backend: ${config.path}
 *       name: service-account-name-role
 *       allowedKubernetesNamespaces:
 *         - '*'
 *       tokenMaxTtl: 43200
 *       tokenDefaultTtl: 21600
 *       kubernetesRoleName: vault-k8s-secrets-role
 *       extraLabels:
 *         id: abc123
 *         name: some_name
 *       extraAnnotations:
 *         env: development
 *         location: earth
 * ```
 * 
 * Example using `generated_role_rules` mode:
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as std from "@pulumi/std";
 * import * as vault from "@pulumi/vault";
 * const config = new vault.kubernetes.SecretBackend("config", {
 *     path: "kubernetes",
 *     description: "kubernetes secrets engine description",
 *     kubernetesHost: "https://127.0.0.1:61233",
 *     kubernetesCaCert: std.file({
 *         input: "/path/to/cert",
 *     }).then(invoke => invoke.result),
 *     serviceAccountJwt: std.file({
 *         input: "/path/to/token",
 *     }).then(invoke => invoke.result),
 *     disableLocalCaJwt: false,
 * });
 * const rules_example = new vault.kubernetes.SecretBackendRole("rules-example", {
 *     backend: config.path,
 *     name: "service-account-name-role",
 *     allowedKubernetesNamespaces: ["*"],
 *     tokenMaxTtl: 43200,
 *     tokenDefaultTtl: 21600,
 *     kubernetesRoleType: "Role",
 *     generatedRoleRules: `rules:
 * - apiGroups: [""]
 *   resources: ["pods"]
 *   verbs: ["list"]
 * `,
 *     extraLabels: {
 *         id: "abc123",
 *         name: "some_name",
 *     },
 *     extraAnnotations: {
 *         env: "development",
 *         location: "earth",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_std as std
 * import pulumi_vault as vault
 * config = vault.kubernetes.SecretBackend("config",
 *     path="kubernetes",
 *     description="kubernetes secrets engine description",
 *     kubernetes_host="https://127.0.0.1:61233",
 *     kubernetes_ca_cert=std.file(input="/path/to/cert").result,
 *     service_account_jwt=std.file(input="/path/to/token").result,
 *     disable_local_ca_jwt=False)
 * rules_example = vault.kubernetes.SecretBackendRole("rules-example",
 *     backend=config.path,
 *     name="service-account-name-role",
 *     allowed_kubernetes_namespaces=["*"],
 *     token_max_ttl=43200,
 *     token_default_ttl=21600,
 *     kubernetes_role_type="Role",
 *     generated_role_rules="""rules:
 * - apiGroups: [""]
 *   resources: ["pods"]
 *   verbs: ["list"]
 * """,
 *     extra_labels={
 *         "id": "abc123",
 *         "name": "some_name",
 *     },
 *     extra_annotations={
 *         "env": "development",
 *         "location": "earth",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Std = Pulumi.Std;
 * using Vault = Pulumi.Vault;
 * return await Deployment.RunAsync(() =>
 * {
 *     var config = new Vault.Kubernetes.SecretBackend("config", new()
 *     {
 *         Path = "kubernetes",
 *         Description = "kubernetes secrets engine description",
 *         KubernetesHost = "https://127.0.0.1:61233",
 *         KubernetesCaCert = Std.File.Invoke(new()
 *         {
 *             Input = "/path/to/cert",
 *         }).Apply(invoke => invoke.Result),
 *         ServiceAccountJwt = Std.File.Invoke(new()
 *         {
 *             Input = "/path/to/token",
 *         }).Apply(invoke => invoke.Result),
 *         DisableLocalCaJwt = false,
 *     });
 *     var rules_example = new Vault.Kubernetes.SecretBackendRole("rules-example", new()
 *     {
 *         Backend = config.Path,
 *         Name = "service-account-name-role",
 *         AllowedKubernetesNamespaces = new[]
 *         {
 *             "*",
 *         },
 *         TokenMaxTtl = 43200,
 *         TokenDefaultTtl = 21600,
 *         KubernetesRoleType = "Role",
 *         GeneratedRoleRules = @"rules:
 * - apiGroups: [""""]
 *   resources: [""pods""]
 *   verbs: [""list""]
 * ",
 *         ExtraLabels =
 *         {
 *             { "id", "abc123" },
 *             { "name", "some_name" },
 *         },
 *         ExtraAnnotations =
 *         {
 *             { "env", "development" },
 *             { "location", "earth" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-std/sdk/go/std"
 * 	"github.com/pulumi/pulumi-vault/sdk/v6/go/vault/kubernetes"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		invokeFile, err := std.File(ctx, &std.FileArgs{
 * 			Input: "/path/to/cert",
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		invokeFile1, err := std.File(ctx, &std.FileArgs{
 * 			Input: "/path/to/token",
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		config, err := kubernetes.NewSecretBackend(ctx, "config", &kubernetes.SecretBackendArgs{
 * 			Path:              pulumi.String("kubernetes"),
 * 			Description:       pulumi.String("kubernetes secrets engine description"),
 * 			KubernetesHost:    pulumi.String("https://127.0.0.1:61233"),
 * 			KubernetesCaCert:  pulumi.String(invokeFile.Result),
 * 			ServiceAccountJwt: pulumi.String(invokeFile1.Result),
 * 			DisableLocalCaJwt: pulumi.Bool(false),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = kubernetes.NewSecretBackendRole(ctx, "rules-example", &kubernetes.SecretBackendRoleArgs{
 * 			Backend: config.Path,
 * 			Name:    pulumi.String("service-account-name-role"),
 * 			AllowedKubernetesNamespaces: pulumi.StringArray{
 * 				pulumi.String("*"),
 * 			},
 * 			TokenMaxTtl:        pulumi.Int(43200),
 * 			TokenDefaultTtl:    pulumi.Int(21600),
 * 			KubernetesRoleType: pulumi.String("Role"),
 * 			GeneratedRoleRules: pulumi.String("rules:\n- apiGroups: [\"\"]\n  resources: [\"pods\"]\n  verbs: [\"list\"]\n"),
 * 			ExtraLabels: pulumi.StringMap{
 * 				"id":   pulumi.String("abc123"),
 * 				"name": pulumi.String("some_name"),
 * 			},
 * 			ExtraAnnotations: pulumi.StringMap{
 * 				"env":      pulumi.String("development"),
 * 				"location": pulumi.String("earth"),
 * 			},
 * 		})
 * 		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.vault.kubernetes.SecretBackend;
 * import com.pulumi.vault.kubernetes.SecretBackendArgs;
 * import com.pulumi.vault.kubernetes.SecretBackendRole;
 * import com.pulumi.vault.kubernetes.SecretBackendRoleArgs;
 * 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 config = new SecretBackend("config", SecretBackendArgs.builder()
 *             .path("kubernetes")
 *             .description("kubernetes secrets engine description")
 *             .kubernetesHost("https://127.0.0.1:61233")
 *             .kubernetesCaCert(StdFunctions.file(FileArgs.builder()
 *                 .input("/path/to/cert")
 *                 .build()).result())
 *             .serviceAccountJwt(StdFunctions.file(FileArgs.builder()
 *                 .input("/path/to/token")
 *                 .build()).result())
 *             .disableLocalCaJwt(false)
 *             .build());
 *         var rules_example = new SecretBackendRole("rules-example", SecretBackendRoleArgs.builder()
 *             .backend(config.path())
 *             .name("service-account-name-role")
 *             .allowedKubernetesNamespaces("*")
 *             .tokenMaxTtl(43200)
 *             .tokenDefaultTtl(21600)
 *             .kubernetesRoleType("Role")
 *             .generatedRoleRules("""
 * rules:
 * - apiGroups: [""]
 *   resources: ["pods"]
 *   verbs: ["list"]
 *             """)
 *             .extraLabels(Map.ofEntries(
 *                 Map.entry("id", "abc123"),
 *                 Map.entry("name", "some_name")
 *             ))
 *             .extraAnnotations(Map.ofEntries(
 *                 Map.entry("env", "development"),
 *                 Map.entry("location", "earth")
 *             ))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   config:
 *     type: vault:kubernetes:SecretBackend
 *     properties:
 *       path: kubernetes
 *       description: kubernetes secrets engine description
 *       kubernetesHost: https://127.0.0.1:61233
 *       kubernetesCaCert:
 *         fn::invoke:
 *           Function: std:file
 *           Arguments:
 *             input: /path/to/cert
 *           Return: result
 *       serviceAccountJwt:
 *         fn::invoke:
 *           Function: std:file
 *           Arguments:
 *             input: /path/to/token
 *           Return: result
 *       disableLocalCaJwt: false
 *   rules-example:
 *     type: vault:kubernetes:SecretBackendRole
 *     properties:
 *       backend: ${config.path}
 *       name: service-account-name-role
 *       allowedKubernetesNamespaces:
 *         - '*'
 *       tokenMaxTtl: 43200
 *       tokenDefaultTtl: 21600
 *       kubernetesRoleType: Role
 *       generatedRoleRules: |
 *         rules:
 *         - apiGroups: [""]
 *           resources: ["pods"]
 *           verbs: ["list"]
 *       extraLabels:
 *         id: abc123
 *         name: some_name
 *       extraAnnotations:
 *         env: development
 *         location: earth
 * ```
 * 
 * ## Import
 * The Kubernetes secret backend role can be imported using the full path to the role
 * of the form: `/roles/` e.g.
 * ```sh
 * $ pulumi import vault:kubernetes/secretBackendRole:SecretBackendRole example kubernetes kubernetes/roles/example-role
 * ```
 */
public class SecretBackendRole internal constructor(
    override val javaResource: com.pulumi.vault.kubernetes.SecretBackendRole,
) : KotlinCustomResource(javaResource, SecretBackendRoleMapper) {
    /**
     * A label selector for Kubernetes namespaces
     * in which credentials can be generated. Accepts either a JSON or YAML object. The value should be
     * of type [LabelSelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#labelselector-v1-meta).
     * If set with `allowed_kubernetes_namespace`, the conditions are `OR`ed.
     */
    public val allowedKubernetesNamespaceSelector: Output?
        get() = javaResource.allowedKubernetesNamespaceSelector().applyValue({ args0 ->
            args0.map({ args0 -> args0 }).orElse(null)
        })

    /**
     * The list of Kubernetes namespaces this role
     * can generate credentials for. If set to `*` all namespaces are allowed. If set with
     * `allowed_kubernetes_namespace_selector`, the conditions are `OR`ed.
     */
    public val allowedKubernetesNamespaces: Output>?
        get() = javaResource.allowedKubernetesNamespaces().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0 })
            }).orElse(null)
        })

    /**
     * The path of the Kubernetes Secrets Engine backend mount to create
     * the role in.
     */
    public val backend: Output
        get() = javaResource.backend().applyValue({ args0 -> args0 })

    /**
     * Additional annotations to apply to all generated
     * Kubernetes objects.
     */
    public val extraAnnotations: Output>?
        get() = javaResource.extraAnnotations().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0.key.to(args0.value) }).toMap()
            }).orElse(null)
        })

    /**
     * Additional labels to apply to all generated Kubernetes
     * objects.
     * This resource also directly accepts all vault.Mount fields.
     */
    public val extraLabels: Output>?
        get() = javaResource.extraLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * The Role or ClusterRole rules to use when generating
     * a role. Accepts either JSON or YAML formatted rules. Mutually exclusive with `service_account_name`
     * and `kubernetes_role_name`. If set, the entire chain of Kubernetes objects will be generated
     * when credentials are requested.
     */
    public val generatedRoleRules: Output?
        get() = javaResource.generatedRoleRules().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The pre-existing Role or ClusterRole to bind a
     * generated service account to. Mutually exclusive with `service_account_name` and
     * `generated_role_rules`. If set, Kubernetes token, service account, and role
     * binding objects will be created when credentials are requested.
     */
    public val kubernetesRoleName: Output?
        get() = javaResource.kubernetesRoleName().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Specifies whether the Kubernetes role is a Role or
     * ClusterRole.
     */
    public val kubernetesRoleType: Output?
        get() = javaResource.kubernetesRoleType().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The name of the role.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The name template to use when generating service accounts,
     * roles and role bindings. If unset, a default template is used.
     */
    public val nameTemplate: Output?
        get() = javaResource.nameTemplate().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The namespace to provision the resource in.
     * The value should not contain leading or trailing forward slashes.
     * The `namespace` is always relative to the provider's configured [namespace](https://www.terraform.io/docs/providers/vault/index.html#namespace).
     * *Available only for Vault Enterprise*.
     */
    public val namespace: Output?
        get() = javaResource.namespace().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The pre-existing service account to generate tokens for.
     * Mutually exclusive with `kubernetes_role_name` and `generated_role_rules`. If set, only a
     * Kubernetes token will be created when credentials are requested.
     */
    public val serviceAccountName: Output?
        get() = javaResource.serviceAccountName().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The default TTL for generated Kubernetes tokens in seconds.
     */
    public val tokenDefaultTtl: Output?
        get() = javaResource.tokenDefaultTtl().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The maximum TTL for generated Kubernetes tokens in seconds.
     */
    public val tokenMaxTtl: Output?
        get() = javaResource.tokenMaxTtl().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })
}

public object SecretBackendRoleMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.vault.kubernetes.SecretBackendRole::class == javaResource::class

    override fun map(javaResource: Resource): SecretBackendRole = SecretBackendRole(
        javaResource as
            com.pulumi.vault.kubernetes.SecretBackendRole,
    )
}

/**
 * @see [SecretBackendRole].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [SecretBackendRole].
 */
public suspend fun secretBackendRole(
    name: String,
    block: suspend SecretBackendRoleResourceBuilder.() -> Unit,
): SecretBackendRole {
    val builder = SecretBackendRoleResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [SecretBackendRole].
 * @param name The _unique_ name of the resulting resource.
 */
public fun secretBackendRole(name: String): SecretBackendRole {
    val builder = SecretBackendRoleResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy