Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions redshift/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,21 +163,16 @@ func resolveCredentials(d *schema.ResourceData) (string, string, error) {
if (!ok) || username == nil {
return "", "", fmt.Errorf("Username is required")
}
password, passwordIsSet := d.GetOk("password")
_, clusterIdentifierIsSet := d.GetOk("temporary_credentials.0.cluster_identifier")
if !passwordIsSet && !clusterIdentifierIsSet {
return "", "", fmt.Errorf("password or temporary_credentials must be configured")
if _, useTemporaryCredentials := d.GetOk("temporary_credentials.0"); useTemporaryCredentials {
log.Println("[DEBUG] using temporary credentials authentication")
dbUser, dbPassword, err := temporaryCredentials(username.(string), d)
log.Printf("[DEBUG] got temporary credentials with username %s\n", dbUser)
return dbUser, dbPassword, err
}
if passwordIsSet {
if password.(string) != "" {
log.Println("[DEBUG] using password authentication")
return username.(string), password.(string), nil
}
}
log.Println("[DEBUG] using temporary credentials authentication")
dbUser, dbPassword, err := temporaryCredentials(username.(string), d)
log.Printf("[DEBUG] got temporary credentials with username %s\n", dbUser)
return dbUser, dbPassword, err

password, _ := d.GetOk("password")
log.Println("[DEBUG] using password authentication")
return username.(string), password.(string), nil
}

// temporaryCredentials gets temporary credentials using GetClusterCredentials
Expand Down