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

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

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

package com.pulumi.azure.mssql.kotlin

import com.pulumi.azure.mssql.kotlin.outputs.ManagedDatabaseLongTermRetentionPolicy
import com.pulumi.azure.mssql.kotlin.outputs.ManagedDatabasePointInTimeRestore
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 com.pulumi.azure.mssql.kotlin.outputs.ManagedDatabaseLongTermRetentionPolicy.Companion.toKotlin as managedDatabaseLongTermRetentionPolicyToKotlin
import com.pulumi.azure.mssql.kotlin.outputs.ManagedDatabasePointInTimeRestore.Companion.toKotlin as managedDatabasePointInTimeRestoreToKotlin

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

    public var args: ManagedDatabaseArgs = ManagedDatabaseArgs()

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

/**
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example",
 *     location: "West Europe",
 * });
 * const exampleVirtualNetwork = new azure.network.VirtualNetwork("example", {
 *     name: "example",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     addressSpaces: ["10.0.0.0/16"],
 * });
 * const exampleSubnet = new azure.network.Subnet("example", {
 *     name: "example",
 *     resourceGroupName: example.name,
 *     virtualNetworkName: exampleVirtualNetwork.name,
 *     addressPrefixes: ["10.0.2.0/24"],
 * });
 * const exampleManagedInstance = new azure.mssql.ManagedInstance("example", {
 *     name: "managedsqlinstance",
 *     resourceGroupName: example.name,
 *     location: example.location,
 *     licenseType: "BasePrice",
 *     skuName: "GP_Gen5",
 *     storageSizeInGb: 32,
 *     subnetId: exampleSubnet.id,
 *     vcores: 4,
 *     administratorLogin: "msadministrator",
 *     administratorLoginPassword: "thisIsDog11",
 * });
 * const exampleManagedDatabase = new azure.mssql.ManagedDatabase("example", {
 *     name: "example",
 *     managedInstanceId: exampleManagedInstance.id,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example",
 *     location="West Europe")
 * example_virtual_network = azure.network.VirtualNetwork("example",
 *     name="example",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     address_spaces=["10.0.0.0/16"])
 * example_subnet = azure.network.Subnet("example",
 *     name="example",
 *     resource_group_name=example.name,
 *     virtual_network_name=example_virtual_network.name,
 *     address_prefixes=["10.0.2.0/24"])
 * example_managed_instance = azure.mssql.ManagedInstance("example",
 *     name="managedsqlinstance",
 *     resource_group_name=example.name,
 *     location=example.location,
 *     license_type="BasePrice",
 *     sku_name="GP_Gen5",
 *     storage_size_in_gb=32,
 *     subnet_id=example_subnet.id,
 *     vcores=4,
 *     administrator_login="msadministrator",
 *     administrator_login_password="thisIsDog11")
 * example_managed_database = azure.mssql.ManagedDatabase("example",
 *     name="example",
 *     managed_instance_id=example_managed_instance.id)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "example",
 *         Location = "West Europe",
 *     });
 *     var exampleVirtualNetwork = new Azure.Network.VirtualNetwork("example", new()
 *     {
 *         Name = "example",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         AddressSpaces = new[]
 *         {
 *             "10.0.0.0/16",
 *         },
 *     });
 *     var exampleSubnet = new Azure.Network.Subnet("example", new()
 *     {
 *         Name = "example",
 *         ResourceGroupName = example.Name,
 *         VirtualNetworkName = exampleVirtualNetwork.Name,
 *         AddressPrefixes = new[]
 *         {
 *             "10.0.2.0/24",
 *         },
 *     });
 *     var exampleManagedInstance = new Azure.MSSql.ManagedInstance("example", new()
 *     {
 *         Name = "managedsqlinstance",
 *         ResourceGroupName = example.Name,
 *         Location = example.Location,
 *         LicenseType = "BasePrice",
 *         SkuName = "GP_Gen5",
 *         StorageSizeInGb = 32,
 *         SubnetId = exampleSubnet.Id,
 *         Vcores = 4,
 *         AdministratorLogin = "msadministrator",
 *         AdministratorLoginPassword = "thisIsDog11",
 *     });
 *     var exampleManagedDatabase = new Azure.MSSql.ManagedDatabase("example", new()
 *     {
 *         Name = "example",
 *         ManagedInstanceId = exampleManagedInstance.Id,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/mssql"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/network"
 * 	"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"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleVirtualNetwork, err := network.NewVirtualNetwork(ctx, "example", &network.VirtualNetworkArgs{
 * 			Name:              pulumi.String("example"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 			AddressSpaces: pulumi.StringArray{
 * 				pulumi.String("10.0.0.0/16"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleSubnet, err := network.NewSubnet(ctx, "example", &network.SubnetArgs{
 * 			Name:               pulumi.String("example"),
 * 			ResourceGroupName:  example.Name,
 * 			VirtualNetworkName: exampleVirtualNetwork.Name,
 * 			AddressPrefixes: pulumi.StringArray{
 * 				pulumi.String("10.0.2.0/24"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleManagedInstance, err := mssql.NewManagedInstance(ctx, "example", &mssql.ManagedInstanceArgs{
 * 			Name:                       pulumi.String("managedsqlinstance"),
 * 			ResourceGroupName:          example.Name,
 * 			Location:                   example.Location,
 * 			LicenseType:                pulumi.String("BasePrice"),
 * 			SkuName:                    pulumi.String("GP_Gen5"),
 * 			StorageSizeInGb:            pulumi.Int(32),
 * 			SubnetId:                   exampleSubnet.ID(),
 * 			Vcores:                     pulumi.Int(4),
 * 			AdministratorLogin:         pulumi.String("msadministrator"),
 * 			AdministratorLoginPassword: pulumi.String("thisIsDog11"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = mssql.NewManagedDatabase(ctx, "example", &mssql.ManagedDatabaseArgs{
 * 			Name:              pulumi.String("example"),
 * 			ManagedInstanceId: exampleManagedInstance.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.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.network.VirtualNetwork;
 * import com.pulumi.azure.network.VirtualNetworkArgs;
 * import com.pulumi.azure.network.Subnet;
 * import com.pulumi.azure.network.SubnetArgs;
 * import com.pulumi.azure.mssql.ManagedInstance;
 * import com.pulumi.azure.mssql.ManagedInstanceArgs;
 * import com.pulumi.azure.mssql.ManagedDatabase;
 * import com.pulumi.azure.mssql.ManagedDatabaseArgs;
 * 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")
 *             .location("West Europe")
 *             .build());
 *         var exampleVirtualNetwork = new VirtualNetwork("exampleVirtualNetwork", VirtualNetworkArgs.builder()
 *             .name("example")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .addressSpaces("10.0.0.0/16")
 *             .build());
 *         var exampleSubnet = new Subnet("exampleSubnet", SubnetArgs.builder()
 *             .name("example")
 *             .resourceGroupName(example.name())
 *             .virtualNetworkName(exampleVirtualNetwork.name())
 *             .addressPrefixes("10.0.2.0/24")
 *             .build());
 *         var exampleManagedInstance = new ManagedInstance("exampleManagedInstance", ManagedInstanceArgs.builder()
 *             .name("managedsqlinstance")
 *             .resourceGroupName(example.name())
 *             .location(example.location())
 *             .licenseType("BasePrice")
 *             .skuName("GP_Gen5")
 *             .storageSizeInGb(32)
 *             .subnetId(exampleSubnet.id())
 *             .vcores(4)
 *             .administratorLogin("msadministrator")
 *             .administratorLoginPassword("thisIsDog11")
 *             .build());
 *         var exampleManagedDatabase = new ManagedDatabase("exampleManagedDatabase", ManagedDatabaseArgs.builder()
 *             .name("example")
 *             .managedInstanceId(exampleManagedInstance.id())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example
 *       location: West Europe
 *   exampleVirtualNetwork:
 *     type: azure:network:VirtualNetwork
 *     name: example
 *     properties:
 *       name: example
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       addressSpaces:
 *         - 10.0.0.0/16
 *   exampleSubnet:
 *     type: azure:network:Subnet
 *     name: example
 *     properties:
 *       name: example
 *       resourceGroupName: ${example.name}
 *       virtualNetworkName: ${exampleVirtualNetwork.name}
 *       addressPrefixes:
 *         - 10.0.2.0/24
 *   exampleManagedInstance:
 *     type: azure:mssql:ManagedInstance
 *     name: example
 *     properties:
 *       name: managedsqlinstance
 *       resourceGroupName: ${example.name}
 *       location: ${example.location}
 *       licenseType: BasePrice
 *       skuName: GP_Gen5
 *       storageSizeInGb: 32
 *       subnetId: ${exampleSubnet.id}
 *       vcores: 4
 *       administratorLogin: msadministrator
 *       administratorLoginPassword: thisIsDog11
 *   exampleManagedDatabase:
 *     type: azure:mssql:ManagedDatabase
 *     name: example
 *     properties:
 *       name: example
 *       managedInstanceId: ${exampleManagedInstance.id}
 * ```
 * 
 * ## Import
 * SQL Managed Databases can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:mssql/managedDatabase:ManagedDatabase example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.Sql/managedInstances/myserver/databases/mydatabase
 * ```
 */
public class ManagedDatabase internal constructor(
    override val javaResource: com.pulumi.azure.mssql.ManagedDatabase,
) : KotlinCustomResource(javaResource, ManagedDatabaseMapper) {
    /**
     * A `long_term_retention_policy` block as defined below.
     */
    public val longTermRetentionPolicy: Output
        get() = javaResource.longTermRetentionPolicy().applyValue({ args0 ->
            args0.let({ args0 ->
                managedDatabaseLongTermRetentionPolicyToKotlin(args0)
            })
        })

    /**
     * The ID of the Azure SQL Managed Instance on which to create this Managed Database. Changing this forces a new resource to be created.
     */
    public val managedInstanceId: Output
        get() = javaResource.managedInstanceId().applyValue({ args0 -> args0 })

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

    /**
     * A `point_in_time_restore` block as defined below. Changing this forces a new resource to be created.
     */
    public val pointInTimeRestore: Output?
        get() = javaResource.pointInTimeRestore().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> managedDatabasePointInTimeRestoreToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * The backup retention period in days. This is how many days Point-in-Time Restore will be supported.
     */
    public val shortTermRetentionDays: Output?
        get() = javaResource.shortTermRetentionDays().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })
}

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

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy