Chickenpox and shingles are caused by a virus ( varicella-zoster ). You may have had chickenpox as a child so may be immune to the virus. The virus is spread by coughing or direct contact with the fluid from the blisters.
Shingles is not a new infection but is the chickenpox virus which stayed in the nerve cells becoming reactivated. You can only get shingles if you have had chickenpox in the past. Shingles is spread by direct contact with the rash of infected people.
If you are planning a pregnancy it would be advisable to check your immunity to chickenpox with a blood test that your GP could order.
If you are pregnant and are exposed to chickenpox or shingles you need to check your immunity to the virus. If your tests show that you are immune then you will not contract the virus.
On the occasions that you are not immune you need to contact your GP or Obstetrician who may order treatment that needs to be given within 96 hours of exposure.