Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sql private ip to ga provider #2662

Merged
merged 1 commit into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions google/resource_sql_database_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
"google.golang.org/api/sqladmin/v1beta4"
)

const privateNetworkLinkRegex = "projects/(" + ProjectRegex + ")/global/networks/((?:[a-z](?:[-a-z0-9]*[a-z0-9])?))$"

var sqlDatabaseAuthorizedNetWorkSchemaElem *schema.Resource = &schema.Resource{
Schema: map[string]*schema.Schema{
"expiration_time": &schema.Schema{
Expand Down Expand Up @@ -181,6 +183,12 @@ func resourceSqlDatabaseInstance() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
},
"private_network": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ValidateFunc: validateRegexp(privateNetworkLinkRegex),
DiffSuppressFunc: compareSelfLinkRelativePaths,
},
},
},
},
Expand Down Expand Up @@ -624,6 +632,7 @@ func expandIpConfiguration(configured []interface{}) *sqladmin.IpConfiguration {
return &sqladmin.IpConfiguration{
Ipv4Enabled: _ipConfiguration["ipv4_enabled"].(bool),
RequireSsl: _ipConfiguration["require_ssl"].(bool),
PrivateNetwork: _ipConfiguration["private_network"].(string),
AuthorizedNetworks: expandAuthorizedNetworks(_ipConfiguration["authorized_networks"].(*schema.Set).List()),
ForceSendFields: []string{"Ipv4Enabled", "RequireSsl"},
}
Expand Down Expand Up @@ -877,8 +886,9 @@ func flattenDatabaseFlags(databaseFlags []*sqladmin.DatabaseFlags) []map[string]

func flattenIpConfiguration(ipConfiguration *sqladmin.IpConfiguration) interface{} {
data := map[string]interface{}{
"ipv4_enabled": ipConfiguration.Ipv4Enabled,
"require_ssl": ipConfiguration.RequireSsl,
"ipv4_enabled": ipConfiguration.Ipv4Enabled,
"private_network": ipConfiguration.PrivateNetwork,
"require_ssl": ipConfiguration.RequireSsl,
}

if ipConfiguration.AuthorizedNetworks != nil {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/sql_database_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ 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.
* `private_network` - (Optional) 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:

Expand Down