-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Enable support for Google Cloud SQL Postgres #12617
Comments
Sorry - please ignore |
Is PostgreSQL supported using |
Yes just set |
Just to be clear, the correct config has to look like this (notice that resource "google_sql_database_instance" "prod-us-east1-postgres-01" {
name = "prod-us-east1-postgres-01"
region = "us-east1"
database_version = "POSTGRES_9_6"
settings {
tier = "db-f1-micro"
disk_size = "10"
disk_type = "PD_SSD"
}
} |
As mentioned in hashicorp#12617 the google_sql_database_instance resource already supports `POSTGRES_9_6` as `database_version`, it is just undocumented so far.
I proposed to add this to the official documentation in #14028 |
As mentioned in hashicorp#12617 the google_sql_database_instance resource already supports `POSTGRES_9_6` as `database_version`, it is just undocumented so far.
This only works with shared CPU instances. Google Cloud SQL requires a custom machine instance or shared-core for PostgreSQL. For example, the following resource:
Will fail with the following error:
|
This is interesting. When I tried it last week it worked with Maybe we should reopen this issue then? |
And does anyone have a clue how to specify custom machine instance types or where to find documentation on that? https://cloud.google.com/sql/docs/postgres/admin-api/v1beta4/instances isn't really helpful at the moment. |
I see that the Cloud SDK has
That's about all I could find… The latest Go api doesn't seem to support these settings yet: https://godoc.org/google.golang.org/api/sqladmin/v1beta4 |
I could find out that cloud console uses a custom tier called {
"name": "testest",
"region": "europe-west1",
"project": "my-testing-project-1234567",
"databaseVersion": "POSTGRES_9_6",
"backendType": "SECOND_GEN",
"instanceType": "CLOUD_SQL_INSTANCE",
"replicaNames": [],
"settings": {
"dataDiskType": "PD_SSD",
"tier": "db-custom-2-5888",
"locationPreference": {},
"ipConfiguration": {
"authorizedNetworks": []
},
"backupConfiguration": {
"enabled": true,
"binaryLogEnabled": false,
"startTime": "20:00"
},
"activationPolicy": "ALWAYS",
"pricingPlan": "PER_USE",
"storageAutoResize": true,
"maintenanceWindow": {
"day": null,
"hour": 0
},
"databaseFlags": [],
"dataDiskSizeGb": 10
},
"failoverReplica": {},
"rootPassword": "***"
} No clue though where these custom tiers come from. Probably the major lesson learned here is that it doesn't make too much sense to implement terraform resources against Google cloud services that are still in beta. |
Haha, I just figured out that the custom tier actually encodes the amount of CPU and memory. The first number is the number of CPUs, the second number is the amount of memory expressed in MiB. I found it out by creating several instances through the web interface and observed the payload assembled by cloud console:
Just tried it out with terraform and it seems to work well! So the solution for now is to manually calculate the correct tier as:
Details on which combinations of number CPUs and memory are allowed are described in: https://cloud.google.com/compute/docs/instances/creating-instance-with-custom-machine-type#create |
That is both genius and terrifying... I think I'll just stick |
As mentioned in hashicorp#12617 the google_sql_database_instance resource already supports `POSTGRES_9_6` as `database_version`, it is just undocumented so far.
As mentioned in hashicorp#12617 the google_sql_database_instance resource already supports `POSTGRES_9_6` as `database_version`, it is just undocumented so far.
As mentioned in hashicorp/terraform#12617 the google_sql_database_instance resource already supports `POSTGRES_9_6` as `database_version`, it is just undocumented so far.
* Mention PostgreSQL in sql_database_instance docs As mentioned in hashicorp/terraform#12617 the google_sql_database_instance resource already supports `POSTGRES_9_6` as `database_version`, it is just undocumented so far. * Make naming of google_sql_database consistent Looks like this is a relict from some copy & paste from `google_storage_*` while writing the docs for `google_sql_database`. * Note that Postgres support is still BETA
* Mention PostgreSQL in sql_database_instance docs As mentioned in hashicorp/terraform#12617 the google_sql_database_instance resource already supports `POSTGRES_9_6` as `database_version`, it is just undocumented so far. * Make naming of google_sql_database consistent Looks like this is a relict from some copy & paste from `google_storage_*` while writing the docs for `google_sql_database`. * Note that Postgres support is still BETA
Improve google documentation (hashicorp#124) * Mention PostgreSQL in sql_database_instance docs As mentioned in hashicorp/terraform#12617 the google_sql_database_instance resource already supports `POSTGRES_9_6` as `database_version`, it is just undocumented so far. * Make naming of google_sql_database consistent Looks like this is a relict from some copy & paste from `google_storage_*` while writing the docs for `google_sql_database`. * Note that Postgres support is still BETA
* Mention PostgreSQL in sql_database_instance docs As mentioned in hashicorp/terraform#12617 the google_sql_database_instance resource already supports `POSTGRES_9_6` as `database_version`, it is just undocumented so far. * Make naming of google_sql_database consistent Looks like this is a relict from some copy & paste from `google_storage_*` while writing the docs for `google_sql_database`. * Note that Postgres support is still BETA
@ctavan awesome, thanks man! |
@ctavan you are a genius hacker. I scoured the google sql documentation and this appears no where. |
Thanks @ctavan , the more I work with gcloud the more I'm of the opinion that AWS is far > than gcloud. This is pretty nonsensical, having to write out a tier like that. |
* Mention PostgreSQL in sql_database_instance docs As mentioned in hashicorp/terraform#12617 the google_sql_database_instance resource already supports `POSTGRES_9_6` as `database_version`, it is just undocumented so far. * Make naming of google_sql_database consistent Looks like this is a relict from some copy & paste from `google_storage_*` while writing the docs for `google_sql_database`. * Note that Postgres support is still BETA
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Hi there,
Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.
Terraform Version
Terraform v0.8.8
Affected Resource(s)
Terraform Configuration Files
Debug Output
I don't believe this is a bug, more a feature request
Panic Output
N/A
Expected Behavior
Create a new Google Cloud managed postgres instance
Actual Behavior
I got an error:
google_sql_database_instance.prod-us-east1-postgres-01: settings.0: invalid or unknown key: database_version
Steps to Reproduce
terraform apply
Important Factoids
Nope
References
Could not find any other open Google Cloud Postgres issues.
The text was updated successfully, but these errors were encountered: