mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-04 17:51:11 +00:00
Add convenience outputs for public/private IP in Cloud SQL (#3091)
<!-- This change is generated by MagicModules. --> /cc @rileykarson
This commit is contained in:
parent
e989c7a976
commit
10be93463d
@ -186,7 +186,7 @@ func resourceSqlDatabaseInstance() *schema.Resource {
|
|||||||
"private_network": {
|
"private_network": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ValidateFunc: validateRegexp(privateNetworkLinkRegex),
|
ValidateFunc: orEmpty(validateRegexp(privateNetworkLinkRegex)),
|
||||||
DiffSuppressFunc: compareSelfLinkRelativePaths,
|
DiffSuppressFunc: compareSelfLinkRelativePaths,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -291,6 +291,16 @@ func resourceSqlDatabaseInstance() *schema.Resource {
|
|||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"public_ip_address": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
"private_ip_address": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
|
||||||
"name": {
|
"name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
@ -721,6 +731,21 @@ func resourceSqlDatabaseInstanceRead(d *schema.ResourceData, meta interface{}) e
|
|||||||
d.Set("first_ip_address", ipAddresses[0]["ip_address"])
|
d.Set("first_ip_address", ipAddresses[0]["ip_address"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publicIpAddress := ""
|
||||||
|
privateIpAddress := ""
|
||||||
|
for _, ip := range instance.IpAddresses {
|
||||||
|
if publicIpAddress == "" && ip.Type == "PRIMARY" {
|
||||||
|
publicIpAddress = ip.IpAddress
|
||||||
|
}
|
||||||
|
|
||||||
|
if privateIpAddress == "" && ip.Type == "PRIVATE" {
|
||||||
|
privateIpAddress = ip.IpAddress
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
d.Set("public_ip_address", publicIpAddress)
|
||||||
|
d.Set("private_ip_address", privateIpAddress)
|
||||||
|
|
||||||
if err := d.Set("server_ca_cert", flattenServerCaCert(instance.ServerCaCert)); err != nil {
|
if err := d.Set("server_ca_cert", flattenServerCaCert(instance.ServerCaCert)); err != nil {
|
||||||
log.Printf("[WARN] Failed to set SQL Database CA Certificate")
|
log.Printf("[WARN] Failed to set SQL Database CA Certificate")
|
||||||
}
|
}
|
||||||
|
@ -313,20 +313,40 @@ to work, cannot be updated, and supports:
|
|||||||
In addition to the arguments listed above, the following computed attributes are
|
In addition to the arguments listed above, the following computed attributes are
|
||||||
exported:
|
exported:
|
||||||
|
|
||||||
* `first_ip_address` - The first IPv4 address of the addresses assigned. This is
|
* `self_link` - The URI of the created resource.
|
||||||
is to support accessing the [first address in the list in a terraform output](https://github.com/terraform-providers/terraform-provider-google/issues/912)
|
|
||||||
when the resource is configured with a `count`.
|
|
||||||
|
|
||||||
* `connection_name` - The connection name of the instance to be used in connection strings.
|
* `connection_name` - The connection name of the instance to be used in
|
||||||
|
connection strings. For example, when connecting with [Cloud SQL Proxy](https://cloud.google.com/sql/docs/mysql/connect-admin-proxy).
|
||||||
|
|
||||||
|
* `service_account_email_address` - The service account email address assigned to the
|
||||||
|
instance. This property is applicable only to Second Generation instances.
|
||||||
|
|
||||||
* `ip_address.0.ip_address` - The IPv4 address assigned.
|
* `ip_address.0.ip_address` - The IPv4 address assigned.
|
||||||
|
|
||||||
* `ip_address.0.time_to_retire` - The time this IP address will be retired, in RFC
|
* `ip_address.0.time_to_retire` - The time this IP address will be retired, in RFC
|
||||||
3339 format.
|
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).
|
* `ip_address.0.type` - The type of this IP address.
|
||||||
|
|
||||||
* `self_link` - The URI of the created resource.
|
* 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).
|
||||||
|
|
||||||
|
* `first_ip_address` - The first IPv4 address of any type assigned. This is to
|
||||||
|
support accessing the [first address in the list in a terraform output](https://github.com/terraform-providers/terraform-provider-google/issues/912)
|
||||||
|
when the resource is configured with a `count`.
|
||||||
|
|
||||||
|
* `public_ip_address` - The first public (`PRIMARY`) IPv4 address assigned. This is
|
||||||
|
a workaround for an [issue fixed in Terraform 0.12](https://github.com/hashicorp/terraform/issues/17048)
|
||||||
|
but also provides a convenient way to access an IP of a specific type without
|
||||||
|
performing filtering in a Terraform config.
|
||||||
|
|
||||||
|
* `private_ip_address` - The first private (`PRIVATE`) IPv4 address assigned. This is
|
||||||
|
a workaround for an [issue fixed in Terraform 0.12](https://github.com/hashicorp/terraform/issues/17048)
|
||||||
|
but also provides a convenient way to access an IP of a specific type without
|
||||||
|
performing filtering in a Terraform config.
|
||||||
|
|
||||||
* `settings.version` - Used to make sure changes to the `settings` block are
|
* `settings.version` - Used to make sure changes to the `settings` block are
|
||||||
atomic.
|
atomic.
|
||||||
@ -341,9 +361,6 @@ when the resource is configured with a `count`.
|
|||||||
|
|
||||||
* `server_ca_cert.0.sha1_fingerprint` - SHA Fingerprint of the CA Cert.
|
* `server_ca_cert.0.sha1_fingerprint` - SHA Fingerprint of the CA Cert.
|
||||||
|
|
||||||
* `service_account_email_address` - The service account email address assigned to the
|
|
||||||
instance. This property is applicable only to Second Generation instances.
|
|
||||||
|
|
||||||
## Timeouts
|
## Timeouts
|
||||||
|
|
||||||
`google_sql_database_instance` provides the following
|
`google_sql_database_instance` provides the following
|
||||||
|
Loading…
Reference in New Issue
Block a user