Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.pulumi.gcp.sql.kotlin.DatabaseInstance.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.sql.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.sql.kotlin.outputs.DatabaseInstanceClone
import com.pulumi.gcp.sql.kotlin.outputs.DatabaseInstanceIpAddress
import com.pulumi.gcp.sql.kotlin.outputs.DatabaseInstanceReplicaConfiguration
import com.pulumi.gcp.sql.kotlin.outputs.DatabaseInstanceRestoreBackupContext
import com.pulumi.gcp.sql.kotlin.outputs.DatabaseInstanceServerCaCert
import com.pulumi.gcp.sql.kotlin.outputs.DatabaseInstanceSettings
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.List
import com.pulumi.gcp.sql.kotlin.outputs.DatabaseInstanceClone.Companion.toKotlin as databaseInstanceCloneToKotlin
import com.pulumi.gcp.sql.kotlin.outputs.DatabaseInstanceIpAddress.Companion.toKotlin as databaseInstanceIpAddressToKotlin
import com.pulumi.gcp.sql.kotlin.outputs.DatabaseInstanceReplicaConfiguration.Companion.toKotlin as databaseInstanceReplicaConfigurationToKotlin
import com.pulumi.gcp.sql.kotlin.outputs.DatabaseInstanceRestoreBackupContext.Companion.toKotlin as databaseInstanceRestoreBackupContextToKotlin
import com.pulumi.gcp.sql.kotlin.outputs.DatabaseInstanceServerCaCert.Companion.toKotlin as databaseInstanceServerCaCertToKotlin
import com.pulumi.gcp.sql.kotlin.outputs.DatabaseInstanceSettings.Companion.toKotlin as databaseInstanceSettingsToKotlin
/**
* Builder for [DatabaseInstance].
*/
@PulumiTagMarker
public class DatabaseInstanceResourceBuilder internal constructor() {
public var name: String? = null
public var args: DatabaseInstanceArgs = DatabaseInstanceArgs()
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 DatabaseInstanceArgsBuilder.() -> Unit) {
val builder = DatabaseInstanceArgsBuilder()
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(): DatabaseInstance {
val builtJavaResource = com.pulumi.gcp.sql.DatabaseInstance(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return DatabaseInstance(builtJavaResource)
}
}
/**
* Creates a new Google SQL Database Instance. For more information, see the [official documentation](https://cloud.google.com/sql/),
* or the [JSON API](https://cloud.google.com/sql/docs/admin-api/v1beta4/instances).
* > **NOTE on `gcp.sql.DatabaseInstance`:** - Second-generation instances include a
* default 'root'@'%' user with no password. This user will be deleted by the provider on
* instance creation. You should use `gcp.sql.User` to define a custom user with
* a restricted host and strong password.
* > **Note**: On newer versions of the provider, you must explicitly set `deletion_protection=false`
* (and run `pulumi update` to write the field to state) in order to destroy an instance.
* It is recommended to not set this field (or set it to true) until you're ready to destroy the instance and its databases.
* ## Example Usage
* ### SQL Second Generation Instance
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const main = new gcp.sql.DatabaseInstance("main", {
* name: "main-instance",
* databaseVersion: "POSTGRES_15",
* region: "us-central1",
* settings: {
* tier: "db-f1-micro",
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* main = gcp.sql.DatabaseInstance("main",
* name="main-instance",
* database_version="POSTGRES_15",
* region="us-central1",
* settings={
* "tier": "db-f1-micro",
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var main = new Gcp.Sql.DatabaseInstance("main", new()
* {
* Name = "main-instance",
* DatabaseVersion = "POSTGRES_15",
* Region = "us-central1",
* Settings = new Gcp.Sql.Inputs.DatabaseInstanceSettingsArgs
* {
* Tier = "db-f1-micro",
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/sql"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := sql.NewDatabaseInstance(ctx, "main", &sql.DatabaseInstanceArgs{
* Name: pulumi.String("main-instance"),
* DatabaseVersion: pulumi.String("POSTGRES_15"),
* Region: pulumi.String("us-central1"),
* Settings: &sql.DatabaseInstanceSettingsArgs{
* Tier: pulumi.String("db-f1-micro"),
* },
* })
* 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.gcp.sql.DatabaseInstance;
* import com.pulumi.gcp.sql.DatabaseInstanceArgs;
* import com.pulumi.gcp.sql.inputs.DatabaseInstanceSettingsArgs;
* 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 main = new DatabaseInstance("main", DatabaseInstanceArgs.builder()
* .name("main-instance")
* .databaseVersion("POSTGRES_15")
* .region("us-central1")
* .settings(DatabaseInstanceSettingsArgs.builder()
* .tier("db-f1-micro")
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* main:
* type: gcp:sql:DatabaseInstance
* properties:
* name: main-instance
* databaseVersion: POSTGRES_15
* region: us-central1
* settings:
* tier: db-f1-micro
* ```
*
* ### Private IP Instance
* > **NOTE:** For private IP instance setup, note that the `gcp.sql.DatabaseInstance` does not actually interpolate values from `gcp.servicenetworking.Connection`. You must explicitly add a `depends_on`reference as shown below.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* import * as random from "@pulumi/random";
* const privateNetwork = new gcp.compute.Network("private_network", {name: "private-network"});
* const privateIpAddress = new gcp.compute.GlobalAddress("private_ip_address", {
* name: "private-ip-address",
* purpose: "VPC_PEERING",
* addressType: "INTERNAL",
* prefixLength: 16,
* network: privateNetwork.id,
* });
* const privateVpcConnection = new gcp.servicenetworking.Connection("private_vpc_connection", {
* network: privateNetwork.id,
* service: "servicenetworking.googleapis.com",
* reservedPeeringRanges: [privateIpAddress.name],
* });
* const dbNameSuffix = new random.RandomId("db_name_suffix", {byteLength: 4});
* const instance = new gcp.sql.DatabaseInstance("instance", {
* name: pulumi.interpolate`private-instance-${dbNameSuffix.hex}`,
* region: "us-central1",
* databaseVersion: "MYSQL_5_7",
* settings: {
* tier: "db-f1-micro",
* ipConfiguration: {
* ipv4Enabled: false,
* privateNetwork: privateNetwork.selfLink,
* enablePrivatePathForGoogleCloudServices: true,
* },
* },
* }, {
* dependsOn: [privateVpcConnection],
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* import pulumi_random as random
* private_network = gcp.compute.Network("private_network", name="private-network")
* private_ip_address = gcp.compute.GlobalAddress("private_ip_address",
* name="private-ip-address",
* purpose="VPC_PEERING",
* address_type="INTERNAL",
* prefix_length=16,
* network=private_network.id)
* private_vpc_connection = gcp.servicenetworking.Connection("private_vpc_connection",
* network=private_network.id,
* service="servicenetworking.googleapis.com",
* reserved_peering_ranges=[private_ip_address.name])
* db_name_suffix = random.RandomId("db_name_suffix", byte_length=4)
* instance = gcp.sql.DatabaseInstance("instance",
* name=db_name_suffix.hex.apply(lambda hex: f"private-instance-{hex}"),
* region="us-central1",
* database_version="MYSQL_5_7",
* settings={
* "tier": "db-f1-micro",
* "ip_configuration": {
* "ipv4_enabled": False,
* "private_network": private_network.self_link,
* "enable_private_path_for_google_cloud_services": True,
* },
* },
* opts = pulumi.ResourceOptions(depends_on=[private_vpc_connection]))
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* using Random = Pulumi.Random;
* return await Deployment.RunAsync(() =>
* {
* var privateNetwork = new Gcp.Compute.Network("private_network", new()
* {
* Name = "private-network",
* });
* var privateIpAddress = new Gcp.Compute.GlobalAddress("private_ip_address", new()
* {
* Name = "private-ip-address",
* Purpose = "VPC_PEERING",
* AddressType = "INTERNAL",
* PrefixLength = 16,
* Network = privateNetwork.Id,
* });
* var privateVpcConnection = new Gcp.ServiceNetworking.Connection("private_vpc_connection", new()
* {
* Network = privateNetwork.Id,
* Service = "servicenetworking.googleapis.com",
* ReservedPeeringRanges = new[]
* {
* privateIpAddress.Name,
* },
* });
* var dbNameSuffix = new Random.RandomId("db_name_suffix", new()
* {
* ByteLength = 4,
* });
* var instance = new Gcp.Sql.DatabaseInstance("instance", new()
* {
* Name = dbNameSuffix.Hex.Apply(hex => $"private-instance-{hex}"),
* Region = "us-central1",
* DatabaseVersion = "MYSQL_5_7",
* Settings = new Gcp.Sql.Inputs.DatabaseInstanceSettingsArgs
* {
* Tier = "db-f1-micro",
* IpConfiguration = new Gcp.Sql.Inputs.DatabaseInstanceSettingsIpConfigurationArgs
* {
* Ipv4Enabled = false,
* PrivateNetwork = privateNetwork.SelfLink,
* EnablePrivatePathForGoogleCloudServices = true,
* },
* },
* }, new CustomResourceOptions
* {
* DependsOn =
* {
* privateVpcConnection,
* },
* });
* });
* ```
* ```go
* package main
* import (
* "fmt"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/servicenetworking"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/sql"
* "github.com/pulumi/pulumi-random/sdk/v4/go/random"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* privateNetwork, err := compute.NewNetwork(ctx, "private_network", &compute.NetworkArgs{
* Name: pulumi.String("private-network"),
* })
* if err != nil {
* return err
* }
* privateIpAddress, err := compute.NewGlobalAddress(ctx, "private_ip_address", &compute.GlobalAddressArgs{
* Name: pulumi.String("private-ip-address"),
* Purpose: pulumi.String("VPC_PEERING"),
* AddressType: pulumi.String("INTERNAL"),
* PrefixLength: pulumi.Int(16),
* Network: privateNetwork.ID(),
* })
* if err != nil {
* return err
* }
* privateVpcConnection, err := servicenetworking.NewConnection(ctx, "private_vpc_connection", &servicenetworking.ConnectionArgs{
* Network: privateNetwork.ID(),
* Service: pulumi.String("servicenetworking.googleapis.com"),
* ReservedPeeringRanges: pulumi.StringArray{
* privateIpAddress.Name,
* },
* })
* if err != nil {
* return err
* }
* dbNameSuffix, err := random.NewRandomId(ctx, "db_name_suffix", &random.RandomIdArgs{
* ByteLength: pulumi.Int(4),
* })
* if err != nil {
* return err
* }
* _, err = sql.NewDatabaseInstance(ctx, "instance", &sql.DatabaseInstanceArgs{
* Name: dbNameSuffix.Hex.ApplyT(func(hex string) (string, error) {
* return fmt.Sprintf("private-instance-%v", hex), nil
* }).(pulumi.StringOutput),
* Region: pulumi.String("us-central1"),
* DatabaseVersion: pulumi.String("MYSQL_5_7"),
* Settings: &sql.DatabaseInstanceSettingsArgs{
* Tier: pulumi.String("db-f1-micro"),
* IpConfiguration: &sql.DatabaseInstanceSettingsIpConfigurationArgs{
* Ipv4Enabled: pulumi.Bool(false),
* PrivateNetwork: privateNetwork.SelfLink,
* EnablePrivatePathForGoogleCloudServices: pulumi.Bool(true),
* },
* },
* }, pulumi.DependsOn([]pulumi.Resource{
* privateVpcConnection,
* }))
* 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.gcp.compute.Network;
* import com.pulumi.gcp.compute.NetworkArgs;
* import com.pulumi.gcp.compute.GlobalAddress;
* import com.pulumi.gcp.compute.GlobalAddressArgs;
* import com.pulumi.gcp.servicenetworking.Connection;
* import com.pulumi.gcp.servicenetworking.ConnectionArgs;
* import com.pulumi.random.RandomId;
* import com.pulumi.random.RandomIdArgs;
* import com.pulumi.gcp.sql.DatabaseInstance;
* import com.pulumi.gcp.sql.DatabaseInstanceArgs;
* import com.pulumi.gcp.sql.inputs.DatabaseInstanceSettingsArgs;
* import com.pulumi.gcp.sql.inputs.DatabaseInstanceSettingsIpConfigurationArgs;
* import com.pulumi.resources.CustomResourceOptions;
* 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 privateNetwork = new Network("privateNetwork", NetworkArgs.builder()
* .name("private-network")
* .build());
* var privateIpAddress = new GlobalAddress("privateIpAddress", GlobalAddressArgs.builder()
* .name("private-ip-address")
* .purpose("VPC_PEERING")
* .addressType("INTERNAL")
* .prefixLength(16)
* .network(privateNetwork.id())
* .build());
* var privateVpcConnection = new Connection("privateVpcConnection", ConnectionArgs.builder()
* .network(privateNetwork.id())
* .service("servicenetworking.googleapis.com")
* .reservedPeeringRanges(privateIpAddress.name())
* .build());
* var dbNameSuffix = new RandomId("dbNameSuffix", RandomIdArgs.builder()
* .byteLength(4)
* .build());
* var instance = new DatabaseInstance("instance", DatabaseInstanceArgs.builder()
* .name(dbNameSuffix.hex().applyValue(hex -> String.format("private-instance-%s", hex)))
* .region("us-central1")
* .databaseVersion("MYSQL_5_7")
* .settings(DatabaseInstanceSettingsArgs.builder()
* .tier("db-f1-micro")
* .ipConfiguration(DatabaseInstanceSettingsIpConfigurationArgs.builder()
* .ipv4Enabled(false)
* .privateNetwork(privateNetwork.selfLink())
* .enablePrivatePathForGoogleCloudServices(true)
* .build())
* .build())
* .build(), CustomResourceOptions.builder()
* .dependsOn(privateVpcConnection)
* .build());
* }
* }
* ```
* ```yaml
* resources:
* privateNetwork:
* type: gcp:compute:Network
* name: private_network
* properties:
* name: private-network
* privateIpAddress:
* type: gcp:compute:GlobalAddress
* name: private_ip_address
* properties:
* name: private-ip-address
* purpose: VPC_PEERING
* addressType: INTERNAL
* prefixLength: 16
* network: ${privateNetwork.id}
* privateVpcConnection:
* type: gcp:servicenetworking:Connection
* name: private_vpc_connection
* properties:
* network: ${privateNetwork.id}
* service: servicenetworking.googleapis.com
* reservedPeeringRanges:
* - ${privateIpAddress.name}
* dbNameSuffix:
* type: random:RandomId
* name: db_name_suffix
* properties:
* byteLength: 4
* instance:
* type: gcp:sql:DatabaseInstance
* properties:
* name: private-instance-${dbNameSuffix.hex}
* region: us-central1
* databaseVersion: MYSQL_5_7
* settings:
* tier: db-f1-micro
* ipConfiguration:
* ipv4Enabled: false
* privateNetwork: ${privateNetwork.selfLink}
* enablePrivatePathForGoogleCloudServices: true
* options:
* dependson:
* - ${privateVpcConnection}
* ```
*
* ### ENTERPRISE_PLUS Instance with data_cache_config
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const main = new gcp.sql.DatabaseInstance("main", {
* name: "enterprise-plus-main-instance",
* databaseVersion: "MYSQL_8_0_31",
* settings: {
* tier: "db-perf-optimized-N-2",
* edition: "ENTERPRISE_PLUS",
* dataCacheConfig: {
* dataCacheEnabled: true,
* },
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* main = gcp.sql.DatabaseInstance("main",
* name="enterprise-plus-main-instance",
* database_version="MYSQL_8_0_31",
* settings={
* "tier": "db-perf-optimized-N-2",
* "edition": "ENTERPRISE_PLUS",
* "data_cache_config": {
* "data_cache_enabled": True,
* },
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var main = new Gcp.Sql.DatabaseInstance("main", new()
* {
* Name = "enterprise-plus-main-instance",
* DatabaseVersion = "MYSQL_8_0_31",
* Settings = new Gcp.Sql.Inputs.DatabaseInstanceSettingsArgs
* {
* Tier = "db-perf-optimized-N-2",
* Edition = "ENTERPRISE_PLUS",
* DataCacheConfig = new Gcp.Sql.Inputs.DatabaseInstanceSettingsDataCacheConfigArgs
* {
* DataCacheEnabled = true,
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/sql"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := sql.NewDatabaseInstance(ctx, "main", &sql.DatabaseInstanceArgs{
* Name: pulumi.String("enterprise-plus-main-instance"),
* DatabaseVersion: pulumi.String("MYSQL_8_0_31"),
* Settings: &sql.DatabaseInstanceSettingsArgs{
* Tier: pulumi.String("db-perf-optimized-N-2"),
* Edition: pulumi.String("ENTERPRISE_PLUS"),
* DataCacheConfig: &sql.DatabaseInstanceSettingsDataCacheConfigArgs{
* DataCacheEnabled: pulumi.Bool(true),
* },
* },
* })
* 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.gcp.sql.DatabaseInstance;
* import com.pulumi.gcp.sql.DatabaseInstanceArgs;
* import com.pulumi.gcp.sql.inputs.DatabaseInstanceSettingsArgs;
* import com.pulumi.gcp.sql.inputs.DatabaseInstanceSettingsDataCacheConfigArgs;
* 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 main = new DatabaseInstance("main", DatabaseInstanceArgs.builder()
* .name("enterprise-plus-main-instance")
* .databaseVersion("MYSQL_8_0_31")
* .settings(DatabaseInstanceSettingsArgs.builder()
* .tier("db-perf-optimized-N-2")
* .edition("ENTERPRISE_PLUS")
* .dataCacheConfig(DatabaseInstanceSettingsDataCacheConfigArgs.builder()
* .dataCacheEnabled(true)
* .build())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* main:
* type: gcp:sql:DatabaseInstance
* properties:
* name: enterprise-plus-main-instance
* databaseVersion: MYSQL_8_0_31
* settings:
* tier: db-perf-optimized-N-2
* edition: ENTERPRISE_PLUS
* dataCacheConfig:
* dataCacheEnabled: true
* ```
*
* ### Cloud SQL Instance with PSC connectivity
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const main = new gcp.sql.DatabaseInstance("main", {
* name: "psc-enabled-main-instance",
* databaseVersion: "MYSQL_8_0",
* settings: {
* tier: "db-f1-micro",
* ipConfiguration: {
* pscConfigs: [{
* pscEnabled: true,
* allowedConsumerProjects: ["allowed-consumer-project-name"],
* }],
* ipv4Enabled: false,
* },
* backupConfiguration: {
* enabled: true,
* binaryLogEnabled: true,
* },
* availabilityType: "REGIONAL",
* },
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* main = gcp.sql.DatabaseInstance("main",
* name="psc-enabled-main-instance",
* database_version="MYSQL_8_0",
* settings={
* "tier": "db-f1-micro",
* "ip_configuration": {
* "psc_configs": [{
* "psc_enabled": True,
* "allowed_consumer_projects": ["allowed-consumer-project-name"],
* }],
* "ipv4_enabled": False,
* },
* "backup_configuration": {
* "enabled": True,
* "binary_log_enabled": True,
* },
* "availability_type": "REGIONAL",
* })
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var main = new Gcp.Sql.DatabaseInstance("main", new()
* {
* Name = "psc-enabled-main-instance",
* DatabaseVersion = "MYSQL_8_0",
* Settings = new Gcp.Sql.Inputs.DatabaseInstanceSettingsArgs
* {
* Tier = "db-f1-micro",
* IpConfiguration = new Gcp.Sql.Inputs.DatabaseInstanceSettingsIpConfigurationArgs
* {
* PscConfigs = new[]
* {
* new Gcp.Sql.Inputs.DatabaseInstanceSettingsIpConfigurationPscConfigArgs
* {
* PscEnabled = true,
* AllowedConsumerProjects = new[]
* {
* "allowed-consumer-project-name",
* },
* },
* },
* Ipv4Enabled = false,
* },
* BackupConfiguration = new Gcp.Sql.Inputs.DatabaseInstanceSettingsBackupConfigurationArgs
* {
* Enabled = true,
* BinaryLogEnabled = true,
* },
* AvailabilityType = "REGIONAL",
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/sql"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := sql.NewDatabaseInstance(ctx, "main", &sql.DatabaseInstanceArgs{
* Name: pulumi.String("psc-enabled-main-instance"),
* DatabaseVersion: pulumi.String("MYSQL_8_0"),
* Settings: &sql.DatabaseInstanceSettingsArgs{
* Tier: pulumi.String("db-f1-micro"),
* IpConfiguration: &sql.DatabaseInstanceSettingsIpConfigurationArgs{
* PscConfigs: sql.DatabaseInstanceSettingsIpConfigurationPscConfigArray{
* &sql.DatabaseInstanceSettingsIpConfigurationPscConfigArgs{
* PscEnabled: pulumi.Bool(true),
* AllowedConsumerProjects: pulumi.StringArray{
* pulumi.String("allowed-consumer-project-name"),
* },
* },
* },
* Ipv4Enabled: pulumi.Bool(false),
* },
* BackupConfiguration: &sql.DatabaseInstanceSettingsBackupConfigurationArgs{
* Enabled: pulumi.Bool(true),
* BinaryLogEnabled: pulumi.Bool(true),
* },
* AvailabilityType: pulumi.String("REGIONAL"),
* },
* })
* 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.gcp.sql.DatabaseInstance;
* import com.pulumi.gcp.sql.DatabaseInstanceArgs;
* import com.pulumi.gcp.sql.inputs.DatabaseInstanceSettingsArgs;
* import com.pulumi.gcp.sql.inputs.DatabaseInstanceSettingsIpConfigurationArgs;
* import com.pulumi.gcp.sql.inputs.DatabaseInstanceSettingsBackupConfigurationArgs;
* 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 main = new DatabaseInstance("main", DatabaseInstanceArgs.builder()
* .name("psc-enabled-main-instance")
* .databaseVersion("MYSQL_8_0")
* .settings(DatabaseInstanceSettingsArgs.builder()
* .tier("db-f1-micro")
* .ipConfiguration(DatabaseInstanceSettingsIpConfigurationArgs.builder()
* .pscConfigs(DatabaseInstanceSettingsIpConfigurationPscConfigArgs.builder()
* .pscEnabled(true)
* .allowedConsumerProjects("allowed-consumer-project-name")
* .build())
* .ipv4Enabled(false)
* .build())
* .backupConfiguration(DatabaseInstanceSettingsBackupConfigurationArgs.builder()
* .enabled(true)
* .binaryLogEnabled(true)
* .build())
* .availabilityType("REGIONAL")
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* main:
* type: gcp:sql:DatabaseInstance
* properties:
* name: psc-enabled-main-instance
* databaseVersion: MYSQL_8_0
* settings:
* tier: db-f1-micro
* ipConfiguration:
* pscConfigs:
* - pscEnabled: true
* allowedConsumerProjects:
* - allowed-consumer-project-name
* ipv4Enabled: false
* backupConfiguration:
* enabled: true
* binaryLogEnabled: true
* availabilityType: REGIONAL
* ```
*
* ## Import
* Database instances can be imported using one of any of these accepted formats:
* * `projects/{{project}}/instances/{{name}}`
* * `{{project}}/{{name}}`
* * `{{name}}`
* When using the `pulumi import` command, Database instances can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:sql/databaseInstance:DatabaseInstance default projects/{{project}}/instances/{{name}}
* ```
* ```sh
* $ pulumi import gcp:sql/databaseInstance:DatabaseInstance default {{project}}/{{name}}
* ```
* ```sh
* $ pulumi import gcp:sql/databaseInstance:DatabaseInstance default {{name}}
* ```
* config and set on the server.
* When importing, double-check that your config has all the fields set that you expect- just seeing
* no diff isn't sufficient to know that your config could reproduce the imported resource.
*/
public class DatabaseInstance internal constructor(
override val javaResource: com.pulumi.gcp.sql.DatabaseInstance,
) : KotlinCustomResource(javaResource, DatabaseInstanceMapper) {
/**
* The list of all maintenance versions applicable on the instance.
*/
public val availableMaintenanceVersions: Output>
get() = javaResource.availableMaintenanceVersions().applyValue({ args0 ->
args0.map({ args0 ->
args0
})
})
/**
* The context needed to create this instance as a clone of another instance. When this field is set during
* resource creation, this provider will attempt to clone another instance as indicated in the context. The
* configuration is detailed below.
*/
public val clone: Output?
get() = javaResource.clone_().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
databaseInstanceCloneToKotlin(args0)
})
}).orElse(null)
})
/**
* The connection name of the instance to be used in
* connection strings. For example, when connecting with [Cloud SQL Proxy](https://cloud.google.com/sql/docs/mysql/connect-admin-proxy).
*/
public val connectionName: Output
get() = javaResource.connectionName().applyValue({ args0 -> args0 })
/**
* The MySQL, PostgreSQL or
* SQL Server version to use. Supported values include `MYSQL_5_6`,
* `MYSQL_5_7`, `MYSQL_8_0`, `POSTGRES_9_6`,`POSTGRES_10`, `POSTGRES_11`,
* `POSTGRES_12`, `POSTGRES_13`, `POSTGRES_14`, `POSTGRES_15`, `SQLSERVER_2017_STANDARD`,
* `SQLSERVER_2017_ENTERPRISE`, `SQLSERVER_2017_EXPRESS`, `SQLSERVER_2017_WEB`.
* `SQLSERVER_2019_STANDARD`, `SQLSERVER_2019_ENTERPRISE`, `SQLSERVER_2019_EXPRESS`,
* `SQLSERVER_2019_WEB`.
* [Database Version Policies](https://cloud.google.com/sql/docs/db-versions)
* includes an up-to-date reference of supported versions.
*/
public val databaseVersion: Output
get() = javaResource.databaseVersion().applyValue({ args0 -> args0 })
/**
* Whether or not to allow the provider to destroy the instance. Unless this field is set to false
* in state, a `destroy` or `update` command that deletes the instance will fail. Defaults to `true`.
*/
public val deletionProtection: Output?
get() = javaResource.deletionProtection().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* The dns name of the instance.
*/
public val dnsName: Output
get() = javaResource.dnsName().applyValue({ args0 -> args0 })
/**
* The full path to the encryption key used for the CMEK disk encryption. Setting
* up disk encryption currently requires manual steps outside of this provider.
* The provided key must be in the same region as the SQL instance. In order
* to use this feature, a special kind of service account must be created and
* granted permission on this key. This step can currently only be done
* manually, please see [this step](https://cloud.google.com/sql/docs/mysql/configure-cmek#service-account).
* That service account needs the `Cloud KMS > Cloud KMS CryptoKey Encrypter/Decrypter` role on your
* key - please see [this step](https://cloud.google.com/sql/docs/mysql/configure-cmek#grantkey).
*/
public val encryptionKeyName: Output
get() = javaResource.encryptionKeyName().applyValue({ args0 -> args0 })
/**
* The first IPv4 address of any type assigned.
*/
public val firstIpAddress: Output
get() = javaResource.firstIpAddress().applyValue({ args0 -> args0 })
/**
* The type of the instance. The supported values are `SQL_INSTANCE_TYPE_UNSPECIFIED`, `CLOUD_SQL_INSTANCE`, `ON_PREMISES_INSTANCE` and `READ_REPLICA_INSTANCE`.
*/
public val instanceType: Output
get() = javaResource.instanceType().applyValue({ args0 -> args0 })
public val ipAddresses: Output>
get() = javaResource.ipAddresses().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
databaseInstanceIpAddressToKotlin(args0)
})
})
})
/**
* The current software version on the instance. This attribute can not be set during creation. Refer to `available_maintenance_versions` attribute to see what `maintenance_version` are available for upgrade. When this attribute gets updated, it will cause an instance restart. Setting a `maintenance_version` value that is older than the current one on the instance will be ignored.
*/
public val maintenanceVersion: Output
get() = javaResource.maintenanceVersion().applyValue({ args0 -> args0 })
/**
* The name of the existing instance that will
* act as the master in the replication setup. Note, this requires the master to
* have `binary_log_enabled` set, as well as existing backups.
*/
public val masterInstanceName: Output
get() = javaResource.masterInstanceName().applyValue({ args0 -> args0 })
/**
* The name of the instance. If the name is left
* blank, the provider will randomly generate one when the instance is first
* created. This is done because after a name is used, it cannot be reused for
* up to [one week](https://cloud.google.com/sql/docs/delete-instance).
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* The first private (`PRIVATE`) IPv4 address assigned.
*/
public val privateIpAddress: Output
get() = javaResource.privateIpAddress().applyValue({ args0 -> args0 })
/**
* The ID of the project in which the resource belongs. If it
* is not provided, the provider project is used.
*/
public val project: Output
get() = javaResource.project().applyValue({ args0 -> args0 })
/**
* the URI that points to the service attachment of the instance.
*/
public val pscServiceAttachmentLink: Output
get() = javaResource.pscServiceAttachmentLink().applyValue({ args0 -> args0 })
/**
* The first public (`PRIMARY`) IPv4 address assigned.
*/
public val publicIpAddress: Output
get() = javaResource.publicIpAddress().applyValue({ args0 -> args0 })
/**
* The region the instance will sit in. If a region is not provided in the resource definition,
* the provider region will be used instead.
* - - -
*/
public val region: Output
get() = javaResource.region().applyValue({ args0 -> args0 })
/**
* The configuration for replication. The
* configuration is detailed below. Valid only for MySQL instances.
*/
public val replicaConfiguration: Output
get() = javaResource.replicaConfiguration().applyValue({ args0 ->
args0.let({ args0 ->
databaseInstanceReplicaConfigurationToKotlin(args0)
})
})
/**
* The context needed to restore the database to a backup run. This field will
* cause the provider to trigger the database to restore from the backup run indicated. The configuration is detailed below.
* **NOTE:** Restoring from a backup is an imperative action and not recommended via this provider. Adding or modifying this
* block during resource creation/update will trigger the restore action after the resource is created/updated.
*/
public val restoreBackupContext: Output?
get() = javaResource.restoreBackupContext().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> databaseInstanceRestoreBackupContextToKotlin(args0) })
}).orElse(null)
})
/**
* Initial root password. Can be updated. Required for MS SQL Server.
*/
public val rootPassword: Output?
get() = javaResource.rootPassword().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* The URI of the created resource.
*/
public val selfLink: Output
get() = javaResource.selfLink().applyValue({ args0 -> args0 })
public val serverCaCerts: Output>
get() = javaResource.serverCaCerts().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> databaseInstanceServerCaCertToKotlin(args0) })
})
})
/**
* The service account email address assigned to the
* instance.
*/
public val serviceAccountEmailAddress: Output
get() = javaResource.serviceAccountEmailAddress().applyValue({ args0 -> args0 })
/**
* The settings to use for the database. The
* configuration is detailed below. Required if `clone` is not set.
*/
public val settings: Output
get() = javaResource.settings().applyValue({ args0 ->
args0.let({ args0 ->
databaseInstanceSettingsToKotlin(args0)
})
})
}
public object DatabaseInstanceMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.gcp.sql.DatabaseInstance::class == javaResource::class
override fun map(javaResource: Resource): DatabaseInstance = DatabaseInstance(
javaResource as
com.pulumi.gcp.sql.DatabaseInstance,
)
}
/**
* @see [DatabaseInstance].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [DatabaseInstance].
*/
public suspend fun databaseInstance(
name: String,
block: suspend DatabaseInstanceResourceBuilder.() -> Unit,
): DatabaseInstance {
val builder = DatabaseInstanceResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [DatabaseInstance].
* @param name The _unique_ name of the resulting resource.
*/
public fun databaseInstance(name: String): DatabaseInstance {
val builder = DatabaseInstanceResourceBuilder()
builder.name(name)
return builder.build()
}