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

com.pulumi.azure.keyvault.kotlin.SecretArgs.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.14.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azure.keyvault.kotlin

import com.pulumi.azure.keyvault.SecretArgs.builder
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import kotlin.Pair
import kotlin.String
import kotlin.Suppress
import kotlin.collections.Map
import kotlin.jvm.JvmName

/**
 * Manages a Key Vault Secret.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const current = azure.core.getClientConfig({});
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const exampleKeyVault = new azure.keyvault.KeyVault("example", {
 *     name: "examplekeyvault",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     tenantId: current.then(current => current.tenantId),
 *     skuName: "premium",
 *     softDeleteRetentionDays: 7,
 *     accessPolicies: [{
 *         tenantId: current.then(current => current.tenantId),
 *         objectId: current.then(current => current.objectId),
 *         keyPermissions: [
 *             "Create",
 *             "Get",
 *         ],
 *         secretPermissions: [
 *             "Set",
 *             "Get",
 *             "Delete",
 *             "Purge",
 *             "Recover",
 *         ],
 *     }],
 * });
 * const exampleSecret = new azure.keyvault.Secret("example", {
 *     name: "secret-sauce",
 *     value: "szechuan",
 *     keyVaultId: exampleKeyVault.id,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * current = azure.core.get_client_config()
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example_key_vault = azure.keyvault.KeyVault("example",
 *     name="examplekeyvault",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     tenant_id=current.tenant_id,
 *     sku_name="premium",
 *     soft_delete_retention_days=7,
 *     access_policies=[azure.keyvault.KeyVaultAccessPolicyArgs(
 *         tenant_id=current.tenant_id,
 *         object_id=current.object_id,
 *         key_permissions=[
 *             "Create",
 *             "Get",
 *         ],
 *         secret_permissions=[
 *             "Set",
 *             "Get",
 *             "Delete",
 *             "Purge",
 *             "Recover",
 *         ],
 *     )])
 * example_secret = azure.keyvault.Secret("example",
 *     name="secret-sauce",
 *     value="szechuan",
 *     key_vault_id=example_key_vault.id)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var current = Azure.Core.GetClientConfig.Invoke();
 *     var example = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "example-resources",
 *         Location = "West Europe",
 *     });
 *     var exampleKeyVault = new Azure.KeyVault.KeyVault("example", new()
 *     {
 *         Name = "examplekeyvault",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         TenantId = current.Apply(getClientConfigResult => getClientConfigResult.TenantId),
 *         SkuName = "premium",
 *         SoftDeleteRetentionDays = 7,
 *         AccessPolicies = new[]
 *         {
 *             new Azure.KeyVault.Inputs.KeyVaultAccessPolicyArgs
 *             {
 *                 TenantId = current.Apply(getClientConfigResult => getClientConfigResult.TenantId),
 *                 ObjectId = current.Apply(getClientConfigResult => getClientConfigResult.ObjectId),
 *                 KeyPermissions = new[]
 *                 {
 *                     "Create",
 *                     "Get",
 *                 },
 *                 SecretPermissions = new[]
 *                 {
 *                     "Set",
 *                     "Get",
 *                     "Delete",
 *                     "Purge",
 *                     "Recover",
 *                 },
 *             },
 *         },
 *     });
 *     var exampleSecret = new Azure.KeyVault.Secret("example", new()
 *     {
 *         Name = "secret-sauce",
 *         Value = "szechuan",
 *         KeyVaultId = exampleKeyVault.Id,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/keyvault"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		current, err := core.GetClientConfig(ctx, nil, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("example-resources"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleKeyVault, err := keyvault.NewKeyVault(ctx, "example", &keyvault.KeyVaultArgs{
 * 			Name:                    pulumi.String("examplekeyvault"),
 * 			Location:                example.Location,
 * 			ResourceGroupName:       example.Name,
 * 			TenantId:                pulumi.String(current.TenantId),
 * 			SkuName:                 pulumi.String("premium"),
 * 			SoftDeleteRetentionDays: pulumi.Int(7),
 * 			AccessPolicies: keyvault.KeyVaultAccessPolicyArray{
 * 				&keyvault.KeyVaultAccessPolicyArgs{
 * 					TenantId: pulumi.String(current.TenantId),
 * 					ObjectId: pulumi.String(current.ObjectId),
 * 					KeyPermissions: pulumi.StringArray{
 * 						pulumi.String("Create"),
 * 						pulumi.String("Get"),
 * 					},
 * 					SecretPermissions: pulumi.StringArray{
 * 						pulumi.String("Set"),
 * 						pulumi.String("Get"),
 * 						pulumi.String("Delete"),
 * 						pulumi.String("Purge"),
 * 						pulumi.String("Recover"),
 * 					},
 * 				},
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = keyvault.NewSecret(ctx, "example", &keyvault.SecretArgs{
 * 			Name:       pulumi.String("secret-sauce"),
 * 			Value:      pulumi.String("szechuan"),
 * 			KeyVaultId: exampleKeyVault.ID(),
 * 		})
 * 		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.azure.core.CoreFunctions;
 * import com.pulumi.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.keyvault.KeyVault;
 * import com.pulumi.azure.keyvault.KeyVaultArgs;
 * import com.pulumi.azure.keyvault.inputs.KeyVaultAccessPolicyArgs;
 * import com.pulumi.azure.keyvault.Secret;
 * import com.pulumi.azure.keyvault.SecretArgs;
 * 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) {
 *         final var current = CoreFunctions.getClientConfig();
 *         var example = new ResourceGroup("example", ResourceGroupArgs.builder()
 *             .name("example-resources")
 *             .location("West Europe")
 *             .build());
 *         var exampleKeyVault = new KeyVault("exampleKeyVault", KeyVaultArgs.builder()
 *             .name("examplekeyvault")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .tenantId(current.applyValue(getClientConfigResult -> getClientConfigResult.tenantId()))
 *             .skuName("premium")
 *             .softDeleteRetentionDays(7)
 *             .accessPolicies(KeyVaultAccessPolicyArgs.builder()
 *                 .tenantId(current.applyValue(getClientConfigResult -> getClientConfigResult.tenantId()))
 *                 .objectId(current.applyValue(getClientConfigResult -> getClientConfigResult.objectId()))
 *                 .keyPermissions(
 *                     "Create",
 *                     "Get")
 *                 .secretPermissions(
 *                     "Set",
 *                     "Get",
 *                     "Delete",
 *                     "Purge",
 *                     "Recover")
 *                 .build())
 *             .build());
 *         var exampleSecret = new Secret("exampleSecret", SecretArgs.builder()
 *             .name("secret-sauce")
 *             .value("szechuan")
 *             .keyVaultId(exampleKeyVault.id())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleKeyVault:
 *     type: azure:keyvault:KeyVault
 *     name: example
 *     properties:
 *       name: examplekeyvault
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       tenantId: ${current.tenantId}
 *       skuName: premium
 *       softDeleteRetentionDays: 7
 *       accessPolicies:
 *         - tenantId: ${current.tenantId}
 *           objectId: ${current.objectId}
 *           keyPermissions:
 *             - Create
 *             - Get
 *           secretPermissions:
 *             - Set
 *             - Get
 *             - Delete
 *             - Purge
 *             - Recover
 *   exampleSecret:
 *     type: azure:keyvault:Secret
 *     name: example
 *     properties:
 *       name: secret-sauce
 *       value: szechuan
 *       keyVaultId: ${exampleKeyVault.id}
 * variables:
 *   current:
 *     fn::invoke:
 *       Function: azure:core:getClientConfig
 *       Arguments: {}
 * ```
 * 
 * ## Import
 * Key Vault Secrets which are Enabled can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:keyvault/secret:Secret example "https://example-keyvault.vault.azure.net/secrets/example/fdf067c93bbb4b22bff4d8b7a9a56217"
 * ```
 * @property contentType Specifies the content type for the Key Vault Secret.
 * @property expirationDate Expiration UTC datetime (Y-m-d'T'H:M:S'Z').
 * @property keyVaultId The ID of the Key Vault where the Secret should be created. Changing this forces a new resource to be created.
 * @property name Specifies the name of the Key Vault Secret. Changing this forces a new resource to be created.
 * @property notBeforeDate Key not usable before the provided UTC datetime (Y-m-d'T'H:M:S'Z').
 * @property tags A mapping of tags to assign to the resource.
 * @property value Specifies the value of the Key Vault Secret. Changing this will create a new version of the Key Vault Secret.
 * > **Note:** Key Vault strips newlines. To preserve newlines in multi-line secrets try replacing them with `\n` or by base 64 encoding them with `replace(file("my_secret_file"), "/\n/", "\n")` or `base64encode(file("my_secret_file"))`, respectively.
 */
