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

com.pulumi.azure.mysql.kotlin.Server.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.mysql.kotlin

import com.pulumi.azure.mysql.kotlin.outputs.ServerIdentity
import com.pulumi.azure.mysql.kotlin.outputs.ServerThreatDetectionPolicy
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.mysql.kotlin.outputs.ServerIdentity.Companion.toKotlin as serverIdentityToKotlin
import com.pulumi.azure.mysql.kotlin.outputs.ServerThreatDetectionPolicy.Companion.toKotlin as serverThreatDetectionPolicyToKotlin

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

    public var args: ServerArgs = ServerArgs()

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

/**
 * Manages a MySQL Server.
 * > **Note:** Azure Database for MySQL Single Server and its sub resources are scheduled for retirement by 2024-09-16 and will migrate to using Azure Database for MySQL Flexible Server: https://go.microsoft.com/fwlink/?linkid=2216041. The `azure.mysql.Server` resource is deprecated and will be removed in v4.0 of the AzureRM Provider. Please use the `azure.mysql.FlexibleServer` resource instead.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const exampleServer = new azure.mysql.Server("example", {
 *     name: "example-mysqlserver",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     administratorLogin: "mysqladminun",
 *     administratorLoginPassword: "H@Sh1CoR3!",
 *     skuName: "B_Gen5_2",
 *     storageMb: 5120,
 *     version: "5.7",
 *     autoGrowEnabled: true,
 *     backupRetentionDays: 7,
 *     geoRedundantBackupEnabled: false,
 *     infrastructureEncryptionEnabled: false,
 *     publicNetworkAccessEnabled: true,
 *     sslEnforcementEnabled: true,
 *     sslMinimalTlsVersionEnforced: "TLS1_2",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example_server = azure.mysql.Server("example",
 *     name="example-mysqlserver",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     administrator_login="mysqladminun",
 *     administrator_login_password="H@Sh1CoR3!",
 *     sku_name="B_Gen5_2",
 *     storage_mb=5120,
 *     version="5.7",
 *     auto_grow_enabled=True,
 *     backup_retention_days=7,
 *     geo_redundant_backup_enabled=False,
 *     infrastructure_encryption_enabled=False,
 *     public_network_access_enabled=True,
 *     ssl_enforcement_enabled=True,
 *     ssl_minimal_tls_version_enforced="TLS1_2")
 * ```
 * ```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-resources",
 *         Location = "West Europe",
 *     });
 *     var exampleServer = new Azure.MySql.Server("example", new()
 *     {
 *         Name = "example-mysqlserver",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         AdministratorLogin = "mysqladminun",
 *         AdministratorLoginPassword = "H@Sh1CoR3!",
 *         SkuName = "B_Gen5_2",
 *         StorageMb = 5120,
 *         Version = "5.7",
 *         AutoGrowEnabled = true,
 *         BackupRetentionDays = 7,
 *         GeoRedundantBackupEnabled = false,
 *         InfrastructureEncryptionEnabled = false,
 *         PublicNetworkAccessEnabled = true,
 *         SslEnforcementEnabled = true,
 *         SslMinimalTlsVersionEnforced = "TLS1_2",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/mysql"
 * 	"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
 * 		}
 * 		_, err = mysql.NewServer(ctx, "example", &mysql.ServerArgs{
 * 			Name:                            pulumi.String("example-mysqlserver"),
 * 			Location:                        example.Location,
 * 			ResourceGroupName:               example.Name,
 * 			AdministratorLogin:              pulumi.String("mysqladminun"),
 * 			AdministratorLoginPassword:      pulumi.String("H@Sh1CoR3!"),
 * 			SkuName:                         pulumi.String("B_Gen5_2"),
 * 			StorageMb:                       pulumi.Int(5120),
 * 			Version:                         pulumi.String("5.7"),
 * 			AutoGrowEnabled:                 pulumi.Bool(true),
 * 			BackupRetentionDays:             pulumi.Int(7),
 * 			GeoRedundantBackupEnabled:       pulumi.Bool(false),
 * 			InfrastructureEncryptionEnabled: pulumi.Bool(false),
 * 			PublicNetworkAccessEnabled:      pulumi.Bool(true),
 * 			SslEnforcementEnabled:           pulumi.Bool(true),
 * 			SslMinimalTlsVersionEnforced:    pulumi.String("TLS1_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.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.mysql.Server;
 * import com.pulumi.azure.mysql.ServerArgs;
 * 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 exampleServer = new Server("exampleServer", ServerArgs.builder()
 *             .name("example-mysqlserver")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .administratorLogin("mysqladminun")
 *             .administratorLoginPassword("H@Sh1CoR3!")
 *             .skuName("B_Gen5_2")
 *             .storageMb(5120)
 *             .version("5.7")
 *             .autoGrowEnabled(true)
 *             .backupRetentionDays(7)
 *             .geoRedundantBackupEnabled(false)
 *             .infrastructureEncryptionEnabled(false)
 *             .publicNetworkAccessEnabled(true)
 *             .sslEnforcementEnabled(true)
 *             .sslMinimalTlsVersionEnforced("TLS1_2")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleServer:
 *     type: azure:mysql:Server
 *     name: example
 *     properties:
 *       name: example-mysqlserver
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       administratorLogin: mysqladminun
 *       administratorLoginPassword: H@Sh1CoR3!
 *       skuName: B_Gen5_2
 *       storageMb: 5120
 *       version: '5.7'
 *       autoGrowEnabled: true
 *       backupRetentionDays: 7
 *       geoRedundantBackupEnabled: false
 *       infrastructureEncryptionEnabled: false
 *       publicNetworkAccessEnabled: true
 *       sslEnforcementEnabled: true
 *       sslMinimalTlsVersionEnforced: TLS1_2
 * ```
 * 
 * ## Import
 * MySQL Server's can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:mysql/server:Server server1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.DBforMySQL/servers/server1
 * ```
 */
