Repository: dbt-labs/dbt-core

Issue:
Adding IAM parameters to redshift adapter
### Describe the feature
I would the arguments to get_cluster_credentials to be added to the dbt profile configuration. In particular DbGroups to allow the temporary user to be added to a group and AutoCreate to allow auto creation of users that do not exist. 

### Describe alternatives you've considered
Since these are IAM specific configurations the only other alternative is to not use the temporary credentials.

### Additional context
This is a feature specifically for redshift users.

### Who will this benefit?
This feature will be useful for dbt users who want to use temporary and dynamic credentials with redshift. 



Discussion:
Thanks for making this issue @gfeldman! 

If you're interested in contributing a code change for this feature, the relevant code should be around here:
https://github.com/fishtown-analytics/dbt/blob/40839c79fcf1854942f8db44d1a2648bffe0a2ab/plugins/redshift/dbt/adapters/redshift/connections.py#L39-L57

and here https://github.com/fishtown-analytics/dbt/blob/40839c79fcf1854942f8db44d1a2648bffe0a2ab/plugins/redshift/dbt/adapters/redshift/connections.py#L87-L128

It sounds like we'll just need to state these two configs (`DbGroups` and `AutoCreate`) in the set of whitelisted RedshiftCredentials, then pass them through to [boto_client.get_cluster_credentials](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/redshift.html#Redshift.Client.get_cluster_credentials).

Resolving patch:
diff --git a/plugins/redshift/dbt/adapters/redshift/connections.py b/plugins/redshift/dbt/adapters/redshift/connections.py
--- a/plugins/redshift/dbt/adapters/redshift/connections.py
+++ b/plugins/redshift/dbt/adapters/redshift/connections.py
@@ -14,7 +14,7 @@
 from hologram.helpers import StrEnum
 
 from dataclasses import dataclass, field
-from typing import Optional
+from typing import Optional, List
 
 drop_lock: Lock = dbt.flags.MP_CONTEXT.Lock()
 
@@ -47,6 +47,8 @@ class RedshiftCredentials(PostgresCredentials):
     iam_duration_seconds: int = 900
     search_path: Optional[str] = None
     keepalives_idle: int = 240
+    autocreate: bool = False
+    db_groups: List[str] = field(default_factory=list)
 
     @property
     def type(self):
@@ -85,7 +87,7 @@ def fresh_transaction(self, name=None):
 
     @classmethod
     def fetch_cluster_credentials(cls, db_user, db_name, cluster_id,
-                                  duration_s):
+                                  duration_s, autocreate, db_groups):
         """Fetches temporary login credentials from AWS. The specified user
         must already exist in the database, or else an error will occur"""
         boto_client = boto3.client('redshift')
@@ -96,7 +98,8 @@ def fetch_cluster_credentials(cls, db_user, db_name, cluster_id,
                 DbName=db_name,
                 ClusterIdentifier=cluster_id,
                 DurationSeconds=duration_s,
-                AutoCreate=False)
+                AutoCreate=autocreate,
+                DbGroups=db_groups,)
 
         except boto_client.exceptions.ClientError as e:
             raise dbt.exceptions.FailedToConnectException(
@@ -121,6 +124,8 @@ def get_tmp_iam_cluster_credentials(cls, credentials):
             credentials.database,
             credentials.cluster_id,
             iam_duration_s,
+            credentials.autocreate,
+            credentials.db_groups,
         )
 
         # replace username and password with temporary redshift credentials


Test patch:
diff --git a/test/unit/test_redshift_adapter.py b/test/unit/test_redshift_adapter.py
--- a/test/unit/test_redshift_adapter.py
+++ b/test/unit/test_redshift_adapter.py
@@ -96,6 +96,8 @@ def test_iam_conn_optionals(self):
                     'schema': 'public',
                     'method': 'iam',
                     'cluster_id': 'my_redshift',
+                    'db_groups': ["my_dbgroup"],
+                    'autocreate': True,
                 }
             },
             'target': 'test'