GitLab provides a built in Terraform state feature, so instead of keeping the terraform state file in the local system or repository, you can store the state file in GitLab and can be referenced while performing various terraform operation using GitLab pipeline.
The terraform file terraform.tfstate stores the state of your infrastructure provisioned on the cloud platform by terraform, and if you lose it means that Terraform would not know the status of your current infrastructure on the cloud platform. This file can be stored to a remote Git repo for sharing, but it is not a good practice because the state file could easily get out of sync if it is not handled carefully.
Storing the state in GitLab allows developers to focus on writing code, and not on syncing state across multiple machines. We also have some other remote state options, but users of GitLab can take advantage of GitLab’s built in functionality, including CI/CD pipeline.