Skip to content

Commit

Permalink
Added more outputs and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-bitonti committed Nov 22, 2023
1 parent 140a986 commit 37eda6a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
28 changes: 15 additions & 13 deletions modules/cloudsql-instance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ module "db" {
|---|---|:---:|:---:|:---:|
| [database_version](variables.tf#L68) | Database type and version to create. | <code>string</code> || |
| [name](variables.tf#L146) | Name of primary instance. | <code>string</code> || |
| [network_config](variables.tf#L151) | Network configuration for the instance. Only one between private VPC and PSC can be used. | <code title="object&#40;&#123;&#10; authorized_networks &#61; optional&#40;map&#40;string&#41;&#41;&#10; ipv4_enabled &#61; optional&#40;bool, false&#41;&#10; private_network &#61; optional&#40;string, null&#41;&#10; require_ssl &#61; optional&#40;bool&#41;&#10; allocated_ip_ranges &#61; optional&#40;object&#40;&#123;&#10; primary &#61; optional&#40;string&#41;&#10; replica &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; psc_config &#61; optional&#40;object&#40;&#123;&#10; allowed_consumer_projects &#61; optional&#40;list&#40;string&#41;, &#91;&#93;&#41;&#10; psc_enabled &#61; optional&#40;bool, true&#41;&#10; &#125;&#41;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> || |
| [network_config](variables.tf#L151) | Network configuration for the instance. Only one between private_network and psc_config can be used. | <code title="object&#40;&#123;&#10; authorized_networks &#61; optional&#40;map&#40;string&#41;&#41;&#10; ipv4_enabled &#61; optional&#40;bool, false&#41;&#10; private_network &#61; optional&#40;string, null&#41;&#10; require_ssl &#61; optional&#40;bool&#41;&#10; allocated_ip_ranges &#61; optional&#40;object&#40;&#123;&#10; primary &#61; optional&#40;string&#41;&#10; replica &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;&#10; psc_config &#61; optional&#40;object&#40;&#123;&#10; allowed_consumer_projects &#61; optional&#40;list&#40;string&#41;, &#91;&#93;&#41;&#10; psc_enabled &#61; optional&#40;bool, true&#41;&#10; &#125;&#41;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> || |
| [project_id](variables.tf#L189) | The ID of the project where this instances will be created. | <code>string</code> || |
| [region](variables.tf#L194) | Region of the primary instance. | <code>string</code> || |
| [tier](variables.tf#L214) | The machine type to use for the instances. | <code>string</code> || |
Expand Down Expand Up @@ -237,16 +237,18 @@ module "db" {
| [connection_name](outputs.tf#L24) | Connection name of the primary instance. | |
| [connection_names](outputs.tf#L29) | Connection names of all instances. | |
| [dns_name](outputs.tf#L37) | The dns name of the instance. | |
| [id](outputs.tf#L42) | Fully qualified primary instance id. | |
| [ids](outputs.tf#L47) | Fully qualified ids of all instances. | |
| [instances](outputs.tf#L55) | Cloud SQL instance resources. ||
| [ip](outputs.tf#L61) | IP address of the primary instance. | |
| [ips](outputs.tf#L66) | IP addresses of all instances. | |
| [name](outputs.tf#L74) | Name of the primary instance. | |
| [names](outputs.tf#L79) | Names of all instances. | |
| [postgres_client_certificates](outputs.tf#L87) | The CA Certificate used to connect to the SQL Instance via SSL. ||
| [psc_service_attachment_link](outputs.tf#L93) | The link to service attachment of PSC instance. | |
| [self_link](outputs.tf#L98) | Self link of the primary instance. | |
| [self_links](outputs.tf#L103) | Self links of all instances. | |
| [user_passwords](outputs.tf#L111) | Map of containing the password of all users created through terraform. ||
| [dns_names](outputs.tf#L42) | Dns names of all instances. | |
| [id](outputs.tf#L50) | Fully qualified primary instance id. | |
| [ids](outputs.tf#L55) | Fully qualified ids of all instances. | |
| [instances](outputs.tf#L63) | Cloud SQL instance resources. ||
| [ip](outputs.tf#L69) | IP address of the primary instance. | |
| [ips](outputs.tf#L74) | IP addresses of all instances. | |
| [name](outputs.tf#L82) | Name of the primary instance. | |
| [names](outputs.tf#L87) | Names of all instances. | |
| [postgres_client_certificates](outputs.tf#L95) | The CA Certificate used to connect to the SQL Instance via SSL. ||
| [psc_service_attachment_link](outputs.tf#L101) | The link to service attachment of PSC instance. | |
| [psc_service_attachment_links](outputs.tf#L106) | Links to service attachment of PSC instances. | |
| [self_link](outputs.tf#L114) | Self link of the primary instance. | |
| [self_links](outputs.tf#L119) | Self links of all instances. | |
| [user_passwords](outputs.tf#L127) | Map of containing the password of all users created through terraform. ||
<!-- END TFDOC -->
20 changes: 18 additions & 2 deletions modules/cloudsql-instance/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@ output "connection_names" {

output "dns_name" {
description = "The dns name of the instance."
value = try(google_sql_database_instance.primary.dns_name, null)
value = google_sql_database_instance.primary.dns_name
}

output "dns_names" {
description = "Dns names of all instances."
value = {
for id, instance in local._all_instances :
id => instance.dns_name
}
}

output "id" {
Expand Down Expand Up @@ -92,7 +100,15 @@ output "postgres_client_certificates" {

output "psc_service_attachment_link" {
description = "The link to service attachment of PSC instance."
value = try(google_sql_database_instance.primary.psc_service_attachment_link, null)
value = google_sql_database_instance.primary.psc_service_attachment_link
}

output "psc_service_attachment_links" {
description = "Links to service attachment of PSC instances."
value = {
for id, instance in local._all_instances :
id => instance.psc_service_attachment_link
}
}

output "self_link" {
Expand Down
4 changes: 2 additions & 2 deletions modules/cloudsql-instance/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ variable "name" {
}

variable "network_config" {
description = "Network configuration for the instance. Only one between private VPC and PSC can be used."
description = "Network configuration for the instance. Only one between private_network and psc_config can be used."
type = object({
authorized_networks = optional(map(string))
ipv4_enabled = optional(bool, false)
Expand All @@ -165,7 +165,7 @@ variable "network_config" {
}))
})
validation {
condition = (var.network_config.private_network != null ? 1 : 0) + (var.network_config.psc_config != null ? 1 : 0) == 1
condition = (var.network_config.private_network != null ? 1 : 0) + (var.network_config.psc_config != null ? 1 : 0) < 2
error_message = "Only one between private network and psc can be specified."
}
}
Expand Down

0 comments on commit 37eda6a

Please sign in to comment.