Hi All,
There have been some recent messages popup around the depreciation of 3rd party services such as AWS and Twilio. I think this is going to cause people a lot of confusion so I would advise MongoDB to add some examples of using the AWS package as a dependency.
In my projects across multiple clients, I have utilised the 3rd party AWS service to do lots of things such as S3, SQS, SFN, SNS. I have therefore just explored how to implement this change.
The example below gives a sort of “hello world” on how to get the AWS SDK working.
The access key and secret are stored in realm using the secrets and values area.
The installed aws-sdk package is v2.737.0. More recent ones don’t seem to work yet and I found this out from @Drew_DiPalma post HERE
exports = async function(){
// Load the AWS SDK for Node.js
const AWS = require('aws-sdk');
// Set the AWS config
AWS.config = new AWS.Config();
AWS.config.accessKeyId = context.values.get("AWS_ACCESS_KEY");
AWS.config.secretAccessKey = context.values.get("AWS_ACCESS_SECRET");
AWS.config.region = context.values.get("AWS_REGION");
// Create S3 service object
s3 = new AWS.S3({apiVersion: '2006-03-01'});
// Call S3 to list the buckets
const buckets = await s3.listBuckets().promise()
return buckets
};
One thing I would like to know from the MongoDB realm team is what sort of overhead is this going to add to our functions? Is it going to slow them down considerably if we need to load in the AWS SDK? The 3rd party services worked well in my opinion and didn’t really add any overhead.
As I mentioned, it would be great if there could be some detailed documention with examples around these dependencies that people will be needing. Mainly around AWS and HTTP, so maybe an example of the library axios or node-fetch would be ideal.
Thanks