Skip to content

Commit

Permalink
docs: update AWS Athena and Redshift docs (apache#24751)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeshmu authored Jul 24, 2023
1 parent 54e557a commit 0899119
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
9 changes: 3 additions & 6 deletions docs/docs/databases/athena.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@ s3://... -> s3%3A//...

### PyAthena

You can also use [PyAthena library](https://pypi.org/project/PyAthena/) (no Java required) with the
You can also use the [PyAthena library](https://pypi.org/project/PyAthena/) (no Java required) with the
following connection string:

```
awsathena+rest://{aws_access_key_id}:{aws_secret_access_key}@athena.{region_name}.amazonaws.com/{schema_name}?s3_staging_dir={s3_staging_dir}&...
```

The PyAthena library also allows to assume a specific IAM role, by [importing the datasource from YAML](https://superset.apache.org/docs/miscellaneous/importing-exporting-datasources/#importing-datasources-from-yaml) and passing extra parameters:
The PyAthena library also allows to assume a specific IAM role which you can define by adding following parameters in Superset's Athena database connection UI under ADVANCED --> Other --> ENGINE PARAMETERS.
```
databases:
- database_name: awsathena
sqlalchemy_uri: awsathena+rest://athena.{region_name}.amazonaws.com/{schema_name}?s3_staging_dir={s3_staging_dir}&...
extra: "{\"engine_params\": {\"connect_args\": {\"role_arn\": \"{{ ROLE_ARN }}\" }}}"
{"connect_args":{"role_arn":"<role arn>"}}
```
45 changes: 43 additions & 2 deletions docs/docs/databases/redshift.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,57 @@ version: 1
The [sqlalchemy-redshift](https://pypi.org/project/sqlalchemy-redshift/) library is the recommended
way to connect to Redshift through SQLAlchemy.

You'll need to the following setting values to form the connection string:
This dialect requires either [redshift_connector](https://pypi.org/project/redshift-connector/) or [psycopg2](https://pypi.org/project/psycopg2/) to work properly.

You'll need to set the following values to form the connection string:

- **User Name**: userName
- **Password**: DBPassword
- **Database Host**: AWS Endpoint
- **Database Name**: Database Name
- **Port**: default 5439

Here's what the connection string looks like:

### psycopg2

Here's what the SQLALCHEMY URI looks like:

```
redshift+psycopg2://<userName>:<DBPassword>@<AWS End Point>:5439/<Database Name>
```


### redshift_connector

Here's what the SQLALCHEMY URI looks like:

```
redshift+redshift_connector://<userName>:<DBPassword>@<AWS End Point>:5439/<Database Name>
```


#### Using IAM-based credentials with Redshift cluster:

[Amazon redshift cluster](https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-clusters.html) also supports generating temporary IAM-based database user credentials.

Your superset app's [IAM role should have permissions](https://docs.aws.amazon.com/redshift/latest/mgmt/generating-iam-credentials-role-permissions.html) to call the `redshift:GetClusterCredentials` operation.

You have to define the following arguments in Superset's redshift database connection UI under ADVANCED --> Others --> ENGINE PARAMETERS.

```
{"connect_args":{"iam":true,"database":"<database>","cluster_identifier":"<cluster_identifier>","db_user":"<db_user>"}}
```
and SQLALCHEMY URI should be set to `redshift+redshift_connector://`


#### Using IAM-based credentials with Redshift serverless:

[Redshift serverless](https://docs.aws.amazon.com/redshift/latest/mgmt/serverless-whatis.html) supports connection using IAM roles.

Your superset app's IAM role should have `redshift-serverless:GetCredentials` and `redshift-serverless:GetWorkgroup` permissions on Redshift serverless workgroup.

You have to define the following arguments in Superset's redshift database connection UI under ADVANCED --> Others --> ENGINE PARAMETERS.

```
{"connect_args":{"iam":true,"is_serverless":true,"serverless_acct_id":"<aws account number>","serverless_work_group":"<redshift work group>","database":"<database>","user":"IAMR:<superset iam role name>"}}
```

0 comments on commit 0899119

Please sign in to comment.