Skip to content

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
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sichenzhao
Copy link

@sichenzhao sichenzhao commented Nov 8, 2024

#317

Add a different aws_rds_iam_token_host parameter, so that we can use one hostname to get AWS RDS database token, and use another hostname when do psql connect.

@sichenzhao
Copy link
Author

@jcarvalho could you please take a look?

@sichenzhao
Copy link
Author

or shall I ping @cyrilgdn ?

@cyrilgdn
Copy link
Owner

@sichenzhao Seems good to me but even with the associated issue, I'm not sure I got the point of this? Could you just explain a bit more the use case please?

@sichenzhao
Copy link
Author

To explain, for people use tailscale for example, we will have different VPN hostname for postgresSQL connection. That's a different url than url AWS can take for AWS API related calls. Thus, people would benefit from this PR which gives an option to differ these two.

@sichenzhao
Copy link
Author

kindly ping @cyrilgdn to see if my answer above makes sense. Thank you!

Copy link

@danxmoran danxmoran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also interested in getting this feature merged and released!

I left a comment that might clarify the use case of the new parameter. I'd also be happy to submit an alternate PR if you've moved on from this @sichenzhao

DefaultFunc: schema.EnvDefaultFunc("PGHOST", nil),
Description: "Name of PostgreSQL server address",
},
"connection_host": {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also in need of this feature 😄

As a potential user, I think I would find the stated difference between host and connection_host a bit confusing. As far as I know, the problem we're trying to solve is specific to the RDS IAM auth. I think it'd be more clear if the new provider option was prefixed with aws_rds_iam_ like the other options below (i.e. aws_rds_iam_hostname). Then we could clearly document that it should be the internal hostname of the RDS instance, used to generate an IAM token, which might not be the same address used to connect to the instance if connecting over a VPN / tunnel

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reasonable comments! I am thinking about how I should update this PR.

IAM specific host is going to be the default host name though, and the connection host is the host through VPN/Tunnel. Not everyone uses VPN/Tunnel, but mostly every uses the host to get IAM token.

If I add a new IAM one, when not specified, we will use the default host to get the token, and when specified, we will use the default host to connect (VPN/Tunnel one), and use iam one to get the token. Sounds like a plan?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated!

@sichenzhao sichenzhao requested a review from danxmoran May 17, 2025 23:24
@sichenzhao sichenzhao changed the title Add extra connection host with default value as host Add extra connection host for AWS RDS IAM token May 17, 2025
Copy link

@danxmoran danxmoran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New option name and doc LGTM - would revert some of the unrelated changes 😄

@cyrilgdn what do you think of the latest changes? Does it make the use-case more clear?

@@ -248,7 +249,7 @@ func (c *Config) connParams() []string {
}

func (c *Config) connStr(database string) string {
host := c.Host
host = c.Host

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would revert this change, it must now be overwriting some top-level host variable

@@ -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",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would revert this change, I feel "to connect to" is useful in distinguishing the difference between the options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants