Merge #6008: PostgreSQL provider supports "ssl_mode"

This commit is contained in:
Martin Atkins 2016-04-17 08:20:44 -07:00
commit 4954f1351f
3 changed files with 12 additions and 2 deletions

View File

@ -13,6 +13,7 @@ type Config struct {
Port int
Username string
Password string
SslMode string
}
// Client struct holding connection string
@ -23,7 +24,7 @@ type Client struct {
//NewClient returns new client config
func (c *Config) NewClient() (*Client, error) {
connStr := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=postgres", c.Host, c.Port, c.Username, c.Password)
connStr := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=postgres sslmode=%s", c.Host, c.Port, c.Username, c.Password, c.SslMode)
client := Client{
connStr: connStr,

View File

@ -35,6 +35,12 @@ func Provider() terraform.ResourceProvider {
DefaultFunc: schema.EnvDefaultFunc("POSTGRESQL_PASSWORD", nil),
Description: "Password for postgresql server connection",
},
"ssl_mode": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: "require",
Description: "Connection mode for postgresql server",
},
},
ResourcesMap: map[string]*schema.Resource{
@ -52,6 +58,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
Port: d.Get("port").(int),
Username: d.Get("username").(string),
Password: d.Get("password").(string),
SslMode: d.Get("ssl_mode").(string),
}
client, err := config.NewClient()

View File

@ -20,6 +20,7 @@ provider "postgresql" {
port = 5432
username = "postgres_user"
password = "postgres_password"
ssl_mode = "require"
}
```
@ -60,4 +61,5 @@ The following arguments are supported:
* `host` - (Required) The address for the postgresql server connection.
* `port` - (Optional) The port for the postgresql server connection. (Default 5432)
* `username` - (Required) Username for the server connection.
* `password` - (Optional) Password for the server connection.
* `password` - (Optional) Password for the server connection.
* `ssl_mode` - (Optional) Set connection mode for postgresql server (Default "require", more options [lib/pq documentations](https://godoc.org/github.com/lib/pq)).