How to use the Endpoint function from aws-sdk

Find comprehensive JavaScript aws-sdk.Endpoint code examples handpicked from public code repositorys.

aws-sdk.Endpoint is a constructor function in the AWS SDK for JavaScript that represents the endpoint URL of an AWS service.

21
22
23
24
25
26
27
28
29
30
// Use the MediaRegion property below in CreateMeeting to select the region
// the meeting is hosted in.
const chime = new AWS.Chime({ region: 'us-east-1' });

// Set the AWS SDK Chime endpoint. The global endpoint is https://service.chime.aws.amazon.com.
chime.endpoint = new AWS.Endpoint(process.env.ENDPOINT || 'https://service.chime.aws.amazon.com');

// Start an HTTP server to serve the index page and handle meeting actions
http.createServer({}, async (request, response) => {
  log(`${request.method} ${request.url} BEGIN`);
fork icon453
star icon641
watch icon59

8
9
10
11
12
13
14
15
16
17
18
19
    index: 'records',
    doctype: 'movie'
};


var creds = new AWS.EnvironmentCredentials('AWS');
var endpoint = new AWS.Endpoint(openSearchDomain.endpoint);


function postDocumentToOpenSearch(doc, context) {
    var req = new AWS.HttpRequest(endpoint);

fork icon201
star icon952
watch icon0

How does aws-sdk.Endpoint work?

aws-sdk.Endpoint is a constructor function provided by the AWS SDK for JavaScript that allows you to create an object representing an endpoint URL for an AWS service, which can be used to make requests to that service. When creating an endpoint object, you can specify the protocol, hostname, port, and service name, as well as any custom path prefix or query string parameters to include in requests to the service. Once you have created an Endpoint object, you can use it to instantiate an instance of the service client class for the desired AWS service, passing in any necessary configuration options.

8
9
10
11
12
13
14
15
16
17
18
19
    index: 'records',
    doctype: 'movie'
};


var creds = new AWS.EnvironmentCredentials('AWS');
var endpoint =  new AWS.Endpoint(esDomain.endpoint);


function postDocumentToES(doc, context) {
    var req = new AWS.HttpRequest(endpoint);

fork icon201
star icon952
watch icon0

20
21
22
23
24
25
26
27
28
29
30
// Use the MediaRegion property below in CreateMeeting to select the region
// the meeting is hosted in.
const chime = new AWS.Chime({ region: 'us-east-1' });
const ivs = new AWS.IVS({ apiVersion: '2020-07-14' });
// Set the AWS SDK Chime endpoint. The Chime endpoint is https://service.chime.aws.amazon.com.
chime.endpoint = new AWS.Endpoint(endpoint);


const chimeSDKMeetings = new AWS.ChimeSDKMeetings({region: currentRegion});
if (chimeSDKMeetingsEndpoint != 'https://service.chime.aws.amazon.com' && useChimeSDKMeetings === 'true'){
  chimeSDKMeetings.endpoint = new AWS.Endpoint(chimeSDKMeetingsEndpoint);
fork icon450
star icon638
watch icon0

+ 17 other calls in file

Ai Example

1
2
3
4
5
6
7
const { Endpoint } = require("aws-sdk");

const endpoint = new Endpoint("https://my-endpoint-url.com");

console.log(endpoint.hostname); // Output: my-endpoint-url.com
console.log(endpoint.protocol); // Output: https:
console.log(endpoint.port); // Output: null

In this example, we first import the Endpoint class from the aws-sdk module. Then, we create a new Endpoint object by passing the endpoint URL as a parameter to the constructor. We can then access various properties of the endpoint object, such as hostname, protocol, and port, to get information about the endpoint.

51
52
53
54
55
56
57
58
59
60
      port = ':' + port;
    }
    endpoint = protocol + endpoint + port;
  }
  options.params = options.params || {};
  options.params.endpoint = options.params.endpoint || new AWS.Endpoint(endpoint);
}

