Aws-sdk-js: RDSDataService is not working

Created on 23 Nov 2018  路  20Comments  路  Source: aws/aws-sdk-js

RDSDataService is not working, is not doing nothing no errors, no logs.

Running aws lambda node js:

var rdsDataService = new AWS.RDSDataService({apiVersion: '2018-08-01'});
    var params = {
        awsSecretStoreArn: 'arn:xxxxx', /* required */
        dbClusterOrInstanceArn: 'arn:xxxxxxx', /* required */
        sqlStatements: 'select * from Member' /* required */
    };
    rdsDataService.executeSql(params, function(err, data) {
        console.log("log1");
        if (err)   { console.log("log2"); console.log(err, err.stack);  }// an error occurred
        else     {   console.log("log3");console.log(data);          } // successful response
    });
    console.log('End executeSql');

More info:
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/RDSDataService.html#executeSql-property

service-api

Most helpful comment

@svenmilewski

Refer to Lambda Execution Environment and Available Libraries.

Lambda currently bundles 2.290.0, which does not have the RDSDataService included.

NPM has the latest version of the SDK.

You could manually bundle a current version of the SDK into your Lambda deployment package.

All 20 comments

@asyba

Thanks for opening this issue.

Do you have a default region configured?

No, it should use the default one.

@asyba

Which region is that?

The default from AWS.RDSDataService() class that are in the sdk, don't know what is , I guess is us-east-1.

The documentation doesn't say that region is a required field to use this service.

I guess the class is looking the "AWS_REGION" env variable if I didn't add one in the creation of RDSDataService()

Can you try setting the region to 'us-east-1' explicitly?

var rdsDataService = new AWS.RDSDataService({apiVersion: '2018-08-01', region: 'us-east-1'});

Okey now I got this error:

 BadRequestException: ERROR: invalid cluster id: arn:aws:rds:us-east-1:xxxxx:db:xxxxxtest
    at Object.extractError (/var/task/node_modules/aws-sdk/lib/protocol/json.js:48:27)
    at Request.extractError (/var/task/node_modules/aws-sdk/lib/protocol/rest_json.js:52:8)
    at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:683:14)
    at Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /var/task/node_modules/aws-sdk/lib/state_machine.js:26:10

Second: can you create a feature to develop to use by default "AWS_REGION", if region not present?
In Java SDK we have that feature.

Is your RDS a cluster? Or a single instance?

There is a similar issue here for a customer receiving the same error when using an instance ARN: https://github.com/aws/aws-sdk-ruby/issues/1922

is a Single instance (mysql).
and my secret manager where created with the template "Credentials for RDS database".

so is a bug like the other, ok

@asyba

Regarding your feature request, the region can be configured a number of ways, including from AWS_REGION environmental variable or from a shared config file:

Setting the AWS Region

But in Java SDK I can do this, without setting the region:

AmazonS3ClientBuilder.defaultClient()

I am using a cluster and maybe I am having the same issue. Setting the region manually didn't change anything. I am still getting

"errorMessage": "AWS.RDSDataService is not a constructor"

when using

new AWS.RDSDataService({apiVersion: '2018-08-01', region: 'us-east-1'});

in my AWS Lambda function.

Any ideas?

// EDIT:

When using the AWS-SDK via npm install it seems to work. Looks like the region's (us-east-1) isn't that up-to-date or am I going wrong?

@svenmilewski

Refer to Lambda Execution Environment and Available Libraries.

Lambda currently bundles 2.290.0, which does not have the RDSDataService included.

NPM has the latest version of the SDK.

You could manually bundle a current version of the SDK into your Lambda deployment package.

@srchase

Didn't know that page. Thanks. :-) Is there atypical cycle where the SDK is updated in the Lambda Environment?

@svenmilewski

Currently, there is not a set schedule.

Per Lambda's Best Practices, the SDKs are updated periodically.

Supplying a specific version of the SDK with your deployment package gives you full control over your dependencies.

@asyba

The Service Team has indicated that only Aurora Clusters and Serverless Aurora are supported at this time.

Please refer to this documentation:

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html

Note that the Data API is in beta for Aurora Serverless and is subject to change.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings