Show / Hide Table of Contents

Class DatabaseInstance

Creates a new Google SQL Database Instance. For more information, see the official documentation, or the JSON API.

NOTE on gcp.sql.DatabaseInstance: - First-generation instances have been deprecated and should no longer be created, see upgrade docs for more details. To upgrade your First-generation instance, update your config that the instance has

  • settings.ip_configuration.ipv4_enabled=true
  • settings.backup_configuration.enabled=true
  • settings.backup_configuration.binary_log_enabled=true.
    Apply the config, then upgrade the instance in the console as described in the documentation. Once upgraded, update the following attributes in your config to the correct value according to the above documentation:
  • region
  • database_version (if applicable)
  • tier
    Remove any fields that are not applicable to Second-generation instances:
  • settings.crash_safe_replication
  • settings.replication_type
  • settings.authorized_gae_applications And change values to appropriate values for Second-generation instances for:
  • activation_policy ("ON_DEMAND" is no longer an option)
  • pricing_plan ("PER_USE" is now the only valid option) Change settings.backup_configuration.enabled attribute back to its desired value and apply as necessary.

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.

Example Usage

SQL Second Generation Instance

using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
public MyStack()
{
    var master = new Gcp.Sql.DatabaseInstance("master", new Gcp.Sql.DatabaseInstanceArgs
    {
        DatabaseVersion = "POSTGRES_11",
        Region = "us-central1",
        Settings = new Gcp.Sql.Inputs.DatabaseInstanceSettingsArgs
        {
            Tier = "db-f1-micro",
        },
    });
}

}

Private IP Instance

using Pulumi;
using Gcp = Pulumi.Gcp;
using Random = Pulumi.Random;

class MyStack : Stack
{
public MyStack()
{
    var privateNetwork = new Gcp.Compute.Network("privateNetwork", new Gcp.Compute.NetworkArgs
    {
    });
    var privateIpAddress = new Gcp.Compute.GlobalAddress("privateIpAddress", new Gcp.Compute.GlobalAddressArgs
    {
        Purpose = "VPC_PEERING",
        AddressType = "INTERNAL",
        PrefixLength = 16,
        Network = privateNetwork.Id,
    });
    var privateVpcConnection = new Gcp.ServiceNetworking.Connection("privateVpcConnection", new Gcp.ServiceNetworking.ConnectionArgs
    {
        Network = privateNetwork.Id,
        Service = "servicenetworking.googleapis.com",
        ReservedPeeringRanges = 
        {
            privateIpAddress.Name,
        },
    });
    var dbNameSuffix = new Random.RandomId("dbNameSuffix", new Random.RandomIdArgs
    {
        ByteLength = 4,
    });
    var instance = new Gcp.Sql.DatabaseInstance("instance", new Gcp.Sql.DatabaseInstanceArgs
    {
        Region = "us-central1",
        Settings = new Gcp.Sql.Inputs.DatabaseInstanceSettingsArgs
        {
            Tier = "db-f1-micro",
            Ip_configuration = 
            {
                { "ipv4Enabled", false },
                { "privateNetwork", privateNetwork.Id },
            },
        },
    });
}

}
Inheritance
System.Object
Resource
CustomResource
DatabaseInstance
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.Gcp.Sql
Assembly: Pulumi.Gcp.dll
Syntax
public class DatabaseInstance : CustomResource

Constructors

View Source

DatabaseInstance(String, DatabaseInstanceArgs, CustomResourceOptions)

Create a DatabaseInstance resource with the given unique name, arguments, and options.

