AWS Javascript API

Does anyone have an example of calling an Amazon Javascript API for instance the cloudformation API to get stackevents?

How do you load the javascript library for sdk? How do you provide authentication into AWS?

There are AWS resources available for you to authenticate and there several operations built in to Retool. Go to Resources and set up an AWS resource. There’s plenty of documentation. Once youre set up and can can connect I would suggest you then post your specific need.
https://docs.retool.com/docs/s3-integration-1

Can I add a +1 to this request/question? I'm trying to list out all subnets in a VPC. How do I load the libraries required?

1 Like

Hi @dgoodbourn

Thanks for checking in here. You should be able to import the library as long as it is available over a CDN: https://docs.retool.com/docs/custom-js-code#custom-javascript-libraries--npm-modules

Have you tried this method yet? Let me know if you run into blockers

Hi @Tess

I have tried this but as I'm a noob with JS I'm having a problem with it. I've got them loaded here

libraries

And with some simple code I get an error when trying to define the object with

var AWS = require("aws-sdk");

I get the error

message:"Module name "aws-sdk" has not been loaded yet for context: _. Use require([])
http://requirejs.org/docs/errors.html#notloaded"

So I tried

var AWS = require(["aws-sdk"]);

Which I think helped but now when I run

AWS.config.update(
  {
    region: 'eu-west-1',
    accessKeyId: ******,
    secretAccessKey: *****
  }
)

I get the error

message:"Cannot read properties of undefined (reading 'update')"

Feels like something's not quite right.
In a nodeJS dev env on my machine this all works.

Any help would be magic

Sorry scrap this, after re-re-reading your docs, I just needed to NOT declare the var AWS as it's automatically declared. :frowning:

Dave.

1 Like

Yes, exactly! :+1:

Hm. I'm trying the same thing but getting failures as well:



How is the module supposed to be loaded? Where are we supposed to find the variable it's defined as?

I didn't have to add the library, it was already available in the libraries panel:
image

Hi @ttsunrun

Thanks for reaching out! For connecting external libraries, you won't ever need to import or require them. Once you add the library link to the "Libraries" section (along with links for any dependencies), you should be able to use the code directly without having to define any variables. Typically, if we see errors about variables that should be defined by the library, it implies that the library isn't compatible with Retool.

I'd recommend trying the link mentioned here instead. I'm not too familiar with this sdk, so apologies if this isn't quite what you're looking for, but this appears to work :crossed_fingers::

Hope this helps!!