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

com.pulumi.vault.consul.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.consul.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

/**
 * 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.consul.SecretBackendRole(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return SecretBackendRole(builtJavaResource)
    }
}

/**
 * Manages a Consul secrets role for a Consul secrets engine in Vault. Consul secret backends can then issue Consul tokens.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as vault from "@pulumi/vault";
 * const test = new vault.consul.SecretBackend("test", {
 *     path: "consul",
 *     description: "Manages the Consul backend",
 *     address: "127.0.0.1:8500",
 *     token: "4240861b-ce3d-8530-115a-521ff070dd29",
 * });
 * const example = new vault.consul.SecretBackendRole("example", {
 *     name: "test-role",
 *     backend: test.path,
 *     consulPolicies: ["example-policy"],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_vault as vault
 * test = vault.consul.SecretBackend("test",
 *     path="consul",
 *     description="Manages the Consul backend",
 *     address="127.0.0.1:8500",
 *     token="4240861b-ce3d-8530-115a-521ff070dd29")
 * example = vault.consul.SecretBackendRole("example",
 *     name="test-role",
 *     backend=test.path,
 *     consul_policies=["example-policy"])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Vault = Pulumi.Vault;
 * return await Deployment.RunAsync(() =>
 * {
 *     var test = new Vault.Consul.SecretBackend("test", new()
 *     {
 *         Path = "consul",
 *         Description = "Manages the Consul backend",
 *         Address = "127.0.0.1:8500",
 *         Token = "4240861b-ce3d-8530-115a-521ff070dd29",
 *     });
 *     var example = new Vault.Consul.SecretBackendRole("example", new()
 *     {
 *         Name = "test-role",
 *         Backend = test.Path,
 *         ConsulPolicies = new[]
 *         {
 *             "example-policy",
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-vault/sdk/v6/go/vault/consul"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		test, err := consul.NewSecretBackend(ctx, "test", &consul.SecretBackendArgs{
 * 			Path:        pulumi.String("consul"),
 * 			Description: pulumi.String("Manages the Consul backend"),
 * 			Address:     pulumi.String("127.0.0.1:8500"),
 * 			Token:       pulumi.String("4240861b-ce3d-8530-115a-521ff070dd29"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = consul.NewSecretBackendRole(ctx, "example", &consul.SecretBackendRoleArgs{
 * 			Name:    pulumi.String("test-role"),
 * 			Backend: test.Path,
 * 			ConsulPolicies: pulumi.StringArray{
 * 				pulumi.String("example-policy"),
 * 			},
 * 		})
 * 		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.consul.SecretBackend;
 * import com.pulumi.vault.consul.SecretBackendArgs;
 * import com.pulumi.vault.consul.SecretBackendRole;
 * import com.pulumi.vault.consul.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 test = new SecretBackend("test", SecretBackendArgs.builder()
 *             .path("consul")
 *             .description("Manages the Consul backend")
 *             .address("127.0.0.1:8500")
 *             .token("4240861b-ce3d-8530-115a-521ff070dd29")
 *             .build());
 *         var example = new SecretBackendRole("example", SecretBackendRoleArgs.builder()
 *             .name("test-role")
 *             .backend(test.path())
 *             .consulPolicies("example-policy")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   test:
 *     type: vault:consul:SecretBackend
 *     properties:
 *       path: consul
 *       description: Manages the Consul backend
 *       address: 127.0.0.1:8500
 *       token: 4240861b-ce3d-8530-115a-521ff070dd29
 *   example:
 *     type: vault:consul:SecretBackendRole
 *     properties:
 *       name: test-role
 *       backend: ${test.path}
 *       consulPolicies:
 *         - example-policy
 * ```
 * 
 * ## Note About Required Arguments
 * *At least one* of the four arguments `consul_policies`, `consul_roles`, `service_identities`, or
 * `node_identities` is required for a token. If desired, any combination of the four arguments up-to and
 * including all four, is valid.
 * ## Import
 * Consul secret backend roles can be imported using the `backend`, `/roles/`, and the `name` e.g.
 * ```sh
 * $ pulumi import vault:consul/secretBackendRole:SecretBackendRole example consul/roles/my-role
 * ```
 */
public class SecretBackendRole internal constructor(
    override val javaResource: com.pulumi.vault.consul.SecretBackendRole,
) : KotlinCustomResource(javaResource, SecretBackendRoleMapper) {
    /**
     * The unique name of an existing Consul secrets backend mount. Must not begin or end with a `/`. One of `path` or `backend` is required.
     */
    public val backend: Output?
        get() = javaResource.backend().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The Consul namespace that the token will be created in.
     * Applicable for Vault 1.10+ and Consul 1.7+".
     */
    public val consulNamespace: Output
        get() = javaResource.consulNamespace().applyValue({ args0 -> args0 })

    /**
     * SEE NOTE The list of Consul ACL policies to associate with these roles.
     */
    public val consulPolicies: Output>?
        get() = javaResource.consulPolicies().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0 })
            }).orElse(null)
        })

    /**
     * SEE NOTE Set of Consul roles to attach to the token.
     * Applicable for Vault 1.10+ with Consul 1.5+.
     */
    public val consulRoles: Output>?
        get() = javaResource.consulRoles().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0
                })
            }).orElse(null)
        })

    /**
     * Indicates that the token should not be replicated globally and instead be local to the current datacenter.
     */
    public val local: Output?
        get() = javaResource.local().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * Maximum TTL for leases associated with this role, in seconds.
     */
    public val maxTtl: Output?
        get() = javaResource.maxTtl().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

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

    /**
     * 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) })

    /**
     * SEE NOTE Set of Consul node
     * identities to attach to the token. Applicable for Vault 1.11+ with Consul 1.8+.
     */
    public val nodeIdentities: Output>?
        get() = javaResource.nodeIdentities().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0 })
            }).orElse(null)
        })

    /**
     * The admin partition that the token will be created in.
     * Applicable for Vault 1.10+ and Consul 1.11+".
     */
    public val partition: Output
        get() = javaResource.partition().applyValue({ args0 -> args0 })

    /**
     * The list of Consul ACL policies to associate with these roles.
     * **NOTE:** The new parameter `consul_policies` should be used in favor of this. This parameter,
     * `policies`, remains supported for legacy users, but Vault has deprecated this field.
     */
    public val policies: Output>?
        get() = javaResource.policies().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0
                })
            }).orElse(null)
        })

    /**
     * SEE NOTE Set of Consul
     * service identities to attach to the token. Applicable for Vault 1.11+ with Consul 1.5+.
     */
    public val serviceIdentities: Output>?
        get() = javaResource.serviceIdentities().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 -> args0 })
            }).orElse(null)
        })

    /**
     * Specifies the TTL for this role.
     */
    public val ttl: Output?
        get() = javaResource.ttl().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
}

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

    override fun map(javaResource: Resource): SecretBackendRole = SecretBackendRole(
        javaResource as
            com.pulumi.vault.consul.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