forked from dougmoscrop/aws-info-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaws-info.js
33 lines (22 loc) · 803 Bytes
/
aws-info.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
const data= require('./data.json');
const { services, regions } = data;
module.exports.data = data;
module.exports.endpoint = (serviceName, regionName) => {
const service = services[serviceName.toLowerCase()];
if (service) {
const endpoint = service.endpoints[regionName.toLowerCase()];
if (endpoint) {
return endpoint;
}
throw new Error(`aws-info: ${serviceName} has no known endpoints in ${regionName}`);
}
throw new Error(`aws-info: ${serviceName} is unknown`);
};
module.exports.regionName = (regionNameShort) => {
const region = regions[regionNameShort.toLowerCase()];
if (region) {
return region.name;
}
throw new Error(`aws-info: ${regionNameShort} is not a known region short name`);
};