async createInput()

in provider-utils/awscloudformation/cloudformation-templates/livestream-helpers/LambdaFunctions/psdemo-js-live-workflow_v0.4.0/lib/flagfish.js [229:262]


  async createInput(securityGroupId) {
    const InputSecurityGroups = Array.isArray(securityGroupId)
      ? securityGroupId
      : [securityGroupId];
    const payload = {
      Name: `input-${this.channelId}`,
      Type: this.ingestType,
      InputSecurityGroups,
    };
    /* RTMP specifically needs StreamName to be set */
    if (this.ingestType === 'RTMP_PUSH') {
      payload.Destinations = ['p', 'b'].map(x => ({ StreamName: `${this.channelId}-${x}` }));
    }
     /* Set MediaLive input Source as the Url to MP4 file*/
    if (this.ingestType === 'MP4_FILE') {
      payload.Sources =  [{ Url: this.mp4URL }, {Url: this.mp4URL}];
    }

    const response = await this.flagfish.createInput(payload).promise();
    const { Input } = response;
    const missing = ['Id', 'Arn', 'Name', 'Destinations'].filter(x => Input[x] === undefined);
    if (missing.length) {
      throw new Error(`response.Input missing ${missing.join(', ')}`);
    }
    if (this.ingestType === 'MP4_FILE') {
      /* Just return when it is MP4_FILE */
      return response;
    }
    const { Destinations } = Input;
    if (Destinations.length < 2) {
      throw new Error(`invalid input destination counts: (${Destinations.length})`);
    }
    return response;
  }