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

com.pulumi.azure.mssql.kotlin.VirtualMachine.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.mssql.kotlin

import com.pulumi.azure.mssql.kotlin.outputs.VirtualMachineAssessment
import com.pulumi.azure.mssql.kotlin.outputs.VirtualMachineAutoBackup
import com.pulumi.azure.mssql.kotlin.outputs.VirtualMachineAutoPatching
import com.pulumi.azure.mssql.kotlin.outputs.VirtualMachineKeyVaultCredential
import com.pulumi.azure.mssql.kotlin.outputs.VirtualMachineSqlInstance
import com.pulumi.azure.mssql.kotlin.outputs.VirtualMachineStorageConfiguration
import com.pulumi.azure.mssql.kotlin.outputs.VirtualMachineWsfcDomainCredential
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.Map
import com.pulumi.azure.mssql.kotlin.outputs.VirtualMachineAssessment.Companion.toKotlin as virtualMachineAssessmentToKotlin
import com.pulumi.azure.mssql.kotlin.outputs.VirtualMachineAutoBackup.Companion.toKotlin as virtualMachineAutoBackupToKotlin
import com.pulumi.azure.mssql.kotlin.outputs.VirtualMachineAutoPatching.Companion.toKotlin as virtualMachineAutoPatchingToKotlin
import com.pulumi.azure.mssql.kotlin.outputs.VirtualMachineKeyVaultCredential.Companion.toKotlin as virtualMachineKeyVaultCredentialToKotlin
import com.pulumi.azure.mssql.kotlin.outputs.VirtualMachineSqlInstance.Companion.toKotlin as virtualMachineSqlInstanceToKotlin
import com.pulumi.azure.mssql.kotlin.outputs.VirtualMachineStorageConfiguration.Companion.toKotlin as virtualMachineStorageConfigurationToKotlin
import com.pulumi.azure.mssql.kotlin.outputs.VirtualMachineWsfcDomainCredential.Companion.toKotlin as virtualMachineWsfcDomainCredentialToKotlin

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

    public var args: VirtualMachineArgs = VirtualMachineArgs()

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

/**
 * Manages a Microsoft SQL Virtual Machine
 * ## Example Usage
 * This example provisions a brief Managed Microsoft SQL Virtual Machine.
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = azure.compute.getVirtualMachine({
 *     name: "example-vm",
 *     resourceGroupName: "example-resources",
 * });
 * const exampleVirtualMachine = new azure.mssql.VirtualMachine("example", {
 *     virtualMachineId: example.then(example => example.id),
 *     sqlLicenseType: "PAYG",
 *     rServicesEnabled: true,
 *     sqlConnectivityPort: 1433,
 *     sqlConnectivityType: "PRIVATE",
 *     sqlConnectivityUpdatePassword: "Password1234!",
 *     sqlConnectivityUpdateUsername: "sqllogin",
 *     autoPatching: {
 *         dayOfWeek: "Sunday",
 *         maintenanceWindowDurationInMinutes: 60,
 *         maintenanceWindowStartingHour: 2,
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.compute.get_virtual_machine(name="example-vm",
 *     resource_group_name="example-resources")
 * example_virtual_machine = azure.mssql.VirtualMachine("example",
 *     virtual_machine_id=example.id,
 *     sql_license_type="PAYG",
 *     r_services_enabled=True,
 *     sql_connectivity_port=1433,
 *     sql_connectivity_type="PRIVATE",
 *     sql_connectivity_update_password="Password1234!",
 *     sql_connectivity_update_username="sqllogin",
 *     auto_patching={
 *         "day_of_week": "Sunday",
 *         "maintenance_window_duration_in_minutes": 60,
 *         "maintenance_window_starting_hour": 2,
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = Azure.Compute.GetVirtualMachine.Invoke(new()
 *     {
 *         Name = "example-vm",
 *         ResourceGroupName = "example-resources",
 *     });
 *     var exampleVirtualMachine = new Azure.MSSql.VirtualMachine("example", new()
 *     {
 *         VirtualMachineId = example.Apply(getVirtualMachineResult => getVirtualMachineResult.Id),
 *         SqlLicenseType = "PAYG",
 *         RServicesEnabled = true,
 *         SqlConnectivityPort = 1433,
 *         SqlConnectivityType = "PRIVATE",
 *         SqlConnectivityUpdatePassword = "Password1234!",
 *         SqlConnectivityUpdateUsername = "sqllogin",
 *         AutoPatching = new Azure.MSSql.Inputs.VirtualMachineAutoPatchingArgs
 *         {
 *             DayOfWeek = "Sunday",
 *             MaintenanceWindowDurationInMinutes = 60,
 *             MaintenanceWindowStartingHour = 2,
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/compute"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/mssql"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		example, err := compute.LookupVirtualMachine(ctx, &compute.LookupVirtualMachineArgs{
 * 			Name:              "example-vm",
 * 			ResourceGroupName: "example-resources",
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = mssql.NewVirtualMachine(ctx, "example", &mssql.VirtualMachineArgs{
 * 			VirtualMachineId:              pulumi.String(example.Id),
 * 			SqlLicenseType:                pulumi.String("PAYG"),
 * 			RServicesEnabled:              pulumi.Bool(true),
 * 			SqlConnectivityPort:           pulumi.Int(1433),
 * 			SqlConnectivityType:           pulumi.String("PRIVATE"),
 * 			SqlConnectivityUpdatePassword: pulumi.String("Password1234!"),
 * 			SqlConnectivityUpdateUsername: pulumi.String("sqllogin"),
 * 			AutoPatching: &mssql.VirtualMachineAutoPatchingArgs{
 * 				DayOfWeek:                          pulumi.String("Sunday"),
 * 				MaintenanceWindowDurationInMinutes: pulumi.Int(60),
 * 				MaintenanceWindowStartingHour:      pulumi.Int(2),
 * 			},
 * 		})
 * 		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.compute.ComputeFunctions;
 * import com.pulumi.azure.compute.inputs.GetVirtualMachineArgs;
 * import com.pulumi.azure.mssql.VirtualMachine;
 * import com.pulumi.azure.mssql.VirtualMachineArgs;
 * import com.pulumi.azure.mssql.inputs.VirtualMachineAutoPatchingArgs;
 * 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 example = ComputeFunctions.getVirtualMachine(GetVirtualMachineArgs.builder()
 *             .name("example-vm")
 *             .resourceGroupName("example-resources")
 *             .build());
 *         var exampleVirtualMachine = new VirtualMachine("exampleVirtualMachine", VirtualMachineArgs.builder()
 *             .virtualMachineId(example.applyValue(getVirtualMachineResult -> getVirtualMachineResult.id()))
 *             .sqlLicenseType("PAYG")
 *             .rServicesEnabled(true)
 *             .sqlConnectivityPort(1433)
 *             .sqlConnectivityType("PRIVATE")
 *             .sqlConnectivityUpdatePassword("Password1234!")
 *             .sqlConnectivityUpdateUsername("sqllogin")
 *             .autoPatching(VirtualMachineAutoPatchingArgs.builder()
 *                 .dayOfWeek("Sunday")
 *                 .maintenanceWindowDurationInMinutes(60)
 *                 .maintenanceWindowStartingHour(2)
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   exampleVirtualMachine:
 *     type: azure:mssql:VirtualMachine
 *     name: example
 *     properties:
 *       virtualMachineId: ${example.id}
 *       sqlLicenseType: PAYG
 *       rServicesEnabled: true
 *       sqlConnectivityPort: 1433
 *       sqlConnectivityType: PRIVATE
 *       sqlConnectivityUpdatePassword: Password1234!
 *       sqlConnectivityUpdateUsername: sqllogin
 *       autoPatching:
 *         dayOfWeek: Sunday
 *         maintenanceWindowDurationInMinutes: 60
 *         maintenanceWindowStartingHour: 2
 * variables:
 *   example:
 *     fn::invoke:
 *       Function: azure:compute:getVirtualMachine
 *       Arguments:
 *         name: example-vm
 *         resourceGroupName: example-resources
 * ```
 * 
 * ## Import
 * Microsoft SQL Virtual Machines can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:mssql/virtualMachine:VirtualMachine example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/example1
 * ```
 */
