@@ -315,6 +315,8 @@ def get_redshift_temp_engine(
315315 user : str ,
316316 database : Optional [str ] = None ,
317317 duration : int = 900 ,
318+ auto_create : bool = True ,
319+ db_groups : Optional [List [str ]] = None ,
318320 boto3_session : Optional [boto3 .Session ] = None ,
319321) -> sqlalchemy .engine .Engine :
320322 """Get Glue connection details.
@@ -332,6 +334,12 @@ def get_redshift_temp_engine(
332334 The number of seconds until the returned temporary password expires.
333335 Constraint: minimum 900, maximum 3600.
334336 Default: 900
337+ auto_create : bool
338+ Create a database user with the name specified for the user named in user if one does not exist.
339+ db_groups: List[str], optinal
340+ A list of the names of existing database groups that the user named in DbUser will join for the current session,
341+ in addition to any group memberships for an existing user.
342+ If not specified, a new user is added only to PUBLIC.
335343 boto3_session : boto3.Session(), optional
336344 Boto3 Session. The default boto3 session will be used if boto3_session receive None.
337345
@@ -347,9 +355,15 @@ def get_redshift_temp_engine(
347355
348356 """
349357 client_redshift : boto3 .client = _utils .client (service_name = "redshift" , session = boto3_session )
350- res : Dict [str , Any ] = client_redshift .get_cluster_credentials (
351- DbUser = user , ClusterIdentifier = cluster_identifier , DurationSeconds = duration , AutoCreate = False
352- )
358+ args : Dict [str , Any ] = {
359+ "DbUser" : user ,
360+ "ClusterIdentifier" : cluster_identifier ,
361+ "DurationSeconds" : duration ,
362+ "AutoCreate" : auto_create ,
363+ }
364+ if db_groups is not None :
365+ args ["DbGroups" ] = db_groups
366+ res : Dict [str , Any ] = client_redshift .get_cluster_credentials (** args )
353367 _user : str = _quote_plus (res ["DbUser" ])
354368 password : str = _quote_plus (res ["DbPassword" ])
355369 cluster : Dict [str , Any ] = client_redshift .describe_clusters (ClusterIdentifier = cluster_identifier )["Clusters" ][0 ]
0 commit comments