Skip to content

Commit

Permalink
incorporate feedback from pr #630
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Apr 23, 2024
1 parent b8e2185 commit f4e7e21
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions dbt/adapters/redshift/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_message(self) -> str:
class RedshiftConnectionMethod(StrEnum):
DATABASE = "database"
IAM = "iam"
IAMR = "iamr"
IAM_ROLE = "iam_role"


class UserSSLMode(StrEnum):
Expand Down Expand Up @@ -215,7 +215,7 @@ def connect():
raise FailedToConnectError("'user' field is required for 'iam' credentials")

def connect():
logger.debug("Connecting to redshift with IAM based auth...")
logger.debug("Connecting to redshift with IAM User based auth...")
c = redshift_connector.connect(
iam=True,
db_user=self.credentials.user,
Expand All @@ -231,15 +231,18 @@ def connect():
c.cursor().execute("set role {}".format(self.credentials.role))
return c

elif method == RedshiftConnectionMethod.IAMR:
elif method == RedshiftConnectionMethod.IAM_ROLE:
if not self.credentials.cluster_id and "serverless" not in self.credentials.host:
raise FailedToConnectError(
"Failed to use IAM method. 'cluster_id' must be provided for provisioned cluster. "
"Failed to use IAM Role method. 'cluster_id' must be provided for provisioned cluster. "
"'host' must be provided for serverless endpoint."
)

if self.credentials.user is None:
raise FailedToConnectError("'user' field is required for 'iam' credentials")

def connect():
logger.debug("Connecting to redshift with IAM based auth...")
logger.debug("Connecting to redshift with IAM Role based auth...")
c = redshift_connector.connect(
iam=True,
cluster_identifier=self.credentials.cluster_id,
Expand Down
4 changes: 2 additions & 2 deletions dbt/include/redshift/profile_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ prompts:
hide_input: true
iam:
_fixed_method: iam
iamr:
_fixed_method: iamr
iam_role:
_fixed_method: iam_role
dbname:
hint: 'default database that dbt will build objects in'
schema:
Expand Down

0 comments on commit f4e7e21

Please sign in to comment.