public class VirtualMachine internal constructor(
    override val javaResource: com.pulumi.azure.mssql.VirtualMachine,
) : KotlinCustomResource(javaResource, VirtualMachineMapper) {
    /**
     * An `assessment` block as defined below.
     */
    public val assessment: Output?
        get() = javaResource.assessment().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    virtualMachineAssessmentToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * An `auto_backup` block as defined below. This block can be added to an existing resource, but removing this block forces a new resource to be created.
     */
    public val autoBackup: Output?
        get() = javaResource.autoBackup().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    virtualMachineAutoBackupToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * An `auto_patching` block as defined below.
     */
    public val autoPatching: Output?
        get() = javaResource.autoPatching().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    virtualMachineAutoPatchingToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * An `key_vault_credential` block as defined below.
     */
    public val keyVaultCredential: Output?
        get() = javaResource.keyVaultCredential().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> virtualMachineKeyVaultCredentialToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * Should R Services be enabled?
     */
    public val rServicesEnabled: Output?
        get() = javaResource.rServicesEnabled().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The SQL Server port. Defaults to `1433`.
     */
    public val sqlConnectivityPort: Output?
        get() = javaResource.sqlConnectivityPort().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The connectivity type used for this SQL Server. Possible values are `LOCAL`, `PRIVATE` and `PUBLIC`. Defaults to `PRIVATE`.
     */
    public val sqlConnectivityType: Output?
        get() = javaResource.sqlConnectivityType().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The SQL Server sysadmin login password.
     */
    public val sqlConnectivityUpdatePassword: Output?
        get() = javaResource.sqlConnectivityUpdatePassword().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The SQL Server sysadmin login to create.
     */
    public val sqlConnectivityUpdateUsername: Output?
        get() = javaResource.sqlConnectivityUpdateUsername().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * A `sql_instance` block as defined below.
     */
    public val sqlInstance: Output?
        get() = javaResource.sqlInstance().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    virtualMachineSqlInstanceToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * The SQL Server license type. Possible values are `AHUB` (Azure Hybrid Benefit), `DR` (Disaster Recovery), and `PAYG` (Pay-As-You-Go). Changing this forces a new resource to be created.
     */
    public val sqlLicenseType: Output?
        get() = javaResource.sqlLicenseType().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The ID of the SQL Virtual Machine Group that the SQL Virtual Machine belongs to.
     */
    public val sqlVirtualMachineGroupId: Output?
        get() = javaResource.sqlVirtualMachineGroupId().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * An `storage_configuration` block as defined below.
     */
    public val storageConfiguration: Output?
        get() = javaResource.storageConfiguration().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> virtualMachineStorageConfigurationToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * A mapping of tags to assign to the resource.
     */
    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

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

    /**
     * A `wsfc_domain_credential` block as defined below
     */
    public val wsfcDomainCredential: Output?
        get() = javaResource.wsfcDomainCredential().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> virtualMachineWsfcDomainCredentialToKotlin(args0) })
            }).orElse(null)
        })
}

public object VirtualMachineMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.mssql.VirtualMachine::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy