Skip to content

Commit bc9e0c3

Browse files
Sichen ZhaoSichen Zhao
authored andcommitted
update for comments
1 parent 43d5e8d commit bc9e0c3

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

postgresql/config.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ type ClientCertificateConfig struct {
169169
type Config struct {
170170
Scheme string
171171
Host string
172-
ConnectionHost string
172+
AWSIAMDBAuthTokenHost string
173173
Port int
174174
Username string
175175
Password string
@@ -249,10 +249,7 @@ func (c *Config) connParams() []string {
249249
}
250250

251251
func (c *Config) connStr(database string) string {
252-
host := c.ConnectionHost
253-
if host == "" {
254-
host = c.Host
255-
}
252+
host = c.Host
256253
// For GCP, support both project/region/instance and project:region:instance
257254
// (The second one allows to use the output of google_sql_database_instance as host
258255
if c.Scheme == "gcppostgres" {

postgresql/provider.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ func Provider() *schema.Provider {
4646
DefaultFunc: schema.EnvDefaultFunc("PGHOST", nil),
4747
Description: "Name of PostgreSQL server address",
4848
},
49-
"connection_host": {
50-
Type: schema.TypeString,
51-
Optional: true,
52-
DefaultFunc: schema.EnvDefaultFunc("PGHOST", nil),
53-
Description: "Name of PostgreSQL server address to connect to",
54-
},
5549
"port": {
5650
Type: schema.TypeInt,
5751
Optional: true,
@@ -106,6 +100,13 @@ func Provider() *schema.Provider {
106100
Description: "AWS IAM role to assume for IAM auth",
107101
},
108102

103+
"aws_rds_iam_token_host": {
104+
Type: schema.TypeString,
105+
Optional: true,
106+
DefaultFunc: schema.EnvDefaultFunc("PGHOST", nil),
107+
Description: "Name of PostgreSQL server address for AWS RDS IAM to get token",
108+
},
109+
109110
"azure_identity_auth": {
110111
Type: schema.TypeBool,
111112
Optional: true,
@@ -350,18 +351,18 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
350351
port := d.Get("port").(int)
351352
username := d.Get("username").(string)
352353

353-
connectionHost := d.Get("connection_host").(string)
354-
if connectionHost == "" {
355-
connectionHost = host
356-
}
357-
358354
var password string
359355
if d.Get("aws_rds_iam_auth").(bool) {
356+
awsIAMTokenHost := d.Get("aws_rds_iam_token_host").(string)
357+
if awsIAMTokenHost == "" {
358+
awsIAMTokenHost = host
359+
}
360+
360361
profile := d.Get("aws_rds_iam_profile").(string)
361362
region := d.Get("aws_rds_iam_region").(string)
362363
role := d.Get("aws_rds_iam_provider_role_arn").(string)
363364
var err error
364-
password, err = getRDSAuthToken(region, profile, role, username, host, port)
365+
password, err = getRDSAuthToken(region, profile, role, username, awsIAMTokenHost, port)
365366
if err != nil {
366367
return nil, err
367368
}
@@ -382,7 +383,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
382383
config := Config{
383384
Scheme: d.Get("scheme").(string),
384385
Host: host,
385-
ConnectionHost: connectionHost,
386+
AWSIAMDBAuthTokenHost: awsIAMTokenHost,
386387
Port: port,
387388
Username: username,
388389
Password: password,

0 commit comments

Comments
 (0)