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

com.pulumi.vault.ad.kotlin.SecretRole.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.ad.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

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

    public var args: SecretRoleArgs = SecretRoleArgs()

    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 SecretRoleArgsBuilder.() -> Unit) {
        val builder = SecretRoleArgsBuilder()
        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(): SecretRole {
        val builtJavaResource = com.pulumi.vault.ad.SecretRole(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return SecretRole(builtJavaResource)
    }
}

/**
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as vault from "@pulumi/vault";
 * const config = new vault.ad.SecretBackend("config", {
 *     backend: "ad",
 *     binddn: "CN=Administrator,CN=Users,DC=corp,DC=example,DC=net",
 *     bindpass: "SuperSecretPassw0rd",
 *     url: "ldaps://ad",
 *     insecureTls: true,
 *     userdn: "CN=Users,DC=corp,DC=example,DC=net",
 * });
 * const role = new vault.ad.SecretRole("role", {
 *     backend: config.backend,
 *     role: "bob",
 *     serviceAccountName: "Bob",
 *     ttl: 60,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_vault as vault
 * config = vault.ad.SecretBackend("config",
 *     backend="ad",
 *     binddn="CN=Administrator,CN=Users,DC=corp,DC=example,DC=net",
 *     bindpass="SuperSecretPassw0rd",
 *     url="ldaps://ad",
 *     insecure_tls=True,
 *     userdn="CN=Users,DC=corp,DC=example,DC=net")
 * role = vault.ad.SecretRole("role",
 *     backend=config.backend,
 *     role="bob",
 *     service_account_name="Bob",
 *     ttl=60)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Vault = Pulumi.Vault;
 * return await Deployment.RunAsync(() =>
 * {
 *     var config = new Vault.AD.SecretBackend("config", new()
 *     {
 *         Backend = "ad",
 *         Binddn = "CN=Administrator,CN=Users,DC=corp,DC=example,DC=net",
 *         Bindpass = "SuperSecretPassw0rd",
 *         Url = "ldaps://ad",
 *         InsecureTls = true,
 *         Userdn = "CN=Users,DC=corp,DC=example,DC=net",
 *     });
 *     var role = new Vault.AD.SecretRole("role", new()
 *     {
 *         Backend = config.Backend,
 *         Role = "bob",
 *         ServiceAccountName = "Bob",
 *         Ttl = 60,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-vault/sdk/v6/go/vault/ad"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		config, err := ad.NewSecretBackend(ctx, "config", &ad.SecretBackendArgs{
 * 			Backend:     pulumi.String("ad"),
 * 			Binddn:      pulumi.String("CN=Administrator,CN=Users,DC=corp,DC=example,DC=net"),
 * 			Bindpass:    pulumi.String("SuperSecretPassw0rd"),
 * 			Url:         pulumi.String("ldaps://ad"),
 * 			InsecureTls: pulumi.Bool(true),
 * 			Userdn:      pulumi.String("CN=Users,DC=corp,DC=example,DC=net"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = ad.NewSecretRole(ctx, "role", &ad.SecretRoleArgs{
 * 			Backend:            config.Backend,
 * 			Role:               pulumi.String("bob"),
 * 			ServiceAccountName: pulumi.String("Bob"),
 * 			Ttl:                pulumi.Int(60),
 * 		})
 * 		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.ad.SecretBackend;
 * import com.pulumi.vault.ad.SecretBackendArgs;
 * import com.pulumi.vault.ad.SecretRole;
 * import com.pulumi.vault.ad.SecretRoleArgs;
 * 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()
 *             .backend("ad")
 *             .binddn("CN=Administrator,CN=Users,DC=corp,DC=example,DC=net")
 *             .bindpass("SuperSecretPassw0rd")
 *             .url("ldaps://ad")
 *             .insecureTls("true")
 *             .userdn("CN=Users,DC=corp,DC=example,DC=net")
 *             .build());
 *         var role = new SecretRole("role", SecretRoleArgs.builder()
 *             .backend(config.backend())
 *             .role("bob")
 *             .serviceAccountName("Bob")
 *             .ttl(60)
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   config:
 *     type: vault:ad:SecretBackend
 *     properties:
 *       backend: ad
 *       binddn: CN=Administrator,CN=Users,DC=corp,DC=example,DC=net
 *       bindpass: SuperSecretPassw0rd
 *       url: ldaps://ad
 *       insecureTls: 'true'
 *       userdn: CN=Users,DC=corp,DC=example,DC=net
 *   role:
 *     type: vault:ad:SecretRole
 *     properties:
 *       backend: ${config.backend}
 *       role: bob
 *       serviceAccountName: Bob
 *       ttl: 60
 * ```
 * 
 * ## Import
 * AD secret backend roles can be imported using the `path`, e.g.
 * ```sh
 * $ pulumi import vault:ad/secretRole:SecretRole role ad/roles/bob
 * ```
 */
public class SecretRole internal constructor(
    override val javaResource: com.pulumi.vault.ad.SecretRole,
) : KotlinCustomResource(javaResource, SecretRoleMapper) {
    /**
     * The path the AD secret backend is mounted at,
     * with no leading or trailing `/`s.
     */
    public val backend: Output
        get() = javaResource.backend().applyValue({ args0 -> args0 })

    /**
     * Timestamp of the last password rotation by Vault.
     */
    public val lastVaultRotation: Output
        get() = javaResource.lastVaultRotation().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) })

    /**
     * Timestamp of the last password set by Vault.
     */
    public val passwordLastSet: Output
        get() = javaResource.passwordLastSet().applyValue({ args0 -> args0 })

    /**
     * The name to identify this role within the backend.
     * Must be unique within the backend.
     */
    public val role: Output
        get() = javaResource.role().applyValue({ args0 -> args0 })

    /**
     * Specifies the name of the Active Directory service
     * account mapped to this role.
     */
    public val serviceAccountName: Output
        get() = javaResource.serviceAccountName().applyValue({ args0 -> args0 })

    /**
     * The password time-to-live in seconds. Defaults to the configuration
     * ttl if not provided.
     */
    public val ttl: Output?
        get() = javaResource.ttl().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
}

public object SecretRoleMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.vault.ad.SecretRole::class == javaResource::class

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy