@cumulus/common
Version:
Common utilities used across tasks
24 lines • 1.1 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchFakeProviderIp = void 0;
const is_ip_1 = __importDefault(require("is-ip"));
const S3_1 = require("@cumulus/aws-client/S3");
const fetchFakeProviderIp = async () => {
if (!process.env.FAKE_PROVIDER_CONFIG_BUCKET) {
throw new Error('The FAKE_PROVIDER_CONFIG_BUCKET environment variable must be set');
}
const textObject = await (0, S3_1.getTextObject)(process.env.FAKE_PROVIDER_CONFIG_BUCKET, 'fake-provider-ip');
if (!textObject) {
throw new Error('Failed to get object defined in FAKE_PROVIDER_CONFIG_BUCKET');
}
const ip = textObject.trim();
if (!(0, is_ip_1.default)(ip)) {
throw new Error(`Invalid fake provider IP "${ip}" fetched from s3://${process.env.FAKE_PROVIDER_CONFIG_BUCKET}/fake-provider-ip`);
}
return ip;
};
exports.fetchFakeProviderIp = fetchFakeProviderIp;
//# sourceMappingURL=fake-provider.js.map