public data class SecretArgs(
    public val contentType: Output? = null,
    public val expirationDate: Output? = null,
    public val keyVaultId: Output? = null,
    public val name: Output? = null,
    public val notBeforeDate: Output? = null,
    public val tags: Output>? = null,
    public val `value`: Output? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.azure.keyvault.SecretArgs =
        com.pulumi.azure.keyvault.SecretArgs.builder()
            .contentType(contentType?.applyValue({ args0 -> args0 }))
            .expirationDate(expirationDate?.applyValue({ args0 -> args0 }))
            .keyVaultId(keyVaultId?.applyValue({ args0 -> args0 }))
            .name(name?.applyValue({ args0 -> args0 }))
            .notBeforeDate(notBeforeDate?.applyValue({ args0 -> args0 }))
            .tags(tags?.applyValue({ args0 -> args0.map({ args0 -> args0.key.to(args0.value) }).toMap() }))
            .`value`(`value`?.applyValue({ args0 -> args0 })).build()
}

/**
 * Builder for [SecretArgs].
 */
@PulumiTagMarker
public class SecretArgsBuilder internal constructor() {
    private var contentType: Output? = null

    private var expirationDate: Output? = null

    private var keyVaultId: Output? = null

    private var name: Output? = null

    private var notBeforeDate: Output? = null

