1

Been banging my head on this for a while now. I have an AWS Redshift Serverless Workspace set up. I have loaded data to a table and am able to query it using the AWS browser tool. Using the AWS CLI, I am able to get a successful query response as well.

aws redshift-data execute-statement --region us-west-2 --workgroup-name myworkgroup --database dev --sql "select * from users limit 1"

When I attempt to use the AWS SDK for dotnet to run ExecuteStatement, I receive an error:

An exception of type 'Amazon.RedshiftDataAPIService.Model.ValidationException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'Workgroup is currently not supported.'

Same in Python with boto3:

An error occurred (ValidationException) when calling the ExecuteStatement operation: Workgroup is currently not supported.

My C# console app is simply this:

using Amazon.RedshiftDataAPIService;


var client = new AmazonRedshiftDataAPIServiceClient();
var request = new Amazon.RedshiftDataAPIService.Model.ExecuteStatementRequest();
request.ClusterIdentifier = "mycluster";
request.WorkgroupName = "myworkgroup";
request.Database = "dev";
request.DbUser = "admin";
request.Sql = "select * from users limit 1";
await client.ExecuteStatementAsync(request);

I feel like I'm missing something and in my setup of the serverless that allows the DataAPI to query it?

reenrik
  • 51
  • 9

1 Answers1

1

Coming back to provide an answer...it was the AWS region.

  1. My test code in dotnet above had two problems. ClusterIdentifier and DbUser should not be used when making a request to the RedshiftDataAPI for Serverless Redshift.
  2. My Redshift Serverless was in the us-west-2 region and I didn't set my region when creating the client.

Updated working sample snippet for whomever needs it!

using Amazon.RedshiftDataAPIService;

var client = new AmazonRedshiftDataAPIServiceClient(region: Amazon.RegionEndpoint.USWest2)
var request = new Amazon.RedshiftDataAPIService.Model.ExecuteStatementRequest();
request.WorkgroupName = "myworkgroup";
request.Database = "dev";
request.Sql = "select * from users limit 1";
var usersResp = await client.ExecuteStatementAsync(request);
var resultReq = new Amazon.RedshiftDataAPIService.Model.GetStatementResultRequest();
resultReq.Id = usersResp.Id;
var users = await client.GetStatementResultAsync(resultReq);
reenrik
  • 51
  • 9