def empty_bucket()

in resources/flink-on-kda/cdk/lambda/empty-bucket.py [0:0]


def empty_bucket(event, context):
    bucket_name = os.environ['bucket_name']

    try:
        if event['RequestType'] == 'Delete':
            print("empty bucket: " + bucket_name)
            
            bucket = boto3.resource('s3').Bucket(bucket_name)
            bucket.object_versions.delete()

        cfnresponse.send(event, context, cfnresponse.SUCCESS, {})
    except Exception:
        traceback.print_exc()

        cfnresponse.send(event, context, cfnresponse.FAILED, {})