How to check existing resource through script?

I wrote a block to create the cache policy for cloud front but what I want is that before creating it should check whether there is an existing policy with the same name. If there exist a policy then it should skip that block creation otherwise it should create that block. How can I achieve that?

I wrote a block to create the cache policy for cloud front but what I want is that before creating it should check whether there is an existing policy with the same name. If there exist a policy then it should skip that block creation otherwise it should create that block. How can I achieve that?