Backend half
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
var getEndpoint = function() {
|
||||
return {
|
||||
IPv4: 'http://169.254.169.254',
|
||||
IPv6: 'http://[fd00:ec2::254]',
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = getEndpoint;
|
||||
Generated
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
var ENV_ENDPOINT_NAME = 'AWS_EC2_METADATA_SERVICE_ENDPOINT';
|
||||
var CONFIG_ENDPOINT_NAME = 'ec2_metadata_service_endpoint';
|
||||
|
||||
var getEndpointConfigOptions = function() {
|
||||
return {
|
||||
environmentVariableSelector: function(env) { return env[ENV_ENDPOINT_NAME]; },
|
||||
configFileSelector: function(profile) { return profile[CONFIG_ENDPOINT_NAME]; },
|
||||
default: undefined,
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = getEndpointConfigOptions;
|
||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
var getEndpointMode = function() {
|
||||
return {
|
||||
IPv4: 'IPv4',
|
||||
IPv6: 'IPv6',
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = getEndpointMode;
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
var EndpointMode = require('./get_endpoint_mode')();
|
||||
|
||||
var ENV_ENDPOINT_MODE_NAME = 'AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE';
|
||||
var CONFIG_ENDPOINT_MODE_NAME = 'ec2_metadata_service_endpoint_mode';
|
||||
|
||||
var getEndpointModeConfigOptions = function() {
|
||||
return {
|
||||
environmentVariableSelector: function(env) { return env[ENV_ENDPOINT_MODE_NAME]; },
|
||||
configFileSelector: function(profile) { return profile[CONFIG_ENDPOINT_MODE_NAME]; },
|
||||
default: EndpointMode.IPv4,
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = getEndpointModeConfigOptions;
|
||||
Generated
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
var AWS = require('../core');
|
||||
|
||||
var Endpoint = require('./get_endpoint')();
|
||||
var EndpointMode = require('./get_endpoint_mode')();
|
||||
|
||||
var ENDPOINT_CONFIG_OPTIONS = require('./get_endpoint_config_options')();
|
||||
var ENDPOINT_MODE_CONFIG_OPTIONS = require('./get_endpoint_mode_config_options')();
|
||||
|
||||
var getMetadataServiceEndpoint = function() {
|
||||
var endpoint = AWS.util.loadConfig(ENDPOINT_CONFIG_OPTIONS);
|
||||
if (endpoint !== undefined) return endpoint;
|
||||
|
||||
var endpointMode = AWS.util.loadConfig(ENDPOINT_MODE_CONFIG_OPTIONS);
|
||||
switch (endpointMode) {
|
||||
case EndpointMode.IPv4:
|
||||
return Endpoint.IPv4;
|
||||
case EndpointMode.IPv6:
|
||||
return Endpoint.IPv6;
|
||||
default:
|
||||
throw new Error('Unsupported endpoint mode: ' + endpointMode);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = getMetadataServiceEndpoint;
|
||||
Reference in New Issue
Block a user