// this is to support the knox style attribute OR AWS s3ForcePathStyle attribute
if (options.style && (options.style === 'path')) {
fork icon31
star icon47
watch icon13

43
44
45
46
47
48
49
50
51
52
53
54
 */
function sendDocument(httpMethod, path, document, securitytenant, filename) {
  return new Promise(function (resolve, reject) {
    console.log({ httpMethod, path, document });


    var endpoint = new AWS.Endpoint(domain);
    var request = new AWS.HttpRequest(endpoint, region);


    // if this is a kibana request
    // add a xsrf header
fork icon2
star icon4
watch icon0

46
47
48
49
50
51
52
53
54
55
};

if (esAws) {
  // TODO: Grab region from env-vars
  const region = 'us-east-2';
  var endpoint = new AWS.Endpoint(esEndpoint);
  var aws_request = new AWS.HttpRequest(endpoint, region);

  aws_request.method = 'POST';
  aws_request.path = path.join(aws_request.path, 'segment', '_search');
fork icon1
star icon0
watch icon0

18
19
20
21
22
23
24
25
26
27
28
29
function getBook(id, error, success) { indexDocument('GET', id, null, error, success) }
function putBook(id, json) { indexDocument('PUT', id, json) }
function postBook(id, json) { indexDocument('POST', id, json) }


function indexDocument(method, id, document, errorCallback, successCallback) {
  var endpoint = new AWS.Endpoint(DOMAIN);
  var request = new AWS.HttpRequest(endpoint, REGION);


  if(request.method != "GET"){
    request.body = JSON.stringify(document);
fork icon1
star icon0
watch icon0

3
4
5
6
7
8
9
10
11
12
13
const sharp = require("sharp");
const aws = require("aws-sdk");
const { nanoid } = require("nanoid");
const productServices = require("./productServices");


const spacesEndpoint = new aws.Endpoint(process.env.PRIVATE_BUCKET_URL);
const s3 = new aws.S3({
  endpoint: spacesEndpoint,
  accessKeyId: process.env.DO_ACCESS_KEY,
  secretAccessKey: process.env.DO_ACCESS_SECRET,
fork icon0
star icon3
watch icon1

+ 34 other calls in file

3
4
5
6
7
8
9
10
11
12
13
14
var domain = 'search-movies-YOUR_MOVIES_DOMAIN_ID_HERE.us-east-1.es.amazonaws.com'; // e.g. search-domain-xxxxxxxxxxxx.region.es.amazonaws.com
var index = 'movies';
var type = '_search';


exports.lambdaHandler = (event, context, callback) => {
	let endpoint = new AWS.Endpoint(domain);
	let request = new AWS.HttpRequest(endpoint);
	// let credentials = new AWS.EnvironmentCredentials('AWS');


	let query = {
fork icon0
star icon1
watch icon0

26
27
28
29
30
31
32
33
34
35
36
//     cb(undefined, true);
//   },
// });


//"fra1.digitaloceanspaces.com"
const spacesEndpoint = new aws.Endpoint(process.env.SPACE_ENDPOINT);
const s3 = new aws.S3({
  endpoint: spacesEndpoint,
  accessKeyId: process.env.ACCESS_KEY,
  secretAccessKey: process.env.SECRET_ACCESS_KEY,
fork icon1
star icon0
watch icon3

+ 11 other calls in file

0
1
2
3
4
5
6
7
8
9
10
const AWS = require('aws-sdk');
const { v4: uuidv4 } = require('uuid');
var S3 = require('aws-sdk/clients/s3');
const bucketName = 'admin-order';
require('dotenv').config();
const wasabiEndpoint = new AWS.Endpoint('s3.ap-northeast-1.wasabisys.com');


let removeUnicode = (str) => {
    return str
        .normalize('NFD')
fork icon0
star icon0
watch icon1

+ 9 other calls in file

42
43
44
45
46
47
48
49
50
51
52
// currently must be configured to us-east-1, however the actual region where the
// meetings are hosted can be configured when invoking Chime.createMeeting
const chime = new AWS.Chime({region: 'us-east-1'});
const mediaPipeLineInit = new AWS.ChimeSDKMediaPipelines({region: 'us-east-1'});


chime.endpoint = new AWS.Endpoint('https://service.chime.aws.amazon.com/console');
mediaPipeLineInit.endpoint = new AWS.Endpoint('https://service.chime.aws.amazon.com/console');
const sts = new AWS.STS({region: 'us-east-1'})
console.log('STS: __________________________________', sts)

fork icon0
star icon0
watch icon1

+ 9 other calls in file

28
29
30
31
32
33
34
35
36
37
});

const s3 = new aws.S3({
  apiVersion: '2006-03-01',
  // If you want to specify a different endpoint, such as using DigitalOcean spaces
  // endpoint: new aws.Endpoint("nyc3.digitaloceanspaces.com"),
});

const stream = fs.createReadStream(filePath);
stream.on('error', (err) => {
fork icon0
star icon0
watch icon1

+ 17 other calls in file

15
16
17
18
19
20
21
22
23
24
25
26
const config = require('../config/db.config');


const Model = db.models;
const User = db.users;


const spacesEndpoint = new aws.Endpoint(process.env.BUCKET_ENDPOINT);
const s3 = new aws.S3({
  endpoint: spacesEndpoint,
  accessKeyId: process.env.BUCKET_KEY,
  secretAccessKey: process.env.BUCKET_SECRET
fork icon0
star icon0
watch icon1

+ 29 other calls in file

836
837
838
839
840
841
842
843
844
845
  ContactFlowId: context.state.config.connect.contactFlowId,
  InstanceId: context.state.config.connect.instanceId,
};

const uri = new URL(context.state.config.connect.apiGatewayEndpoint);
const endpoint = new AWS.Endpoint(uri.hostname);
const req = new AWS.HttpRequest(endpoint, context.state.config.region);
req.method = 'POST';
req.path = uri.pathname;
req.headers['Content-Type'] = 'application/json';
fork icon0
star icon0
watch icon1

+ 33 other calls in file

531
532
533
534
535
536
537
538
539
540
// let text = await this.pdf_to_json(filePath);
// text = text.replaceAll('\n', ' ');

const fileName = `DO_PDF_${random_6_digit_number}.pdf`

const spacesEndpoint = new aws.Endpoint('fra1.digitaloceanspaces.com')
const s3 = new aws.S3({
  endpoint: spacesEndpoint,
  accessKeyId: process.env.AWSACCESSKEYID,
  secretAccessKey: process.env.SECRETACCESSKEY,
fork icon0
star icon0
watch icon1

+ 44 other calls in file

27
28
29
30
31
32
33
34
35
36
37
38
// ElasticSearch endpoint
console.log("esDomainVehicle Endpoint " + esDomainVehicle.endpoint);
const endpointVehicle = new AWS.Endpoint(esDomainVehicle.endpoint);


console.log("esDomainSavedSearch Endpoint " + esDomainSavedSearch.endpoint);
const endpointSearch = new AWS.Endpoint(esDomainSavedSearch.endpoint);


function error(err, callback) {
    var errorMessage = process.env.AWS_LAMBDA_FUNCTION_NAME + " Error: " + err;
    console.log(errorMessage);
fork icon0
star icon0
watch icon0

9
10
11
12
13
14
15
16
17
18
19
20
    },
  });
}


const dynamoDB = new AWS.DynamoDB.DocumentClient({
  endpoint: isLocal ? new AWS.Endpoint(`http://localhost:4566`) : undefined,
});


module.exports = {
  dynamoDB,
fork icon0
star icon0
watch icon1

+ 25 other calls in file