Declaration
public DatabaseInstance(string name, DatabaseInstanceArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

DatabaseInstanceArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

ConnectionName

The connection name of the instance to be used in connection strings. For example, when connecting with Cloud SQL Proxy.

Declaration
public Output<string> ConnectionName { get; }
Property Value
Type Description
Output<System.String>
View Source

DatabaseVersion

The MySQL, PostgreSQL or SQL Server (beta) version to use. Supported values include MYSQL_5_6, MYSQL_5_7, POSTGRES_9_6,POSTGRES_10, POSTGRES_11, POSTGRES_12, SQLSERVER_2017_STANDARD, SQLSERVER_2017_ENTERPRISE, SQLSERVER_2017_EXPRESS, SQLSERVER_2017_WEB. Database Version Policies includes an up-to-date reference of supported versions.

Declaration
public Output<string> DatabaseVersion { get; }
Property Value
Type Description
Output<System.String>
View Source

EncryptionKeyName

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. That service account needs the Cloud KMS > Cloud KMS CryptoKey Encrypter/Decrypter role on your key - please see this step.

Declaration
public Output<string> EncryptionKeyName { get; }
Property Value
Type Description
Output<System.String>
View Source

FirstIpAddress

The first IPv4 address of any type assigned.

Declaration
public Output<string> FirstIpAddress { get; }
Property Value
Type Description
Output<System.String>
View Source

IpAddresses

Declaration
public Output<ImmutableArray<DatabaseInstanceIpAddress>> IpAddresses { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<DatabaseInstanceIpAddress>>
View Source

MasterInstanceName

The name of the 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.

Declaration
public Output<string> MasterInstanceName { get; }
Property Value
Type Description
Output<System.String>
View Source

Name

A name for this whitelist entry.

Declaration
public Output<string> Name { get; }
Property Value
Type Description
Output<System.String>
View Source

PrivateIpAddress

The first private (PRIVATE) IPv4 address assigned.

Declaration
public Output<string> PrivateIpAddress { get; }
Property Value
Type Description
Output<System.String>
View Source

Project

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Declaration
public Output<string> Project { get; }
Property Value
Type Description
Output<System.String>
View Source

PublicIpAddress

The first public (PRIMARY) IPv4 address assigned.

Declaration
public Output<string> PublicIpAddress { get; }
Property Value
Type Description
Output<System.String>
View Source

Region

The region the instance will sit in. Note, Cloud SQL is not available in all regions - choose from one of the options listed here. A valid region must be provided to use this resource. If a region is not provided in the resource definition, the provider region will be used instead, but this will be an apply-time error for instances if the provider region is not supported with Cloud SQL. If you choose not to provide the region argument for this resource, make sure you understand this.

Declaration
public Output<string> Region { get; }
Property Value
Type Description
Output<System.String>
View Source

ReplicaConfiguration

The configuration for replication. The configuration is detailed below.

Declaration
public Output<DatabaseInstanceReplicaConfiguration> ReplicaConfiguration { get; }
Property Value
Type Description
Output<DatabaseInstanceReplicaConfiguration>
View Source

RootPassword

Initial root password. Required for MS SQL Server, ignored by MySQL and PostgreSQL.

Declaration
public Output<string> RootPassword { get; }
Property Value
Type Description
Output<System.String>
View Source

SelfLink

The URI of the created resource.

Declaration
public Output<string> SelfLink { get; }
Property Value
Type Description
Output<System.String>
View Source

ServerCaCert

Declaration
public Output<DatabaseInstanceServerCaCert> ServerCaCert { get; }
Property Value
Type Description
Output<DatabaseInstanceServerCaCert>
View Source

ServiceAccountEmailAddress

The service account email address assigned to the instance.

Declaration
public Output<string> ServiceAccountEmailAddress { get; }
Property Value
Type Description
Output<System.String>
View Source

Settings

The settings to use for the database. The configuration is detailed below.

Declaration
public Output<DatabaseInstanceSettings> Settings { get; }
Property Value
Type Description
Output<DatabaseInstanceSettings>

Methods

View Source

Get(String, Input<String>, DatabaseInstanceState, CustomResourceOptions)

Get an existing DatabaseInstance resource's state with the given name, ID, and optional extra properties used to qualify the lookup.

Declaration
public static DatabaseInstance Get(string name, Input<string> id, DatabaseInstanceState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

DatabaseInstanceState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
DatabaseInstance
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.