This Node.js code example shows:
- How to retrieve your account-specific endpoint from MediaConvert.
In this example, you use a Node.js module to call MediaConvert and retrieve your account-specific endpoint. You can retrieve your endpoint URL from the service default endpoint and so do not yet need your acccount-specific endpoint. The code uses the SDK for JavaScript to retrieve this endpoint by using this method of the MediaConvert client class:
- https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/MediaConvert.html#describeEndpoints-property
To set up and run this example, first complete these tasks:
- Install Node.js. For more information, see the Node.js website.
- Create a shared configurations file with your user credentials. For more information about providing a shared credentials file, see Loading Credentials in Node.js from the Shared Credentials File.
- Create an IAM role that gives MediaConvert access to your input files and the Amazon S3 buckets where your output files are stored. For details, see Set Up IAM Permissions in the AWS Elemental MediaConvert User Guide.
Configure the SDK for JavaScript by creating a global configuration object, and then setting the region for your code. In this example, the region is set to us-west-2
.
// Load the SDK for JavaScript
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'us-west-2'});
Create a Node.js module with the file name emc_getendpoint.js
. Be sure to configure the SDK as previously shown.
Create an object to pass the empty request parameters for the describeEndpoints
method of the AWS.MediaConvert client class. To call the describeEndpoints
method, create a promise for invoking an MediaConvert service object, passing the parameters. Handle the response in the promise callback.
// Load the SDK for JavaScript
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'us-west-2'});
// Create empty request parameters
var params = {
MaxResults: 0,
};
// Create a promise on a MediaConvert object
var endpointPromise = new AWS.MediaConvert({apiVersion: '2017-08-29'}).describeEndpoints(params).promise();
endpointPromise.then(
function(data) {
console.log("Your MediaConvert endpoint is ", data.Endpoints);
},
function(err) {
console.log("Error", err);
}
);
To run the example, type the following at the command line.
node emc_getendpoint.js
This sample code can be found here on GitHub.