public class Server internal constructor(
    override val javaResource: com.pulumi.azure.mysql.Server,
) : KotlinCustomResource(javaResource, ServerMapper) {
    /**
     * The Administrator login for the MySQL Server. Required when `create_mode` is `Default`. Changing this forces a new resource to be created.
     */
    public val administratorLogin: Output
        get() = javaResource.administratorLogin().applyValue({ args0 -> args0 })

    /**
     * The Password associated with the `administrator_login` for the MySQL Server. Required when `create_mode` is `Default`.
     */
    public val administratorLoginPassword: Output?
        get() = javaResource.administratorLoginPassword().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Enable/Disable auto-growing of the storage. Storage auto-grow prevents your server from running out of storage and becoming read-only. If storage auto grow is enabled, the storage automatically grows without impacting the workload. Defaults to `true`.
     */
    public val autoGrowEnabled: Output?
        get() = javaResource.autoGrowEnabled().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Backup retention days for the server, supported values are between `7` and `35` days.
     */
    public val backupRetentionDays: Output
        get() = javaResource.backupRetentionDays().applyValue({ args0 -> args0 })

    /**
     * The creation mode. Can be used to restore or replicate existing servers. Possible values are `Default`, `Replica`, `GeoRestore`, and `PointInTimeRestore`. Defaults to `Default`.
     */
    public val createMode: Output?
        get() = javaResource.createMode().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * For creation modes other than `Default`, the source server ID to use.
     */
    public val creationSourceServerId: Output?
        get() = javaResource.creationSourceServerId().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The FQDN of the MySQL Server.
     */
    public val fqdn: Output
        get() = javaResource.fqdn().applyValue({ args0 -> args0 })

    /**
     * Turn Geo-redundant server backups on/off. This allows you to choose between locally redundant or geo-redundant backup storage in the General Purpose and Memory Optimized tiers. When the backups are stored in geo-redundant backup storage, they are not only stored within the region in which your server is hosted, but are also replicated to a paired data center. This provides better protection and ability to restore your server in a different region in the event of a disaster. This is not supported for the Basic tier.
     */
    public val geoRedundantBackupEnabled: Output
        get() = javaResource.geoRedundantBackupEnabled().applyValue({ args0 -> args0 })

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

    /**
     * Whether or not infrastructure is encrypted for this server. Changing this forces a new resource to be created.
     */
    public val infrastructureEncryptionEnabled: Output?
        get() = javaResource.infrastructureEncryptionEnabled().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 MySQL Server. Changing this forces a new resource to be created. This needs to be globally unique within Azure.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * Whether or not public network access is allowed for this server. Defaults to `true`.
     */
    public val publicNetworkAccessEnabled: Output?
        get() = javaResource.publicNetworkAccessEnabled().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

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

    /**
     * When `create_mode` is `PointInTimeRestore`, specifies the point in time to restore from `creation_source_server_id`. It should be provided in [RFC3339](https://www.rfc-editor.org/rfc/rfc3339) format, e.g. `2013-11-08T22:00:40Z`.
     */
    public val restorePointInTime: Output?
        get() = javaResource.restorePointInTime().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Specifies the SKU Name for this MySQL Server. The name of the SKU, follows the `tier` + `family` + `cores` pattern (e.g. `B_Gen4_1`, `GP_Gen5_8`). For more information see the [product documentation](https://docs.microsoft.com/azure/mysql/concepts-pricing-tiers). Possible values are `B_Gen4_1`, `B_Gen4_2`, `B_Gen5_1`, `B_Gen5_2`, `GP_Gen4_2`, `GP_Gen4_4`, `GP_Gen4_8`, `GP_Gen4_16`, `GP_Gen4_32`, `GP_Gen5_2`, `GP_Gen5_4`, `GP_Gen5_8`, `GP_Gen5_16`, `GP_Gen5_32`, `GP_Gen5_64`, `MO_Gen5_2`, `MO_Gen5_4`, `MO_Gen5_8`, `MO_Gen5_16` and `MO_Gen5_32`.
     */
    public val skuName: Output
        get() = javaResource.skuName().applyValue({ args0 -> args0 })

    /**
     * Specifies if SSL should be enforced on connections. Possible values are `true` and `false`.
     */
    public val sslEnforcementEnabled: Output
        get() = javaResource.sslEnforcementEnabled().applyValue({ args0 -> args0 })

    /**
     * The minimum TLS version to support on the sever. Possible values are `TLSEnforcementDisabled`, `TLS1_0`, `TLS1_1`, and `TLS1_2`. Defaults to `TLS1_2`.
     */
    public val sslMinimalTlsVersionEnforced: Output?
        get() = javaResource.sslMinimalTlsVersionEnforced().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Max storage allowed for a server. Possible values are between `5120` MB(5GB) and `1048576` MB(1TB) for the Basic SKU and between `5120` MB(5GB) and `16777216` MB(16TB) for General Purpose/Memory Optimized SKUs. For more information see the [product documentation](https://docs.microsoft.com/azure/mysql/concepts-pricing-tiers).
     */
    public val storageMb: Output
        get() = javaResource.storageMb().applyValue({ args0 -> args0 })

    /**
     * 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)
        })

    /**
     * Threat detection policy configuration, known in the API as Server Security Alerts Policy. The `threat_detection_policy` block supports fields documented below.
     */
    public val threatDetectionPolicy: Output?
        get() = javaResource.threatDetectionPolicy().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> serverThreatDetectionPolicyToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * Specifies the version of MySQL to use. Valid values are `5.7`, or `8.0`. Changing this forces a new resource to be created.
     */
    public val version: Output
        get() = javaResource.version().applyValue({ args0 -> args0 })
}

public object ServerMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.mysql.Server::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy