def process_thing()

in lambda-bulk-importer/main.py [0:0]


def process_thing(thingName, certificateId, thingTypeName):
    certificateArn = get_certificate_arn(certificateId)
    try:
        response = iot_client.describe_thing(thingName=thingName)
        return response.get("thingArn")
    except:
        print("Thing not found. Creating.")
    
    # Create thing
    try:
        if thingTypeName == "":
            response = iot_client.create_thing(thingName=thingName)
        else:
            response = iot_client.create_thing(thingName=thingName,
                                               thingTypeName=thingTypeName)

    except Exception as e:
        print("ERROR Thing creation failed.")
        print(e)
        return None

    try:
        response = iot_client.attach_thing_principal( thingName=thingName,
                                                      principal=certificateArn)
            
        return 
    except Exception as e:
        print("ERROR Certificate attachment failed.")
        print(e)
        return None