    private var tags: Output>? = null

    private var `value`: Output? = null

    /**
     * @param value Specifies the content type for the Key Vault Secret.
     */
    @JvmName("nbbyltyiuaekisch")
    public suspend fun contentType(`value`: Output) {
        this.contentType = value
    }

    /**
     * @param value Expiration UTC datetime (Y-m-d'T'H:M:S'Z').
     */
    @JvmName("rfkdqddfaifuauuk")
    public suspend fun expirationDate(`value`: Output) {
        this.expirationDate = value
    }

    /**
     * @param value The ID of the Key Vault where the Secret should be created. Changing this forces a new resource to be created.
     */
    @JvmName("wvmtoviyamqvjnud")
    public suspend fun keyVaultId(`value`: Output) {
        this.keyVaultId = value
    }

    /**
     * @param value Specifies the name of the Key Vault Secret. Changing this forces a new resource to be created.
     */
    @JvmName("rfcfpscjelqqtdok")
    public suspend fun name(`value`: Output) {
        this.name = value
    }

    /**
     * @param value Key not usable before the provided UTC datetime (Y-m-d'T'H:M:S'Z').
     */
    @JvmName("bmgtauvcylwfrkre")
    public suspend fun notBeforeDate(`value`: Output) {
        this.notBeforeDate = value
    }

    /**
     * @param value A mapping of tags to assign to the resource.
     */
    @JvmName("eegsafbujbsbcmwk")
    public suspend fun tags(`value`: Output>) {
        this.tags = value
    }

    /**
     * @param value Specifies the value of the Key Vault Secret. Changing this will create a new version of the Key Vault Secret.
     * > **Note:** Key Vault strips newlines. To preserve newlines in multi-line secrets try replacing them with `\n` or by base 64 encoding them with `replace(file("my_secret_file"), "/\n/", "\n")` or `base64encode(file("my_secret_file"))`, respectively.
     */
    @JvmName("ylmlvuhbtpmsgbys")
    public suspend fun `value`(`value`: Output) {
        this.`value` = value
    }

    /**
     * @param value Specifies the content type for the Key Vault Secret.
     */
    @JvmName("ekaucimnhcfavicf")
    public suspend fun contentType(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.contentType = mapped
    }

    /**
     * @param value Expiration UTC datetime (Y-m-d'T'H:M:S'Z').
     */
    @JvmName("tascdgmiyiqufuyw")
    public suspend fun expirationDate(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.expirationDate = mapped
    }

    /**
     * @param value The ID of the Key Vault where the Secret should be created. Changing this forces a new resource to be created.
     */
    @JvmName("clxvjohslobmidwr")
    public suspend fun keyVaultId(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.keyVaultId = mapped
    }

    /**
     * @param value Specifies the name of the Key Vault Secret. Changing this forces a new resource to be created.
     */
    @JvmName("xnksyivmjfxygnwg")
    public suspend fun name(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.name = mapped
    }

    /**
     * @param value Key not usable before the provided UTC datetime (Y-m-d'T'H:M:S'Z').
     */
    @JvmName("dliwompdkfcegxtd")
    public suspend fun notBeforeDate(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.notBeforeDate = mapped
    }

    /**
     * @param value A mapping of tags to assign to the resource.
     */
    @JvmName("dqfacryuthtllqms")
    public suspend fun tags(`value`: Map?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.tags = mapped
    }

    /**
     * @param values A mapping of tags to assign to the resource.
     */
    @JvmName("fvybkkenbnadyqbe")
    public fun tags(vararg values: Pair) {
        val toBeMapped = values.toMap()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.tags = mapped
    }

    /**
     * @param value Specifies the value of the Key Vault Secret. Changing this will create a new version of the Key Vault Secret.
     * > **Note:** Key Vault strips newlines. To preserve newlines in multi-line secrets try replacing them with `\n` or by base 64 encoding them with `replace(file("my_secret_file"), "/\n/", "\n")` or `base64encode(file("my_secret_file"))`, respectively.
     */
    @JvmName("tagietkiksfgxpwn")
    public suspend fun `value`(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.`value` = mapped
    }

    internal fun build(): SecretArgs = SecretArgs(
        contentType = contentType,
        expirationDate = expirationDate,
        keyVaultId = keyVaultId,
        name = name,
        notBeforeDate = notBeforeDate,
        tags = tags,
        `value` = `value`,
    )
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy