def create_input()

in source/customresources/custom-resource-py/lib/medialive.py [0:0]


def create_input(config):
    print('Creating::{} Input'.format(config['Type']))

    if config['Type'] == 'RTP_PUSH':
        sg = medialive.create_input_security_group(
            WhitelistRules=[
                {
                    'Cidr': config['Cidr']
                }
            ]
        )
        response = medialive.create_input(
            InputSecurityGroups=[
                sg['SecurityGroup']['Id'],
            ],
            Name = config['StreamName'],
            Type=config['Type']
        )
        responseData['Id'] = response['Input']['Id']
        responseData['EndPoint1'] = response['Input']['Destinations'][0]['Url']

    if config['Type'] == 'RTMP_PUSH':
        sg = medialive.create_input_security_group(
            WhitelistRules=[
                {
                    'Cidr': config['Cidr']
                }
            ]
        )
        response = medialive.create_input(
            InputSecurityGroups=[
                sg['SecurityGroup']['Id'],
            ],
            Name = config['StreamName'],
            Destinations= [
                {
                    'StreamName': config['StreamName']+'primary'
                }
            ],
            Type=config['Type']
        )
        responseData['Id'] = response['Input']['Id']
        responseData['EndPoint1'] = response['Input']['Destinations'][0]['Url']
        # responseData['EndPoint2'] = response['Input']['Destinations'][1]['Url']

    if config['Type'] == 'RTMP_PULL' or config['Type'] == 'URL_PULL' :
        Name = config['StreamName']
        Sources = [
            {
                'Url': config['PriUrl']
            }
        ]
        Type = config['Type']
        # store input u/p in SSM
        if config['PriUser']:
            Sources[0]['Username'] = config['PriUser']

            ssm.put_parameter(
                Name = config['PriUser'],
                Description = 'Live Stream solution Primary input credentials',
                Type = 'String',
                Value = config['PriPass'],
                Overwrite=True
            )

        response = medialive.create_input(
                Name = Name,
                Type = Type,
                Sources = Sources
        )
        responseData['Id'] = response['Input']['Id']
        responseData['EndPoint1'] = 'Push InputType only'

    if config['Type'] == 'MEDIACONNECT':
        response = medialive.create_input(
            Name = config['StreamName'],
            Type = config['Type'],
            RoleArn = config['RoleArn'],
            MediaConnectFlows = [
                {
                    'FlowArn': config['PriMediaConnectArn']
                }
            ]
        )
        responseData['Id'] = response['Input']['Id']
        responseData['EndPoint1'] = 'Push InputType only'

    return responseData