Skip to content
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

IAM authentication method for redshift adapter #769

Closed
wants to merge 3 commits into from

Conversation

danielchalef
Copy link
Contributor

Per #757 :
A method value is now required in a profile using the redshift adapter.

Copy link
Contributor

@drewbanin drewbanin left a comment

Choose a reason for hiding this comment

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

This is super cool, thanks for opening this PR @danielchalef! I dropped some comments in here, happy to discuss!

@@ -24,6 +23,18 @@
Required('schema'): basestring,
})

redshift_auth_methods = ['database', 'iam']
redshift_credentials_contract = Schema({
Required('method'): Any(*redshift_auth_methods),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be optional, and the default should be database. It would be good to preserve backwards compatibility here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Roger that. It would be great to require a password if the method keyword is missing or the database method is selected. Similarly, for cluster_id if the iam method is used. How do I go about doing so with voluptuous?

Copy link
Contributor

Choose a reason for hiding this comment

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

We're in the process of ripping out voluptuous and replacing it with json schemas as a part of building out dbt's API. I think you can just leave the voluptuous code here and we'll convert it to the new style contract along with everything else

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it.

return (result)

elif method == 'iam':
cluster_id = result.get('cluster_id')
Copy link
Contributor

Choose a reason for hiding this comment

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

can you slide the logic in this else branch into a different function? I think get_redshift_credentials should return a dict that looks like

{
  "dbname": "...",
  "user": "...",
  "pass": "...",
  "port": "..."
}

regardless of if the auth method is credentials or IAM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

result = connection.copy()

try:
credentials = cls.get_redshift_credentials(connection.get('credentials', {}))
Copy link
Contributor

Choose a reason for hiding this comment

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

the suggestion above about get_redshift_credentials should clean up the if/else logic here I believe!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@drewbanin
Copy link
Contributor

hey @danielchalef - thanks for your patience here. We changed some aspects of dbt's API since you opened this PR. Do you mind if I branch off of here and get it up-to-date with development?

@danielchalef
Copy link
Contributor Author

@drewbanin No worries. Go for it. Thanks.

@drewbanin
Copy link
Contributor

Closing this in favor of #818, which integrates development and adds an iam_duration_seconds parameter

@drewbanin drewbanin closed this Jul 2, 2018
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.

2 participants