-
Notifications
You must be signed in to change notification settings - Fork 258
Add extra connection host for AWS RDS IAM token #489
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
Open
sichenzhao
wants to merge
6
commits into
cyrilgdn:main
Choose a base branch
from
sichenzhao:connection_host
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6da51a3
add connection host
sichenzhao 43d5e8d
Merge branch 'main' into connection_host
cyrilgdn bc9e0c3
update for comments
ba3d079
Update config.go
sichenzhao 40eb932
Update provider.go
sichenzhao 72dd06e
Merge branch 'main' into connection_host
sichenzhao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,10 @@ package postgresql | |
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/aws/aws-sdk-go-v2/credentials" | ||
"github.com/aws/aws-sdk-go-v2/service/sts" | ||
"os" | ||
|
||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity" | ||
|
@@ -43,7 +44,7 @@ func Provider() *schema.Provider { | |
Type: schema.TypeString, | ||
Optional: true, | ||
DefaultFunc: schema.EnvDefaultFunc("PGHOST", nil), | ||
Description: "Name of PostgreSQL server address to connect to", | ||
Description: "Name of PostgreSQL server address", | ||
|
||
}, | ||
"port": { | ||
Type: schema.TypeInt, | ||
|
@@ -99,6 +100,13 @@ func Provider() *schema.Provider { | |
Description: "AWS IAM role to assume for IAM auth", | ||
}, | ||
|
||
"aws_rds_iam_token_host": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
DefaultFunc: schema.EnvDefaultFunc("PGHOST", nil), | ||
Description: "Name of PostgreSQL server address for AWS RDS IAM to get token", | ||
}, | ||
|
||
"azure_identity_auth": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
|
@@ -345,11 +353,16 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) { | |
|
||
var password string | ||
if d.Get("aws_rds_iam_auth").(bool) { | ||
awsIAMTokenHost := d.Get("aws_rds_iam_token_host").(string) | ||
if awsIAMTokenHost == "" { | ||
awsIAMTokenHost = host | ||
} | ||
|
||
profile := d.Get("aws_rds_iam_profile").(string) | ||
region := d.Get("aws_rds_iam_region").(string) | ||
role := d.Get("aws_rds_iam_provider_role_arn").(string) | ||
var err error | ||
password, err = getRDSAuthToken(region, profile, role, username, host, port) | ||
password, err = getRDSAuthToken(region, profile, role, username, awsIAMTokenHost, port) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -370,6 +383,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) { | |
config := Config{ | ||
Scheme: d.Get("scheme").(string), | ||
Host: host, | ||
AWSIAMDBAuthTokenHost: awsIAMTokenHost, | ||
Port: port, | ||
Username: username, | ||
Password: password, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.