def create_flowlog()

in code/ct_flowlog_activator.py [0:0]


def create_flowlog(target_session, accountId, resourceId, resourceType, trafficType, destinationBucket, region):
    '''
    Create Flow Log with destination S3, using the specified traffic type
    '''
    try:
        s3_location = 'arn:aws:s3:::' + destinationBucket + '/'
        ec2_client = target_session.client('ec2', region_name=region)
        response = ec2_client.create_flow_logs(
            ResourceIds=[resourceId],
            ResourceType=resourceType,
            TrafficType=trafficType,
            LogDestinationType='s3',
            LogDestination=s3_location
        )
        LOGGER.info('Flow Log details : {}'.format(response))
        if ('FlowLogIds' in response) and (len(response['FlowLogIds']) > 0):
            return response

    except Exception as e:
        LOGGER.error("Could not create Flow Log : {}".format(e), exc_info=True)