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

com.pulumi.azure.appservice.kotlin.Certificate.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azure.appservice.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.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map

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

    public var args: CertificateArgs = CertificateArgs()

    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 CertificateArgsBuilder.() -> Unit) {
        val builder = CertificateArgsBuilder()
        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(): Certificate {
        val builtJavaResource = com.pulumi.azure.appservice.Certificate(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Certificate(builtJavaResource)
    }
}

/**
 * Manages an App Service certificate.
 * ## Example Usage
 * This example provisions an App Service Certificate from a Local File.
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * import * as std from "@pulumi/std";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const exampleCertificate = new azure.appservice.Certificate("example", {
 *     name: "example-cert",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     pfxBlob: std.filebase64({
 *         input: "certificate.pfx",
 *     }).then(invoke => invoke.result),
 *     password: "password123!",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * import pulumi_std as std
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example_certificate = azure.appservice.Certificate("example",
 *     name="example-cert",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     pfx_blob=std.filebase64(input="certificate.pfx").result,
 *     password="password123!")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * using Std = Pulumi.Std;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "example-resources",
 *         Location = "West Europe",
 *     });
 *     var exampleCertificate = new Azure.AppService.Certificate("example", new()
 *     {
 *         Name = "example-cert",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         PfxBlob = Std.Filebase64.Invoke(new()
 *         {
 *             Input = "certificate.pfx",
 *         }).Apply(invoke => invoke.Result),
 *         Password = "password123!",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/appservice"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-std/sdk/go/std"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("example-resources"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		invokeFilebase64, err := std.Filebase64(ctx, &std.Filebase64Args{
 * 			Input: "certificate.pfx",
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = appservice.NewCertificate(ctx, "example", &appservice.CertificateArgs{
 * 			Name:              pulumi.String("example-cert"),
 * 			ResourceGroupName: example.Name,
 * 			Location:          example.Location,
 * 			PfxBlob:           pulumi.String(invokeFilebase64.Result),
 * 			Password:          pulumi.String("password123!"),
 * 		})
 * 		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.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.appservice.Certificate;
 * import com.pulumi.azure.appservice.CertificateArgs;
 * 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 example = new ResourceGroup("example", ResourceGroupArgs.builder()
 *             .name("example-resources")
 *             .location("West Europe")
 *             .build());
 *         var exampleCertificate = new Certificate("exampleCertificate", CertificateArgs.builder()
 *             .name("example-cert")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .pfxBlob(StdFunctions.filebase64(Filebase64Args.builder()
 *                 .input("certificate.pfx")
 *                 .build()).result())
 *             .password("password123!")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleCertificate:
 *     type: azure:appservice:Certificate
 *     name: example
 *     properties:
 *       name: example-cert
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       pfxBlob:
 *         fn::invoke:
 *           Function: std:filebase64
 *           Arguments:
 *             input: certificate.pfx
 *           Return: result
 *       password: password123!
 * ```
 * 
 * ## Import
 * App Service Certificates can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:appservice/certificate:Certificate example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/certificates/certificate1
 * ```
 */
public class Certificate internal constructor(
    override val javaResource: com.pulumi.azure.appservice.Certificate,
) : KotlinCustomResource(javaResource, CertificateMapper) {
    /**
     * The ID of the associated App Service plan. Must be specified when the certificate is used inside an App Service Environment hosted App Service or with Premium App Service plans. Changing this forces a new resource to be created.
     */
    public val appServicePlanId: Output?
        get() = javaResource.appServicePlanId().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The expiration date for the certificate.
     */
    public val expirationDate: Output
        get() = javaResource.expirationDate().applyValue({ args0 -> args0 })

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

    /**
     * List of host names the certificate applies to.
     */
    public val hostNames: Output>
        get() = javaResource.hostNames().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

    /**
     * The ID of the App Service Environment where the certificate is in use.
     */
    public val hostingEnvironmentProfileId: Output
        get() = javaResource.hostingEnvironmentProfileId().applyValue({ args0 -> args0 })

    /**
     * The issue date for the certificate.
     */
    public val issueDate: Output
        get() = javaResource.issueDate().applyValue({ args0 -> args0 })

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

    public val keyVaultId: Output?
        get() = javaResource.keyVaultId().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The ID of the Key Vault secret. Changing this forces a new resource to be created.
     * > **NOTE:** Exactly one of `key_vault_secret_id` or `pfx_blob` must be specified.
     */
    public val keyVaultSecretId: Output?
        get() = javaResource.keyVaultSecretId().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

    /**
     * Specifies the name of the certificate. Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The password to access the certificate's private key. Changing this forces a new resource to be created.
     */
    public val password: Output?
        get() = javaResource.password().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The base64-encoded contents of the certificate. Changing this forces a new resource to be created.
     * > **NOTE:** Exactly one of `key_vault_secret_id` or `pfx_blob` must be specified.
     */
    public val pfxBlob: Output?
        get() = javaResource.pfxBlob().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * The name of the resource group in which to create the certificate. Changing this forces a new resource to be created.
     * > **NOTE:** The resource group must be the same as that which the app service plan is defined in - otherwise the certificate will not show as available for the app services.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

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

    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * The thumbprint for the certificate.
     */
    public val thumbprint: Output
        get() = javaResource.thumbprint().applyValue({ args0 -> args0 })
}

public object CertificateMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.appservice.Certificate::class == javaResource::class

    override fun map(javaResource: Resource): Certificate = Certificate(
        javaResource as
            com.pulumi.azure.appservice.Certificate,
    )
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy