Search code examples
javascriptfirefoxfirefox-addonaws-sdk

How to use AWS JavaScript SDK in FireFox Addon (Extension)


I've written a very simple script that just logs the list of EC2 instances:

AWS.config.update({accessKeyId: 'id', secretAccessKey: 'secret', region: 'region'});
var ec2 = new AWS.EC2();
ec2.describeInstances({}, function(err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else     console.log(data);           // successful response
})

Added this script to an HTML file (with aws-sdk-2.409.0.js script). Everything works just fine. But when I use the same code in a FireFox extension I get:

NetworkingError: "Network Failure"
 handleRequest moz-extension://uuid/aws-sdk-2.409.0.js:155410 
 [300]</handleRequest/<@moz-extension://uuid/aws-sdk-2.409.0.js:155410:34

I googled and found some issues regarding CORS (all working with S3). Does anybody know how I can use AWS SDK in a FireFox extension to do simple stuff like listing EC2 instances, etc?


Solution

  • It was due to missing permissions entry in the manifest file of the extension:

      "permissions": [
        "https://*.amazonaws.com/*"
      ]