Website changes for SQL private IP + new computed field (#2509)

<!-- This change is generated by MagicModules. -->
/cc @danawillow
This commit is contained in:
The Magician 2018-11-21 10:43:17 -08:00 committed by Nathan McKinley
parent c77d1b0ba2
commit ff1840989b
2 changed files with 47 additions and 1 deletions

View File

@ -265,6 +265,10 @@ func resourceSqlDatabaseInstance() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"time_to_retire": &schema.Schema{
Type: schema.TypeString,
Optional: true,
@ -614,10 +618,12 @@ func expandIpConfiguration(configured []interface{}) *sqladmin.IpConfiguration {
}
_ipConfiguration := configured[0].(map[string]interface{})
return &sqladmin.IpConfiguration{
Ipv4Enabled: _ipConfiguration["ipv4_enabled"].(bool),
RequireSsl: _ipConfiguration["require_ssl"].(bool),
AuthorizedNetworks: expandAuthorizedNetworks(_ipConfiguration["authorized_networks"].(*schema.Set).List()),
ForceSendFields: []string{"Ipv4Enabled"},
}
}
func expandAuthorizedNetworks(configured []interface{}) []*sqladmin.AclEntry {
@ -696,7 +702,6 @@ func resourceSqlDatabaseInstanceRead(d *schema.ResourceData, meta interface{}) e
if err := d.Set("replica_configuration", flattenReplicaConfiguration(instance.ReplicaConfiguration, d)); err != nil {
log.Printf("[WARN] Failed to set SQL Database Instance Replica Configuration")
}
ipAddresses := flattenIpAddresses(instance.IpAddresses)
if err := d.Set("ip_address", ipAddresses); err != nil {
log.Printf("[WARN] Failed to set SQL Database Instance IP Addresses")
@ -950,6 +955,7 @@ func flattenIpAddresses(ipAddresses []*sqladmin.IpMapping) []map[string]interfac
for _, ip := range ipAddresses {
data := map[string]interface{}{
"ip_address": ip.IpAddress,
"type": ip.Type,
"time_to_retire": ip.TimeToRetire,
}

View File

@ -108,6 +108,42 @@ resource "google_sql_database_instance" "postgres" {
}
```
### Private IP Instance
```hcl
resource "google_compute_network" "private_network" {
name = "private_network"
}
resource "google_compute_global_address" "private_ip_address" {
name = "private_ip_address"
purpose = "VPC_PEERING"
address_type = "INTERNAL"
prefix_length = 16
network = "${google_compute_network.private_network.self_link}"
}
resource "google_service_networking_connection" "private_vpc_connection" {
network = "${google_compute_network.private_network.self_link}"
service = "servicenetworking.googleapis.com"
reserved_peering_ranges = ["${google_compute_global_address.private_ip_address.name}"]
}
resource "google_sql_database_instance" "instance" {
depends_on = ["google_service_networking_connection.private_vpc_connection"]
name = "private_instance"
region = "us-central1"
settings {
tier = "db-f1-micro"
ip_configuration {
ipv4_enabled = "false"
private_network = "${google_compute_network.private_network.self_link}"
}
}
}
```
## Argument Reference
The following arguments are supported:
@ -205,6 +241,8 @@ The optional `settings.ip_configuration` subblock supports:
* `require_ssl` - (Optional) True if mysqld should default to `REQUIRE X509`
for users connecting over IP.
* `private_network` - (Optional, [Beta](https://terraform.io/docs/providers/google/provider_versions.html)) The resource link for the VPC network from which the Cloud SQL instance is accessible for private IP.
The optional `settings.ip_configuration.authorized_networks[]` sublist supports:
* `expiration_time` - (Optional) The [RFC 3339](https://tools.ietf.org/html/rfc3339)
@ -286,6 +324,8 @@ when the resource is configured with a `count`.
* `ip_address.0.time_to_retire` - The time this IP address will be retired, in RFC
3339 format.
* `ip_address.0.type` - The type of this IP address. A PRIMARY address is an address that can accept incoming connections. An OUTGOING address is the source address of connections originating from the instance, if supported. A PRIVATE address is an address for an instance which has been configured to use private networking see: [Private IP](https://cloud.google.com/sql/docs/mysql/private-ip).
* `self_link` - The URI of the created resource.
* `settings.version` - Used to make sure changes to the `settings` block are