github.com/nbering/terraform@v0.8.5-0.20170113232247-453f670684b5/website/source/docs/providers/postgresql/index.html.markdown (about) 1 --- 2 layout: "postgresql" 3 page_title: "Provider: PostgreSQL" 4 sidebar_current: "docs-postgresql-index" 5 description: |- 6 A provider for PostgreSQL Server. 7 --- 8 9 # PostgreSQL Provider 10 11 The PostgreSQL provider gives the ability to deploy and configure resources in a PostgreSQL server. 12 13 Use the navigation to the left to read about the available resources. 14 15 ## Usage 16 17 ``` 18 provider "postgresql" { 19 host = "postgres_server_ip" 20 port = 5432 21 database = "postgres" 22 username = "postgres_user" 23 password = "postgres_password" 24 sslmode = "require" 25 connect_timeout = 15 26 } 27 28 ``` 29 30 Configuring multiple servers can be done by specifying the alias option. 31 32 ``` 33 provider "postgresql" { 34 alias = "pg1" 35 host = "postgres_server_ip1" 36 username = "postgres_user1" 37 password = "postgres_password1" 38 } 39 40 provider "postgresql" { 41 alias = "pg2" 42 host = "postgres_server_ip2" 43 username = "postgres_user2" 44 password = "postgres_password2" 45 } 46 47 resource "postgresql_database" "my_db1" { 48 provider = "postgresql.pg1" 49 name = "my_db1" 50 } 51 resource "postgresql_database" "my_db2" { 52 provider = "postgresql.pg2" 53 name = "my_db2" 54 } 55 56 57 ``` 58 59 ## Argument Reference 60 61 The following arguments are supported: 62 63 * `host` - (Required) The address for the postgresql server connection. 64 * `port` - (Optional) The port for the postgresql server connection. The default is `5432`. 65 * `database` - (Optional) Database to connect to. The default is `postgres`. 66 * `username` - (Required) Username for the server connection. 67 * `password` - (Optional) Password for the server connection. 68 * `sslmode` - (Optional) Set the priority for an SSL connection to the server. 69 Valid values for `sslmode` are (note: `prefer` is not supported by Go's 70 [`lib/pq`](https://godoc.org/github.com/lib/pq)): 71 * disable - No SSL 72 * require - Always SSL (the default, also skip verification) 73 * verify-ca - Always SSL (verify that the certificate presented by the server was signed by a trusted CA) 74 * verify-full - Always SSL (verify that the certification presented by the server was signed by a trusted CA and the server host name matches the one in the certificate) 75 Additional information on the options and their implications can be seen 76 [in the `libpq(3)` SSL guide](http://www.postgresql.org/docs/current/static/libpq-ssl.html#LIBPQ-SSL-PROTECTION). 77 * `connect_timeout` - (Optional) Maximum wait for connection, in seconds. The 78 default is `180s`. Zero or not specified means wait indefinitely.