Show / Hide Table of Contents

Namespace Pulumi.Gcp.Sql

Classes

Database

Represents a SQL database inside the Cloud SQL instance, hosted in Google's cloud.

Example Usage - Sql Database Basic

using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
public MyStack()
{
    var instance = new Gcp.Sql.DatabaseInstance("instance", new Gcp.Sql.DatabaseInstanceArgs
    {
        Region = "us-central1",
        Settings = new Gcp.Sql.Inputs.DatabaseInstanceSettingsArgs
        {
            Tier = "db-f1-micro",
        },
    });
    var database = new Gcp.Sql.Database("database", new Gcp.Sql.DatabaseArgs
    {
        Instance = instance.Name,
    });
}

}

DatabaseArgs

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 },
            },
        },
    });
}

}

DatabaseInstanceArgs

DatabaseInstanceState

DatabaseState

GetCaCerts

GetCaCertsArgs

GetCaCertsResult

SourceRepresentationInstance

A source representation instance is a Cloud SQL instance that represents the source database server to the Cloud SQL replica. It is visible in the Cloud Console and appears the same as a regular Cloud SQL instance, but it contains no data, requires no configuration or maintenance, and does not affect billing. You cannot update the source representation instance.

Example Usage - Sql Source Representation Instance Basic

using Pulumi;
using Gcp = Pulumi.Gcp;

class MyStack : Stack
{
public MyStack()
{
    var instance = new Gcp.Sql.SourceRepresentationInstance("instance", new Gcp.Sql.SourceRepresentationInstanceArgs
    {
        DatabaseVersion = "MYSQL_5_7",
        Host = "10.20.30.40",
        Port = 3306,
        Region = "us-central1",
    });
}

}

SourceRepresentationInstanceArgs

SourceRepresentationInstanceState

SslCert

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

Example Usage

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

class MyStack : Stack
{
public MyStack()
{
    var dbNameSuffix = new Random.RandomId("dbNameSuffix", new Random.RandomIdArgs
    {
        ByteLength = 4,
    });
    var master = new Gcp.Sql.DatabaseInstance("master", new Gcp.Sql.DatabaseInstanceArgs
    {
        Settings = new Gcp.Sql.Inputs.DatabaseInstanceSettingsArgs
        {
            Tier = "db-f1-micro",
        },
    });
    var clientCert = new Gcp.Sql.SslCert("clientCert", new Gcp.Sql.SslCertArgs
    {
        CommonName = "client-name",
        Instance = master.Name,
    });
}

}

SslCertArgs

SslCertState

User

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

Example Usage

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

class MyStack : Stack
{
public MyStack()
{
    var dbNameSuffix = new Random.RandomId("dbNameSuffix", new Random.RandomIdArgs
    {
        ByteLength = 4,
    });
    var master = new Gcp.Sql.DatabaseInstance("master", new Gcp.Sql.DatabaseInstanceArgs
    {
        Settings = new Gcp.Sql.Inputs.DatabaseInstanceSettingsArgs
        {
            Tier = "db-f1-micro",
        },
    });
    var users = new Gcp.Sql.User("users", new Gcp.Sql.UserArgs
    {
        Instance = master.Name,
        Host = "me.com",
        Password = "changeme",
    });
}

}

UserArgs

UserState

Back to top Copyright 2016-2020, Pulumi Corporation.