@abtnode/util
Advanced tools
Comparing version 1.2.5 to 1.2.6
@@ -132,2 +132,4 @@ const NODE_SERVICES = Object.freeze({ | ||
NODE_OWNERSHIP_NFT_TYPE: 'NodeOwnershipCredential', | ||
NODE_PACKAGE_NAME: '@abtnode/cli', | ||
@@ -200,3 +202,3 @@ NODE_COMMAND_NAME: 'abtnode', | ||
RBAC_CONFIG, | ||
genPermissionName: (name, action = 'access') => `${action}_${name.replace('_', '-')}`, // resource name cannot include '_' | ||
genPermissionName: (resource, action = 'access') => `${action}_${resource.replace('_', '-')}`, // resource cannot include '_' | ||
@@ -203,0 +205,0 @@ // Service |
const axios = require('axios'); | ||
const debug = require('debug')('get-ec2-meta'); | ||
const HOST = 'http://169.254.169.254/latest'; | ||
// Link: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html | ||
const getEc2Meta = async (key, timeout) => { | ||
// Link: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-add-user-data.html | ||
const getEc2Meta = async (key, timeout = 5000) => { | ||
const url = key === 'user-data' ? `${HOST}/${key}` : `${HOST}/meta-data/${key}`; | ||
try { | ||
const result = await axios.get(`http://169.254.169.254/latest/meta-data/${key}`, { timeout }); | ||
const result = await axios.get(url, { timeout }); | ||
debug('get ec2 meta', { key, status: result.status, data: result.data }); | ||
@@ -15,3 +20,3 @@ if (result.status === 200) { | ||
} catch (err) { | ||
debug('Failed to fetch EC2 instance public host', err.message); | ||
debug('Failed to fetch ec2 meta', err.message); | ||
return ''; | ||
@@ -18,0 +23,0 @@ } |
@@ -6,2 +6,2 @@ const os = require('os'); | ||
module.exports = (folderName = '') => path.join(os.tmpdir(), TMP_FOLDER_NAME, folderName || 'tmp'); | ||
module.exports = (folderName = '') => path.join(os.tmpdir(), TMP_FOLDER_NAME, String(folderName) || 'tmp'); |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "1.2.5", | ||
"version": "1.2.6", | ||
"description": "ArcBlock's JavaScript utility", | ||
@@ -23,2 +23,3 @@ "main": "lib/index.js", | ||
"axios": "^0.21.1", | ||
"axios-mock-adapter": "^1.19.0", | ||
"debug": "^4.3.1", | ||
@@ -48,3 +49,3 @@ "find-up": "^5.0.0", | ||
}, | ||
"gitHead": "c531638f0b07f849289c4dfc08eb5c7cec305319" | ||
"gitHead": "94358acf5115757a1f9d46239e9c5c33282ea168" | ||
} |
27295
790
19
+ Addedaxios-mock-adapter@^1.19.0
+ Addedaxios-mock-adapter@1.22.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedis-buffer@2.0.5(transitive)