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

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

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

package com.pulumi.azure.batch.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

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

/**
 * Manages a certificate in an Azure Batch account.
 * ## Example Usage
 * 
 * ```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: "testbatch",
 *     location: "West Europe",
 * });
 * const exampleAccount = new azure.storage.Account("example", {
 *     name: "teststorage",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     accountTier: "Standard",
 *     accountReplicationType: "LRS",
 * });
 * const exampleAccount2 = new azure.batch.Account("example", {
 *     name: "testbatchaccount",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     poolAllocationMode: "BatchService",
 *     storageAccountId: exampleAccount.id,
 *     storageAccountAuthenticationMode: "StorageKeys",
 *     tags: {
 *         env: "test",
 *     },
 * });
 * const exampleCertificate = new azure.batch.Certificate("example", {
 *     resourceGroupName: example.name,
 *     accountName: exampleAccount2.name,
 *     certificate: std.filebase64({
 *         input: "certificate.pfx",
 *     }).then(invoke => invoke.result),
 *     format: "Pfx",
 *     password: "password",
 *     thumbprint: "42C107874FD0E4A9583292A2F1098E8FE4B2EDDA",
 *     thumbprintAlgorithm: "SHA1",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * import pulumi_std as std
 * example = azure.core.ResourceGroup("example",
 *     name="testbatch",
 *     location="West Europe")
 * example_account = azure.storage.Account("example",
 *     name="teststorage",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     account_tier="Standard",
 *     account_replication_type="LRS")
 * example_account2 = azure.batch.Account("example",
 *     name="testbatchaccount",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     pool_allocation_mode="BatchService",
 *     storage_account_id=example_account.id,
 *     storage_account_authentication_mode="StorageKeys",
 *     tags={
 *         "env": "test",
 *     })
 * example_certificate = azure.batch.Certificate("example",
 *     resource_group_name=example.name,
 *     account_name=example_account2.name,
 *     certificate=std.filebase64(input="certificate.pfx").result,
 *     format="Pfx",
 *     password="password",
 *     thumbprint="42C107874FD0E4A9583292A2F1098E8FE4B2EDDA",
 *     thumbprint_algorithm="SHA1")
 * ```
 * ```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 = "testbatch",
 *         Location = "West Europe",
 *     });
 *     var exampleAccount = new Azure.Storage.Account("example", new()
 *     {
 *         Name = "teststorage",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         AccountTier = "Standard",
 *         AccountReplicationType = "LRS",
 *     });
 *     var exampleAccount2 = new Azure.Batch.Account("example", new()
 *     {
 *         Name = "testbatchaccount",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         PoolAllocationMode = "BatchService",
 *         StorageAccountId = exampleAccount.Id,
 *         StorageAccountAuthenticationMode = "StorageKeys",
 *         Tags =
 *         {
 *             { "env", "test" },
 *         },
 *     });
 *     var exampleCertificate = new Azure.Batch.Certificate("example", new()
 *     {
 *         ResourceGroupName = example.Name,
 *         AccountName = exampleAccount2.Name,
 *         BatchCertificate = Std.Filebase64.Invoke(new()
 *         {
 *             Input = "certificate.pfx",
 *         }).Apply(invoke => invoke.Result),
 *         Format = "Pfx",
 *         Password = "password",
 *         Thumbprint = "42C107874FD0E4A9583292A2F1098E8FE4B2EDDA",
 *         ThumbprintAlgorithm = "SHA1",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/batch"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/storage"
 * 	"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("testbatch"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleAccount, err := storage.NewAccount(ctx, "example", &storage.AccountArgs{
 * 			Name:                   pulumi.String("teststorage"),
 * 			ResourceGroupName:      example.Name,
 * 			Location:               example.Location,
 * 			AccountTier:            pulumi.String("Standard"),
 * 			AccountReplicationType: pulumi.String("LRS"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleAccount2, err := batch.NewAccount(ctx, "example", &batch.AccountArgs{
 * 			Name:                             pulumi.String("testbatchaccount"),
 * 			ResourceGroupName:                example.Name,
 * 			Location:                         example.Location,
 * 			PoolAllocationMode:               pulumi.String("BatchService"),
 * 			StorageAccountId:                 exampleAccount.ID(),
 * 			StorageAccountAuthenticationMode: pulumi.String("StorageKeys"),
 * 			Tags: pulumi.StringMap{
 * 				"env": pulumi.String("test"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		invokeFilebase64, err := std.Filebase64(ctx, &std.Filebase64Args{
 * 			Input: "certificate.pfx",
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = batch.NewCertificate(ctx, "example", &batch.CertificateArgs{
 * 			ResourceGroupName:   example.Name,
 * 			AccountName:         exampleAccount2.Name,
 * 			Certificate:         pulumi.String(invokeFilebase64.Result),
 * 			Format:              pulumi.String("Pfx"),
 * 			Password:            pulumi.String("password"),
 * 			Thumbprint:          pulumi.String("42C107874FD0E4A9583292A2F1098E8FE4B2EDDA"),
 * 			ThumbprintAlgorithm: pulumi.String("SHA1"),
 * 		})
 * 		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.storage.Account;
 * import com.pulumi.azure.storage.AccountArgs;
 * import com.pulumi.azure.batch.Account;
 * import com.pulumi.azure.batch.AccountArgs;
 * import com.pulumi.azure.batch.Certificate;
 * import com.pulumi.azure.batch.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("testbatch")
 *             .location("West Europe")
 *             .build());
 *         var exampleAccount = new Account("exampleAccount", AccountArgs.builder()
 *             .name("teststorage")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .accountTier("Standard")
 *             .accountReplicationType("LRS")
 *             .build());
 *         var exampleAccount2 = new Account("exampleAccount2", AccountArgs.builder()
 *             .name("testbatchaccount")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .poolAllocationMode("BatchService")
 *             .storageAccountId(exampleAccount.id())
 *             .storageAccountAuthenticationMode("StorageKeys")
 *             .tags(Map.of("env", "test"))
 *             .build());
 *         var exampleCertificate = new Certificate("exampleCertificate", CertificateArgs.builder()
 *             .resourceGroupName(example.name())
 *             .accountName(exampleAccount2.name())
 *             .certificate(StdFunctions.filebase64(Filebase64Args.builder()
 *                 .input("certificate.pfx")
 *                 .build()).result())
 *             .format("Pfx")
 *             .password("password")
 *             .thumbprint("42C107874FD0E4A9583292A2F1098E8FE4B2EDDA")
 *             .thumbprintAlgorithm("SHA1")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: testbatch
 *       location: West Europe
 *   exampleAccount:
 *     type: azure:storage:Account
 *     name: example
 *     properties:
 *       name: teststorage
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       accountTier: Standard
 *       accountReplicationType: LRS
 *   exampleAccount2:
 *     type: azure:batch:Account
 *     name: example
 *     properties:
 *       name: testbatchaccount
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       poolAllocationMode: BatchService
 *       storageAccountId: ${exampleAccount.id}
 *       storageAccountAuthenticationMode: StorageKeys
 *       tags:
 *         env: test
 *   exampleCertificate:
 *     type: azure:batch:Certificate
 *     name: example
 *     properties:
 *       resourceGroupName: ${example.name}
 *       accountName: ${exampleAccount2.name}
 *       certificate:
 *         fn::invoke:
 *           Function: std:filebase64
 *           Arguments:
 *             input: certificate.pfx
 *           Return: result
 *       format: Pfx
 *       password: password
 *       thumbprint: 42C107874FD0E4A9583292A2F1098E8FE4B2EDDA
 *       thumbprintAlgorithm: SHA1
 * ```
 * 
 * ## Import
 * Batch Certificates can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:batch/certificate:Certificate example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-rg/providers/Microsoft.Batch/batchAccounts/batch1/certificates/certificate1
 * ```
 */
public class Certificate internal constructor(
    override val javaResource: com.pulumi.azure.batch.Certificate,
) : KotlinCustomResource(javaResource, CertificateMapper) {
    /**
     * Specifies the name of the Batch account. Changing this forces a new resource to be created.
     */
    public val accountName: Output
        get() = javaResource.accountName().applyValue({ args0 -> args0 })

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

    /**
     * The format of the certificate. Possible values are `Cer` or `Pfx`.
     */
    public val format: Output
        get() = javaResource.format().applyValue({ args0 -> args0 })

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

    /**
     * The password to access the certificate's private key. This can only be specified when `format` is `Pfx`.
     */
    public val password: Output?
        get() = javaResource.password().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

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

    /**
     * The name of the resource group in which to create the Batch account. Changing this forces a new resource to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

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

    /**
     * The algorithm of the certificate thumbprint. At this time the only supported value is `SHA1`. Changing this forces a new resource to be created.
     */
    public val thumbprintAlgorithm: Output
        get() = javaResource.thumbprintAlgorithm().applyValue({ args0 -> args0 })
}

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

    override fun map(javaResource: Resource): Certificate = Certificate(
        javaResource as
            com.pulumi.azure.batch.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