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=truesettings.backup_configuration.enabled=truesettings.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:regiondatabase_version(if applicable)tier
Remove any fields that are not applicable to Second-generation instances:settings.crash_safe_replicationsettings.replication_typesettings.authorized_gae_applicationsAnd 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) Changesettings.backup_configuration.enabledattribute 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 usegcp.sql.Userto 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 },
},
},
});
}
}
Inherited Members
Namespace: Pulumi.Gcp.Sql
Assembly: Pulumi.Gcp.dll
Syntax
public class DatabaseInstance : CustomResource
Constructors
View SourceDatabaseInstance(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 SourceConnectionName
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> |
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> |
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> |
FirstIpAddress
The first IPv4 address of any type assigned.
Declaration
public Output<string> FirstIpAddress { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
IpAddresses
Declaration
public Output<ImmutableArray<DatabaseInstanceIpAddress>> IpAddresses { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Collections.Immutable.ImmutableArray<DatabaseInstanceIpAddress>> |
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> |
Name
A name for this whitelist entry.
Declaration
public Output<string> Name { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
PrivateIpAddress
The first private (PRIVATE) IPv4 address assigned.
Declaration
public Output<string> PrivateIpAddress { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
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> |
PublicIpAddress
The first public (PRIMARY) IPv4 address assigned.
Declaration
public Output<string> PublicIpAddress { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
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> |
ReplicaConfiguration
The configuration for replication. The configuration is detailed below.
Declaration
public Output<DatabaseInstanceReplicaConfiguration> ReplicaConfiguration { get; }
Property Value
| Type | Description |
|---|---|
| Output<DatabaseInstanceReplicaConfiguration> |
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> |
SelfLink
The URI of the created resource.
Declaration
public Output<string> SelfLink { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
ServerCaCert
Declaration
public Output<DatabaseInstanceServerCaCert> ServerCaCert { get; }
Property Value
| Type | Description |
|---|---|
| Output<DatabaseInstanceServerCaCert> |
ServiceAccountEmailAddress
The service account email address assigned to the instance.
Declaration
public Output<string> ServiceAccountEmailAddress { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
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 SourceGet(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 |