in provider-utils/awscloudformation/cloudformation-templates/livestream-helpers/LambdaFunctions/psdemo-js-live-workflow_v0.4.0/lib/flagfish.js [59:105]
initialize(event, context) {
try {
this.$event = event;
this.$context = context;
/* sanity check */
if (!this.$event.RequestType) {
throw new Error('missing event.RequestType');
}
let missing = PS_PARAMS.filter(x => this.$event.ResourceProperties[x] === undefined);
if (missing.length) {
throw new Error(`event.ResourceProperties missing ${missing.join(', ')}`);
}
missing = REQUIRED_ENV.filter(x => process.env[x] === undefined);
if (missing.length) {
throw new Error(`process.env missing ${missing.join(', ')}`);
}
const {
ResourceProperties: {
PS_ENDPOINT_URLS: urls,
PS_USERNAMES: usernames,
PS_PARAMETER_STORE_KEYS: storeKeys,
},
} = this.$event;
/* mediapackage ingest points / usernames / parameter stores */
this.$endpoints = (Array.isArray(urls) ? urls : urls.split(',')).filter(x => x);
this.$usernames = (Array.isArray(usernames) ? usernames : usernames.split(',')).filter(x => x);
this.$storeKeys = (Array.isArray(storeKeys) ? storeKeys : storeKeys.split(',')).filter(x => x);
missing = [this.$endpoints, this.$usernames, this.$storeKeys].filter(x => x.length < 2);
if (missing.length) {
this.$endpoints = undefined;
}
/* optional */
const {
ResourceProperties: {
PS_MEDIASTORE_ENDPOINT: msUrl,
},
} = this.$event;
this.$mediastoreHost = (msUrl) ? URL.parse(msUrl).hostname : undefined;
/* flagfish instance */
this.$instance = new MediaLive({ apiVersion: '2017-10-14' });
} catch (e) {
throw e;
}
}