Node AWS SDK: Get Regions
It's important to provide the version number, otherwise if there's a new version, and you try to run this code without the API version, it's just not gonna work. I recommend also providing the region just in case. You can do it with environmental variables as well, but it's just more robust and more predictable if you also put it here.
Then, you can create parameters, such as different filters. For example region name, endpoint, etcetera. These parameters, they go to describe regions. To describe regions singularly to describe regions in AWS CLI. That will give you a list of regions. It's omnipotent, meaning it doesn't matter how many times you run it, it will not modify your environment. It's a safe procedure. That's why I picked it for our first example.
If you're not familiar with Node.js in Node.js we use call backs a lot because it's asynchronous environment. So describe regions uses a callback. The first argument, it's a parameter, but the second it's a function, which is a call back, and all code which you want to execute after that will go inside of the callback. For example, describe images, it's the function that I want to execute after the describe regions. That's why I put describe images after I put it inside of this callback.
And similarly I have the console log-in screen inside of describe images, and that's in its own callback. So how do you run your code? So you saved it in describe.js. You have the package.json, you have the library installed, which, by the way, would be in the folder named node_modules. Very easy, you just go into your terminal.
You go to the folder where you have that file describe.js and also you need to have that node_modules with aws-sdk inside of that node_modules folder. So you go into your terminal and just type "node describe.js" and that will run your Node script. There is no compilation, you don't need to compile anything. That will output you the regions. You can also take the code that I provide, the code for this course, which is in a folder named code, code/sdk. That's where you would find the describe.js.