Getting your account-specific endpoint for MediaConvert - AWS SDK for JavaScript

Help us improve the AWS SDK for JavaScript version 3 (V3) documentation by providing feedback using the Feedback link, or create an issue or pull request on GitHub.

The AWS SDK for JavaScript V3 API Reference Guide describes in detail all the API operations for the AWS SDK for JavaScript version 3 (V3).

Getting your account-specific endpoint for MediaConvert

JavaScript code example that applies to Node.js execution

This Node.js code example shows:

  • How to retrieve your account-specific endpoint from MediaConvert.

The scenario

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 account-specific endpoint. The code uses the SDK for JavaScript to retrieve this endpoint by using this method of the MediaConvert client class:

Prerequisite tasks

To set up and run this example, first complete these tasks:

  • Set up the project environment to run these Node TypeScript examples, and install the required AWS SDK for JavaScript and third-party modules. Follow the instructions on GitHub.

  • 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.

Important

This example uses ECMAScript6 (ES6). This requires Node.js version 13.x or higher. To download and install the latest version of Node.js, see Node.js downloads..

However, if you prefer to use CommonJS sytax, please refer to JavaScript ES6/CommonJS syntax

Getting your endpoint URL

Create a libs directory, and create a Node.js module with the file name emcClientGet.js. Copy and paste the code below into it, which creates the MediaConvert client object. Replace REGION with your AWS Region.

import { MediaConvertClient } from "@aws-sdk/client-mediaconvert"; // Set the AWS Region. const REGION = "REGION"; //Set the account end point. const ENDPOINT = { endpoint: "https://ENDPOINT_UNIQUE_STRING.mediaconvert.REGION.amazonaws.com" }; //Set the MediaConvert Service Object const emcClient = new MediaConvertClient(ENDPOINT); export { emcClient };

This example code can be found here on GitHub.

Create a Node.js module with the file name emc_getendpoint.js. Be sure to configure the SDK as previously shown, including installing the required clients and packages.

Create an object to pass the empty request parameters for the DescribeEndpointsCommand method of the MediaConvert client class. To call the DescribeEndpointsCommand method, create a promise for invoking an MediaConvert client service object, passing the parameters.

Note

Replace AMI_ID with the ID of the AMI to run, and KEY_PAIR_NAME of the key pair to assign to the AMI ID.

// Import required AWS-SDK clients and commands for Node.js import { DescribeEndpointsCommand } from "@aws-sdk/client-mediaconvert"; import { emcClientGet } from "./libs/emcClientGet.js"; //set the parameters const params = { MaxResults: 0 }; const run = async () => { try { // Load the required SDK for JavaScript modules // Create a new service object and set MediaConvert to customer endpoint const params = { MaxResults: 0 }; const data = await emcClientGet.send(new DescribeEndpointsCommand(params)); console.log("Your MediaConvert endpoint is ", data.Endpoints); return data; } catch (err) { console.log("Error", err); } }; run();

To run the example, enter the following at the command prompt.

node emc_getendpoint.js

This example code can be found here on GitHub.