Sobes.tech
Middle

Do you recommend using GitLab or GitHub for storing state files?

sobes.tech AI

Answer from AI

I do not recommend it. State files (e.g., Terraform state) contain sensitive information about the infrastructure, including potentially confidential values and deployment structure. GitHub and GitLab are version control systems designed for storing source code, not for storing sensitive data about the state of deployed infrastructure.

It is recommended to use specialized backend solutions for storing state files, such as:

  • Amazon S3: High availability and reliability, support for locks to prevent concurrent changes.
  • Azure Storage: Similar to S3, integrates with the Azure ecosystem.
  • Google Cloud Storage: Similar to S3 and Azure Storage, integrates with GCP ecosystem.
  • HashiCorp Consul: Distributed key-value store with built-in lock support.
  • HashiCorp Terraform Cloud / Enterprise: Cloud or on-premises solution specifically designed for collaborative work with Terraform and secure storage of state files.

Using such solutions provides:

  • Security: Isolated data storage, access control.
  • Reliability: Geo-replication and backup.
  • Locks: Prevents parallel operations that could damage the state.
  • Versioning: Tracks changes to the state file.
  • Convenience for collaboration: Centralized storage for the team.