From 0736ebf27de65ec799077085e0ac5ccb038244a7 Mon Sep 17 00:00:00 2001 From: mdeshmu Date: Thu, 20 Jul 2023 12:55:33 +0530 Subject: [PATCH 1/2] update AWS Athena and Redshift docs --- docs/docs/databases/athena.mdx | 7 ++---- docs/docs/databases/redshift.mdx | 43 +++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/docs/docs/databases/athena.mdx b/docs/docs/databases/athena.mdx index 55282d68adb9e..e22e5f932a526 100644 --- a/docs/docs/databases/athena.mdx +++ b/docs/docs/databases/athena.mdx @@ -33,10 +33,7 @@ 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":""}} ``` diff --git a/docs/docs/databases/redshift.mdx b/docs/docs/databases/redshift.mdx index 32997adefa85b..c4067f3ee401b 100644 --- a/docs/docs/databases/redshift.mdx +++ b/docs/docs/databases/redshift.mdx @@ -10,6 +10,8 @@ version: 1 The [sqlalchemy-redshift](https://pypi.org/project/sqlalchemy-redshift/) library is the recommended way to connect to Redshift through SQLAlchemy. +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 the following setting values to form the connection string: - **User Name**: userName @@ -18,8 +20,47 @@ You'll need to the following setting values to form the connection string: - **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://:@:5439/ ``` + + +### redshift_connector + +Here's what the SQLALCHEMY URI looks like: + +``` +redshift+redshift_connector://:@:5439/ +``` + + +#### Using IAM-based credentials with Redshift cluster: + +[Amazon redshift cluster](https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-clusters.html) also supports to generate 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 following arguments in Superset's redshift database connection UI under ADVANCED --> Others --> ENGINE PARAMETERS. + +``` +{"connect_args":{"iam":true,"database":"","cluster_identifier":"","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 following arguments in Superset's redshift database connection UI under ADVANCED --> Others --> ENGINE PARAMETERS. + +``` +{"connect_args":{"iam":true,"is_serverless":true,"serverless_acct_id":"","serverless_work_group":"","database":"","user":"IAMR:"}} +``` From 5019c28fad9b6719b83981d9dc8bac41c1d69d90 Mon Sep 17 00:00:00 2001 From: Multazim Deshmukh Date: Mon, 24 Jul 2023 07:52:16 +0530 Subject: [PATCH 2/2] address pr comments --- docs/docs/databases/athena.mdx | 2 +- docs/docs/databases/redshift.mdx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/docs/databases/athena.mdx b/docs/docs/databases/athena.mdx index e22e5f932a526..9e4493d9a0a48 100644 --- a/docs/docs/databases/athena.mdx +++ b/docs/docs/databases/athena.mdx @@ -26,7 +26,7 @@ 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: ``` diff --git a/docs/docs/databases/redshift.mdx b/docs/docs/databases/redshift.mdx index c4067f3ee401b..d4bf3e243330d 100644 --- a/docs/docs/databases/redshift.mdx +++ b/docs/docs/databases/redshift.mdx @@ -12,7 +12,7 @@ way to connect to Redshift through SQLAlchemy. 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 the following setting values to form the connection string: +You'll need to set the following values to form the connection string: - **User Name**: userName - **Password**: DBPassword @@ -41,11 +41,11 @@ redshift+redshift_connector://:@:5439/ Others --> ENGINE PARAMETERS. +You have to define the following arguments in Superset's redshift database connection UI under ADVANCED --> Others --> ENGINE PARAMETERS. ``` {"connect_args":{"iam":true,"database":"","cluster_identifier":"","db_user":""}} @@ -59,7 +59,7 @@ and SQLALCHEMY URI should be set to `redshift+redshift_connector://` Your superset app's IAM role should have `redshift-serverless:GetCredentials` and `redshift-serverless:GetWorkgroup` permissions on Redshift serverless workgroup. -You have to define following arguments in Superset's redshift database connection UI under ADVANCED --> Others --> ENGINE PARAMETERS. +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":"","serverless_work_group":"","database":"","user":"IAMR:"}}