0

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?

Rad
  • 4,292
  • 8
  • 33
  • 71
  • might be useful: https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/cors.html – Joao Pereira Feb 25 '19 at 15:21
  • Checked that already. But it talks about CORS + S3. – Rad Feb 25 '19 at 16:06
  • Everything points out in that direction, including the [AWS SDK for JavaScript](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/) documentation. Perhaps this [thread](https://stackoverflow.com/questions/39835982/where-to-add-cors-headers-in-aws-ec2) is useful. – Joao Pereira Feb 25 '19 at 17:51
  • This is weird, because when I run it via the normal webpage, the response (which is successful) has `Access-Control-Allow-Origin: *`. – Rad Feb 26 '19 at 07:33

1 Answers1

1

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

  "permissions": [
    "https://*.amazonaws.com/*"
  ]
Rad
  • 4,292
  • 8
  • 33
  • 71