|
2 | 2 | title: Git Sync Extension
|
3 | 3 | ---
|
4 | 4 |
|
5 |
| -Segment's Git extension lets you manage versioning by syncing changes you make in Sources and Destinations from your Segment workspace to a Git repository. |
| 5 | +Segment's Git extension lets you manage versioning by syncing changes you make in your Segment workspace to a Git repository. |
6 | 6 |
|
7 |
| -> info "" |
8 |
| -> Extensions, including Git sync, is currently in public beta and is governed by Segment's [First Access and Beta Preview Terms](https://www.twilio.com/en-us/legal/tos){:target="_blank"}. |
| 7 | +Git Sync supports one-way synchronization from Segment to Git. This sync captures the current state of your workspace through a full sync and includes all new records and changes for supported resources. |
9 | 8 |
|
10 |
| -## Set up Git sync |
| 9 | +Segment doesn't support syncing changes from Git back to Segment. |
11 | 10 |
|
12 |
| -Follow these steps to set up Git sync: |
| 11 | +## Set up Git Sync |
| 12 | + |
| 13 | +Follow these steps to set up Git Sync: |
13 | 14 |
|
14 | 15 | 1. In your Segment workspace, navigate to **Settings > Extensions**.
|
15 | 16 | 2. Click **Set up Git sync**.
|
16 |
| -3. On the **Configure service credentials** page, select a service and protocol, add your SSH private key or GitHub token, then click **Next**. |
| 17 | +3. On the **Configure service credentials** page, select a service and protocol, add your GitHub App, SSH private key, or GitHub token, then click **Next**. |
| 18 | + - To connect to GitLab or Bitbucket, use your SSH private key. |
| 19 | + |
| 20 | +## Working with Git Sync |
| 21 | + |
| 22 | +The Git sync extension syncs the following resources from Segment to your Git repository: |
| 23 | + |
| 24 | +- [Sources](/docs/connections/sources/) and [Destinations](/docs/connections/destinations/)) |
| 25 | +- [Warehouses](/docs/connections/storage/warehouses/) |
| 26 | +- [Destination Filters and Mappings](/docs/connections/destinations/destination-filters/) |
| 27 | +- [Tracking Plans](/docs/protocols/tracking-plan/create/) |
| 28 | +- [Functions](/docs/connections/functions/) |
| 29 | +- [Transformations](/docs/protocols/transform/) |
| 30 | +- [Reverse ETL](/docs/connections/reverse-etl/) |
| 31 | +- [Users](/docs/segment-app/iam/concepts/#team-members) and [User groups](/docs/segment-app/iam/concepts/#user-groups) |
| 32 | +- [Labels](/docs/segment-app/iam/labels/#where-can-i-create-labels) |
| 33 | + |
| 34 | +Reach out to [Segment support](https://app.segment.com/workspaces?contact=1){:target="blank"} to request support for additional Git Sync resources. |
| 35 | + |
| 36 | +After you set up the Git sync extension for the first time, Segment performs an initial sync that sends the current state of your Segment workspace to the Git repository you connected. Segment automatically tracks all following workspace updates. |
| 37 | + |
| 38 | +You can manually trigger syncs at any time by clicking **Full Sync** on the Git Sync page. To disable Git Sync from the Git Sync page, switch the **Enabled** toggle to off. |
| 39 | + |
| 40 | +## Git Sync architecture and data model |
| 41 | + |
| 42 | +Because a Segment workspace can represent a distinct environment (testing, staging, production), each workspace is mapped directly to a single Git repository. This direct mapping ensures a clear and organized relationship between workspace resources and a Git repository. |
| 43 | + |
| 44 | +Segment uses its [Terraform provider](https://registry.terraform.io/providers/segmentio/segment/1.0.3){:target="_blank"} to manage key functions like tracking changes and retrieving information about those changes in Segment. Segment stores changes in HashiCorp Configuration Language (HCL), the format used by Terraform. To learn more about HCL and how it compares to JSON or YAML, visit [HashiCorp's HCL repository on GitHub](https://github.com/hashicorp/hcl){:target="_blank"}. |
| 45 | + |
| 46 | +Using HCL makes it easier to document Segment's data model, especially for users managing versioning and Git Sync with Terraform. It also helps manage Segment configurations directly from Git. For more details on the Git Sync data model, read [Segment's Terraform provider documentation](https://registry.terraform.io/providers/segmentio/segment/latest/docs){:target="_blank"}. |
| 47 | + |
| 48 | +## Managing your Segment workspace with Terraform and Git Sync |
| 49 | + |
| 50 | +Segment supports one-way synchronization from Segment to Git, but you can set up two-way synchronization using the Segment Terraform provider. |
| 51 | + |
| 52 | +Terraform offers an open-source way to manage Segment resources through a Git repository as an alternative to a fully managed two-way sync. However, this method requires third-party tools like [Atlantis](https://www.runatlantis.io/){:target="_blank"} for CI integration, which Segment doesn’t officially support. |
| 53 | + |
| 54 | +To manage Segment resources using Git and Terraform, follow these steps: |
| 55 | + |
| 56 | +1. Copy the generated Terraform configuration for the resources you want to manage into a separate Git repository dedicated to Terraform. |
| 57 | +2. Include the following provider configuration blocks: |
| 58 | + |
| 59 | + ```hcl |
| 60 | + # providers.tf |
17 | 61 |
|
18 |
| -## Working with Git syncs |
| 62 | + terraform { |
| 63 | + required_providers { |
| 64 | + segment = { |
| 65 | + source = "segmentio/segment" |
| 66 | + version = "1.0.4" |
| 67 | + } |
| 68 | + } |
| 69 | + } |
19 | 70 |
|
20 |
| -The Git sync extension syncs [Connections](/docs/connections/) ([Sources](/docs/connections/sources/) and [Destinations](/docs/connections/destinations/)) from Segment to your Git repository. |
| 71 | + provider "segment" { |
| 72 | + # Provide the token directly or load it from an environment variable |
| 73 | + } |
| 74 | + ``` |
| 75 | +3. Apply configuration changes by running Terraform locally or using a tool like Atlantis to run it directly from your Git provider. |
21 | 76 |
|
22 |
| -After you set up the Git sync extension for the first time, Segment performs an initial sync that sends source and destination information in your Segment workspace to the Git repository you connected. |
23 | 77 |
|
24 |
| -You can run syncs at any time by clicking **Full resync** on the Git sync page. To disable Git sync from the Git sync page, switch the **Enabled** toggle to off. |
| 78 | +For more information on using Terraform, visit [Terraform's documentation](https://developer.hashicorp.com/terraform/docs){:target="_blank"}. |
0 commit comments