def copy_webui_code()

in functions/source/lex_custom_lambda/lex_custom_lambda.py [0:0]


def copy_webui_code(event):
    is_processed = True
    try:
        logger.info('started processing s3 data event: '+str(event))
        driver = create_clidriver()
        copy_command = 's3 cp s3://{source_path}    s3://{destination_path} --recursive --acl public-read'
        source_bucket = event['ResourceProperties']['SourceBucket']
        destination_bucket = event['ResourceProperties']['DestinationBucket']
        if not source_bucket.endswith('/'):
            source_bucket = source_bucket + '/'
        if not destination_bucket.endswith('/'):
            destination_bucket = destination_bucket + '/'
        source_path = source_bucket + event['ResourceProperties']['SourceKey']
        destination_path = destination_bucket + event['ResourceProperties']['DestinationKey']
        formatted_copy_command = copy_command.format(source_path=source_path, destination_path=destination_path)
        logger.info(formatted_copy_command)
        driver.main(formatted_copy_command.split())

        #Fix for index.html content-type
        index_copy_command = 's3 cp s3://{source_path}/index.html s3://{destination_path} --acl public-read --metadata-directive REPLACE --content-type text/html'
        formatted_index_copy_command = index_copy_command.format(source_path=source_path, destination_path=destination_path)
        driver.main(formatted_index_copy_command.split())
        bot_name = event['ResourceProperties']['BotName']
        pool_id = event['ResourceProperties']['CognitoPoolId']
        static_host_bucket = event['ResourceProperties']['DestinationBucket']
        is_processed = upload_statichost_config(bot_name, region_name, pool_id, static_host_bucket)
        logger.info('completed  s3 data processing ')
    except Exception as e:
        logger.error('Failed to copy static web hosting source code'+str(e))
        is_processed = False
    return is_processed