![JAR search and dependency download from the Maven repository](/logo.png)
com.pulumi.azure.sql.kotlin.Database.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-azure-kotlin Show documentation
Show all versions of pulumi-azure-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.azure.sql.kotlin
import com.pulumi.azure.sql.kotlin.outputs.DatabaseImport
import com.pulumi.azure.sql.kotlin.outputs.DatabaseThreatDetectionPolicy
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.Map
import com.pulumi.azure.sql.kotlin.outputs.DatabaseImport.Companion.toKotlin as databaseImportToKotlin
import com.pulumi.azure.sql.kotlin.outputs.DatabaseThreatDetectionPolicy.Companion.toKotlin as databaseThreatDetectionPolicyToKotlin
/**
* Builder for [Database].
*/
@PulumiTagMarker
public class DatabaseResourceBuilder internal constructor() {
public var name: String? = null
public var args: DatabaseArgs = DatabaseArgs()
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 DatabaseArgsBuilder.() -> Unit) {
val builder = DatabaseArgsBuilder()
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(): Database {
val builtJavaResource = com.pulumi.azure.sql.Database(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return Database(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-resources",
* location: "West Europe",
* });
* const exampleSqlServer = new azure.sql.SqlServer("example", {
* name: "myexamplesqlserver",
* resourceGroupName: example.name,
* location: example.location,
* version: "12.0",
* administratorLogin: "4dm1n157r470r",
* administratorLoginPassword: "4-v3ry-53cr37-p455w0rd",
* tags: {
* environment: "production",
* },
* });
* const exampleAccount = new azure.storage.Account("example", {
* name: "examplesa",
* resourceGroupName: example.name,
* location: example.location,
* accountTier: "Standard",
* accountReplicationType: "LRS",
* });
* const exampleDatabase = new azure.sql.Database("example", {
* name: "myexamplesqldatabase",
* resourceGroupName: example.name,
* location: example.location,
* serverName: exampleSqlServer.name,
* tags: {
* environment: "production",
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_azure as azure
* example = azure.core.ResourceGroup("example",
* name="example-resources",
* location="West Europe")
* example_sql_server = azure.sql.SqlServer("example",
* name="myexamplesqlserver",
* resource_group_name=example.name,
* location=example.location,
* version="12.0",
* administrator_login="4dm1n157r470r",
* administrator_login_password="4-v3ry-53cr37-p455w0rd",
* tags={
* "environment": "production",
* })
* example_account = azure.storage.Account("example",
* name="examplesa",
* resource_group_name=example.name,
* location=example.location,
* account_tier="Standard",
* account_replication_type="LRS")
* example_database = azure.sql.Database("example",
* name="myexamplesqldatabase",
* resource_group_name=example.name,
* location=example.location,
* server_name=example_sql_server.name,
* tags={
* "environment": "production",
* })
* ```
* ```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 exampleSqlServer = new Azure.Sql.SqlServer("example", new()
* {
* Name = "myexamplesqlserver",
* ResourceGroupName = example.Name,
* Location = example.Location,
* Version = "12.0",
* AdministratorLogin = "4dm1n157r470r",
* AdministratorLoginPassword = "4-v3ry-53cr37-p455w0rd",
* Tags =
* {
* { "environment", "production" },
* },
* });
* var exampleAccount = new Azure.Storage.Account("example", new()
* {
* Name = "examplesa",
* ResourceGroupName = example.Name,
* Location = example.Location,
* AccountTier = "Standard",
* AccountReplicationType = "LRS",
* });
* var exampleDatabase = new Azure.Sql.Database("example", new()
* {
* Name = "myexamplesqldatabase",
* ResourceGroupName = example.Name,
* Location = example.Location,
* ServerName = exampleSqlServer.Name,
* Tags =
* {
* { "environment", "production" },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
* "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/sql"
* "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/storage"
* "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
* }
* exampleSqlServer, err := sql.NewSqlServer(ctx, "example", &sql.SqlServerArgs{
* Name: pulumi.String("myexamplesqlserver"),
* ResourceGroupName: example.Name,
* Location: example.Location,
* Version: pulumi.String("12.0"),
* AdministratorLogin: pulumi.String("4dm1n157r470r"),
* AdministratorLoginPassword: pulumi.String("4-v3ry-53cr37-p455w0rd"),
* Tags: pulumi.StringMap{
* "environment": pulumi.String("production"),
* },
* })
* if err != nil {
* return err
* }
* _, err = storage.NewAccount(ctx, "example", &storage.AccountArgs{
* Name: pulumi.String("examplesa"),
* ResourceGroupName: example.Name,
* Location: example.Location,
* AccountTier: pulumi.String("Standard"),
* AccountReplicationType: pulumi.String("LRS"),
* })
* if err != nil {
* return err
* }
* _, err = sql.NewDatabase(ctx, "example", &sql.DatabaseArgs{
* Name: pulumi.String("myexamplesqldatabase"),
* ResourceGroupName: example.Name,
* Location: example.Location,
* ServerName: exampleSqlServer.Name,
* Tags: pulumi.StringMap{
* "environment": pulumi.String("production"),
* },
* })
* 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.sql.SqlServer;
* import com.pulumi.azure.sql.SqlServerArgs;
* import com.pulumi.azure.storage.Account;
* import com.pulumi.azure.storage.AccountArgs;
* import com.pulumi.azure.sql.Database;
* import com.pulumi.azure.sql.DatabaseArgs;
* 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 exampleSqlServer = new SqlServer("exampleSqlServer", SqlServerArgs.builder()
* .name("myexamplesqlserver")
* .resourceGroupName(example.name())
* .location(example.location())
* .version("12.0")
* .administratorLogin("4dm1n157r470r")
* .administratorLoginPassword("4-v3ry-53cr37-p455w0rd")
* .tags(Map.of("environment", "production"))
* .build());
* var exampleAccount = new Account("exampleAccount", AccountArgs.builder()
* .name("examplesa")
* .resourceGroupName(example.name())
* .location(example.location())
* .accountTier("Standard")
* .accountReplicationType("LRS")
* .build());
* var exampleDatabase = new Database("exampleDatabase", DatabaseArgs.builder()
* .name("myexamplesqldatabase")
* .resourceGroupName(example.name())
* .location(example.location())
* .serverName(exampleSqlServer.name())
* .tags(Map.of("environment", "production"))
* .build());
* }
* }
* ```
* ```yaml
* resources:
* example:
* type: azure:core:ResourceGroup
* properties:
* name: example-resources
* location: West Europe
* exampleSqlServer:
* type: azure:sql:SqlServer
* name: example
* properties:
* name: myexamplesqlserver
* resourceGroupName: ${example.name}
* location: ${example.location}
* version: '12.0'
* administratorLogin: 4dm1n157r470r
* administratorLoginPassword: 4-v3ry-53cr37-p455w0rd
* tags:
* environment: production
* exampleAccount:
* type: azure:storage:Account
* name: example
* properties:
* name: examplesa
* resourceGroupName: ${example.name}
* location: ${example.location}
* accountTier: Standard
* accountReplicationType: LRS
* exampleDatabase:
* type: azure:sql:Database
* name: example
* properties:
* name: myexamplesqldatabase
* resourceGroupName: ${example.name}
* location: ${example.location}
* serverName: ${exampleSqlServer.name}
* tags:
* environment: production
* ```
*
* ## Import
* SQL Databases can be imported using the `resource id`, e.g.
* ```sh
* $ pulumi import azure:sql/database:Database database1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.Sql/servers/myserver/databases/database1
* ```
*/
public class Database internal constructor(
override val javaResource: com.pulumi.azure.sql.Database,
) : KotlinCustomResource(javaResource, DatabaseMapper) {
/**
* The name of the collation. Applies only if `create_mode` is `Default`. Azure default is `SQL_LATIN1_GENERAL_CP1_CI_AS`. Changing this forces a new resource to be created.
*/
public val collation: Output
get() = javaResource.collation().applyValue({ args0 -> args0 })
/**
* Specifies how to create the database. Valid values are: `Default`, `Copy`, `OnlineSecondary`, `NonReadableSecondary`, `PointInTimeRestore`, `Recovery`, `Restore` or `RestoreLongTermRetentionBackup`. Must be `Default` to create a new database. Defaults to `Default`. Please see [Azure SQL Database REST API](https://docs.microsoft.com/rest/api/sql/databases/createorupdate#createmode)
*/
public val createMode: Output?
get() = javaResource.createMode().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* The creation date of the SQL Database.
*/
public val creationDate: Output
get() = javaResource.creationDate().applyValue({ args0 -> args0 })
/**
* The default secondary location of the SQL Database.
*/
public val defaultSecondaryLocation: Output
get() = javaResource.defaultSecondaryLocation().applyValue({ args0 -> args0 })
/**
* The edition of the database to be created. Applies only if `create_mode` is `Default`. Valid values are: `Basic`, `Standard`, `Premium`, `DataWarehouse`, `Business`, `BusinessCritical`, `Free`, `GeneralPurpose`, `Hyperscale`, `Premium`, `PremiumRS`, `Standard`, `Stretch`, `System`, `System2`, or `Web`. Please see [Azure SQL database models](https://docs.microsoft.com/azure/azure-sql/database/purchasing-models?view=azuresql).
*/
public val edition: Output
get() = javaResource.edition().applyValue({ args0 -> args0 })
/**
* The name of the elastic database pool.
*/
public val elasticPoolName: Output
get() = javaResource.elasticPoolName().applyValue({ args0 -> args0 })
public val encryption: Output
get() = javaResource.encryption().applyValue({ args0 -> args0 })
/**
* A `import` block as documented below. `create_mode` must be set to `Default`.
*/
public val `import`: Output?
get() = javaResource.import_().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
databaseImportToKotlin(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 })
/**
* The maximum size that the database can grow to. Applies only if `create_mode` is `Default`. Please see [Azure SQL database models](https://docs.microsoft.com/azure/azure-sql/database/purchasing-models?view=azuresql).
*/
public val maxSizeBytes: Output
get() = javaResource.maxSizeBytes().applyValue({ args0 -> args0 })
public val maxSizeGb: Output
get() = javaResource.maxSizeGb().applyValue({ args0 -> args0 })
/**
* The name of the database. Changing this forces a new resource to be created.
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* Read-only connections will be redirected to a high-available replica. Please see [Use read-only replicas to load-balance read-only query workloads](https://docs.microsoft.com/azure/sql-database/sql-database-read-scale-out).
*/
public val readScale: Output?
get() = javaResource.readScale().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* A GUID/UUID corresponding to a configured Service Level Objective for the Azure SQL database which can be used to configure a performance level.
* .
*/
public val requestedServiceObjectiveId: Output
get() = javaResource.requestedServiceObjectiveId().applyValue({ args0 -> args0 })
/**
* The service objective name for the database. Valid values depend on edition and location and may include `S0`, `S1`, `S2`, `S3`, `P1`, `P2`, `P4`, `P6`, `P11` and `ElasticPool`. You can list the available names with the CLI: `shell az sql db list-editions -l westus -o table`. For further information please see [Azure CLI - az sql db](https://docs.microsoft.com/cli/azure/sql/db?view=azure-cli-latest#az-sql-db-list-editions).
*/
public val requestedServiceObjectiveName: Output
get() = javaResource.requestedServiceObjectiveName().applyValue({ args0 -> args0 })
/**
* The name of the resource group in which to create the database. This must be the same as Database Server resource group currently. Changing this forces a new resource to be created.
*/
public val resourceGroupName: Output
get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })
/**
* The point in time for the restore. Only applies if `create_mode` is `PointInTimeRestore`, 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 })
/**
* The name of the SQL Server on which to create the database. Changing this forces a new resource to be created.
*/
public val serverName: Output
get() = javaResource.serverName().applyValue({ args0 -> args0 })
/**
* The deletion date time of the source database. Only applies to deleted databases where `create_mode` is `PointInTimeRestore`.
*/
public val sourceDatabaseDeletionDate: Output
get() = javaResource.sourceDatabaseDeletionDate().applyValue({ args0 -> args0 })
/**
* The URI of the source database if `create_mode` value is not `Default`.
*/
public val sourceDatabaseId: Output
get() = javaResource.sourceDatabaseId().applyValue({ args0 -> args0 })
/**
* A mapping of tags to assign to the resource.
*/
public val tags: Output
© 2015 - 2025 Weber Informatics LLC | Privacy Policy