SageMaker NodeJS's SDK Is Not Locking The API Version
I am running some code in AWS Lambda that dynamically creates SageMaker models. I am locking Sagemaker's API version like so:
const sagemaker = new AWS.SageMaker({apiVersion: '2017-07-24'});
And here's the code to create the model:
await sagemaker.createModel({
ExecutionRoleArn: 'xxxxxx',
ModelName: sageMakerConfigId,
Containers: [{
Image: ecrUrl
}]
}).promise()
This code runs just fine locally with aws-sdk
on 2.418.0
.
However, when this code is deployed to Lambda, it doesn't work due to some validation errors upon creating the model:
- MissingRequiredParameter: Missing required key 'PrimaryContainer' in params
- UnexpectedParameter: Unexpected key 'Containers' found in params
Is anyone aware of existing bugs in the aws-sdk
for NodeJS using the SDK provided by AWS in the Lambda context? I believe the SDK available inside AWS Lambda is more up-to-date than 2.418.0
but apparently there are compatibility issues.
Answer
As you've noticed the 'embedded' lambda version of the aws-sdk lags behind. It's actually on 2.290.0
(you can see the full details on the environment here: https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html)
You can see here: https://github.com/aws/aws-sdk-js/blame/master/clients/sagemaker.d.ts that it is not until 2.366.0
that the params for this method included Containers
and did not require PrimaryContainer
.
As you've noted, the workaround is to deploy your lambda with the aws-sdk
version that you're using. This is sometimes noted as a best practice, as it pins the aws-sdk
on the functionality you've built and tested against.
Related Questions
- → Maximum call stack exceeded when instantiating class inside of a module
- → Browserify api: how to pass advanced option to script
- → Node.js Passing object from server.js to external modules?
- → gulp-rename makes copies, but does not replace
- → requiring RX.js in node.js
- → Remove an ObjectId from an array of objectId
- → Can not connect to Redis
- → React: How to publish page on server using React-starter-kit
- → Express - better pattern for passing data between middleware functions
- → Can't get plotly + node.js to stream data coming through POST requests
- → IsGenerator implementation
- → Async/Await not waiting
- → (Socket.io on nodejs) Updating div with mysql data stops without showing error