billdestein opened a new issue, #32315:
URL: https://github.com/apache/superset/issues/32315
### Bug description
I'd like to use the /v1/database API to create a connection to Athena and a
connection to Redshift Serverless..
I'm successfully creating the connection to Athena, but so far no luck with
Redshift.
My code, output, and log entries are pasted below.
I've made sure that the role AWSRedshiftServerlessProduct has permissions
redshift-serverless:GetCredentials and redshift-serverless:GetWorkgroup.
First question. How would I further troubleshoot?
Second question. For Athena I'm authenticating using temporary credentials
rather than a database user and password. I'd like to do the same for Redshift
Serverless. Is that possible?
Thank you!
>>> Code
def create_redshift_database_connection():
account_id = '012345678901'
cookie = '...'
csrf_token = '...'
password = 'ProductPassword123'
role_name = 'AWSRedshiftServerlessProduct'
username = 'ProductUser123'
work_group = 'product'
headers = {
'Accept': 'application/json',
'Cookie': cookie,
'Content-Type': 'application/json',
'X-CSRFToken': csrf_token
}
extra = {
"engine_params": {
"connect_args": {
"iam": True,
"is_serverless": True,
"serverless_acct_id": account_id,
"serverless_work_group": work_group,
"database": "dev",
"user":
f'IAMR:arn:aws:iam::{account_id}:role/{role_name}'
}
}
}
data = {
"sqlalchemy_uri":
f'redshift+redshift_connector://{username}:{password}@{work_group}.{account_id}.us-west-2.redshift-serverless.amazonaws.com:5439/dev',
"database_name":"Amazon Redshift",
"extra": json.dumps(extra),
"masked_encrypted_extra":""
}
url = 'http://127.0.0.1:37701/api/v1/database/'
response = requests.post(url, json = data, headers = headers)
print(f'reason: {response.reason}')
print(f'status_code: {response.status_code} ')
print(f'text: {response.text}')
create_redshift_database_connection()
>>> Output
print(f'reason: {response.reason}')
print(f'status_code: {response.status_code} ')
print(f'text: {response.text}')
>>> Log
1|welcome||{"path": "/superset/welcome/", "object_ref":
"Superset.welcome"}|2025-02-19 17:11:08.660717|0|0|0|
2|welcome|1|{"path": "/superset/welcome/", "object_ref":
"Superset.welcome"}|2025-02-19 17:11:08.854667|0|0|98|
3|DashboardRestApi.get_list|1|{"path": "/api/v1/dashboard/", "q":
"(filters:!((col:owners,opr:rel_m_m,value:'1')),order_column:changed_on_delta_humanized,order_direction:desc,page:0,page_size:5)",
"rison": {"filters": [{"col": "owners", "opr": "rel_m_m", "value": "1"}],
"order_column": "changed_on_delta_humanized", "order_direction": "desc",
"page": 0, "page_size": 5}}|2025-02-19
17:11:09.312433|0|0|152|http://127.0.0.1:37701/superset/welcome/
4|DatabaseRestApi.get_list|1|{"path": "/api/v1/database/", "q":
"(filters:!((col:database_name,opr:neq,value:examples)))", "rison": {"filters":
[{"col": "database_name", "opr": "neq", "value": "examples"}]}}|2025-02-19
17:11:09.323497|0|0|118|http://127.0.0.1:37701/superset/welcome/
5|LogRestApi.recent_activity|1|{"path": "/api/v1/log/recent_activity/", "q":
"(page_size:6)", "object_ref": "LogRestApi.recent_activity", "rison":
{"page_size": 6}}|2025-02-19
17:11:09.315883|0|0|117|http://127.0.0.1:37701/superset/welcome/
6|ChartRestApi.get_list|1|{"path": "/api/v1/chart/", "q":
"(filters:!((col:owners,opr:rel_m_m,value:'1')),order_column:changed_on_delta_humanized,order_direction:desc,page:0,page_size:5)",
"rison": {"filters": [{"col": "owners", "opr": "rel_m_m", "value": "1"}],
"order_column": "changed_on_delta_humanized", "order_direction": "desc",
"page": 0, "page_size": 5}}|2025-02-19
17:11:09.346345|0|0|181|http://127.0.0.1:37701/superset/welcome/
7|DatabaseRestApi.get_list|1|{"path": "/api/v1/database/", "q":
"(filters:!((col:allow_file_upload,opr:upload_is_enabled,value:!t)))", "rison":
{"filters": [{"col": "allow_file_upload", "opr": "upload_is_enabled", "value":
true}]}}|2025-02-19
17:11:09.315367|0|0|168|http://127.0.0.1:37701/superset/welcome/
8|DashboardRestApi.get_list|1|{"path": "/api/v1/dashboard/", "q":
"(filters:!(),order_column:changed_on_delta_humanized,order_direction:desc,page:0,page_size:5)",
"rison": {"filters": [], "order_column": "changed_on_delta_humanized",
"order_direction": "desc", "page": 0, "page_size": 5}}|2025-02-19
17:11:09.388497|0|0|28|http://127.0.0.1:37701/superset/welcome/
9|SavedQueryRestApi.get_list|1|{"path": "/api/v1/saved_query/", "q":
"(filters:!((col:created_by,opr:rel_o_m,value:'1')),order_column:changed_on_delta_humanized,order_direction:desc,page:0,page_size:5)",
"rison": {"filters": [{"col": "created_by", "opr": "rel_o_m", "value": "1"}],
"order_column": "changed_on_delta_humanized", "order_direction": "desc",
"page": 0, "page_size": 5}}|2025-02-19
17:11:09.317383|0|0|140|http://127.0.0.1:37701/superset/welcome/
10|ChartRestApi.get_list|1|{"path": "/api/v1/chart/", "q":
"(filters:!(),order_column:changed_on_delta_humanized,order_direction:desc,page:0,page_size:5)",
"rison": {"filters": [], "order_column": "changed_on_delta_humanized",
"order_direction": "desc", "page": 0, "page_size": 5}}|2025-02-19
17:11:09.408336|0|0|40|http://127.0.0.1:37701/superset/welcome/
11|ChartRestApi.info|1|{"path": "/api/v1/chart/_info", "q":
"(keys:!(permissions))", "rison": {"keys": ["permissions"]}}|2025-02-19
17:11:09.451496|0|0|3|http://127.0.0.1:37701/superset/welcome/
12|DashboardRestApi.info|1|{"path": "/api/v1/dashboard/_info", "q":
"(keys:!(permissions))", "rison": {"keys": ["permissions"]}}|2025-02-19
17:11:09.452490|0|0|6|http://127.0.0.1:37701/superset/welcome/
13|welcome|1|{"path": "/superset/welcome/", "object_ref":
"Superset.welcome"}|2025-02-19
17:11:10.254491|0|0|17|http://127.0.0.1:37701/superset/welcome/
14|test_connection_attempt|1|{"path": "/api/v1/database/", "sqlalchemy_uri":
"redshift+redshift_connector://ProductUser123:productpassword...@product.012345678901.us-west-2.redshift-serverless.amazonaws.com:5439/dev",
"database_name": "Amazon Redshift", "extra": "{\"engine_params\":
{\"connect_args\": {\"iam\": true, \"is_serverless\": true,
\"serverless_acct_id\": \"012345678901\", \"serverless_work_group\":
\"product\", \"database\": \"dev\", \"user\":
\"IAMR:arn:aws:iam::012345678901:role/AWSRedshiftServerlessProduct\"}}}",
"masked_encrypted_extra": "", "engine": "RedshiftEngineSpec"}|2025-02-19
17:26:32.589207|0|0||
15|test_connection_error.SupersetTimeoutException|1|{"path":
"/api/v1/database/", "sqlalchemy_uri":
"redshift+redshift_connector://ProductUser123:productpassword...@product.012345678901.us-west-2.redshift-serverless.amazonaws.com:5439/dev",
"database_name": "Amazon Redshift", "extra": "{\"engine_params\":
{\"connect_args\": {\"iam\": true, \"is_serverless\": true,
\"serverless_acct_id\": \"012345678901\", \"serverless_work_group\":
\"product\", \"database\": \"dev\", \"user\":
\"IAMR:arn:aws:iam::012345678901:role/AWSRedshiftServerlessProduct\"}}}",
"masked_encrypted_extra": "", "engine": "RedshiftEngineSpec"}|2025-02-19
17:27:02.725634|0|0||
16|db_creation_failed.SupersetTimeoutException|1|{"path":
"/api/v1/database/", "sqlalchemy_uri":
"redshift+redshift_connector://ProductUser123:productpassword...@product.012345678901.us-west-2.redshift-serverless.amazonaws.com:5439/dev",
"database_name": "Amazon Redshift", "extra": "{\"engine_params\":
{\"connect_args\": {\"iam\": true, \"is_serverless\": true,
\"serverless_acct_id\": \"012345678901\", \"serverless_work_group\":
\"product\", \"database\": \"dev\", \"user\":
\"IAMR:arn:aws:iam::012345678901:role/AWSRedshiftServerlessProduct\"}}}",
"masked_encrypted_extra": "", "engine":
"redshift+redshift_connector"}|2025-02-19 17:27:02.737655|0|0||
17|DatabaseRestApi.post|1|{"path": "/api/v1/database/", "sqlalchemy_uri":
"redshift+redshift_connector://ProductUser123:productpassword...@product.012345678901.us-west-2.redshift-serverless.amazonaws.com:5439/dev",
"database_name": "Amazon Redshift", "extra": "{\"engine_params\":
{\"connect_args\": {\"iam\": true, \"is_serverless\": true,
\"serverless_acct_id\": \"012345678901\", \"serverless_work_group\":
\"product\", \"database\": \"dev\", \"user\":
\"IAMR:arn:aws:iam::012345678901:role/AWSRedshiftServerlessProduct\"}}}",
"masked_encrypted_extra": "", "object_ref": "DatabaseRestApi.post"}|2025-02-19
17:27:02.745493|0|0|30159|
### Screenshots/recordings
_No response_
### Superset version
master / latest-dev
### Python version
3.9
### Node version
18 or greater
### Browser
Chrome
### Additional context
_No response_
### Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to
my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug
report.
- [x] I have checked Superset's logs for errors and if I found a relevant
Python stacktrace, I included it here as text in the "additional context"
section.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]