Check if optional attribute is set in .tf file

I am trying to solve this issue. Basically, I need to make sure that if gitlab_project doesn’t have default_branch attribute in .tf file, it is not tracked in state.

  1. What is the proper API call to check that default_branch is absent from .tf?
  2. How to make sure that default_branch is not tracked in the state?