<@U04SE163WC8> How to set the cursor_field for air...
# ask-ai
m
@kapa.ai How to set the cursor_field for airbyte connection while using terraform
u
To set the
cursor_field
for an Airbyte connection using Terraform, you can add it to the stream configuration in your Terraform resource. Here's how you can do it:
Copy code
hcl "selected_fields": [   {     "field_path": ["id"]   },   {     "field_path": ["updated_at"]   },   {     "field_path": ["email"]   } ],
You need to include the
cursor_field
in the list of selected fields. It's important to note that you must also include the primary key and any other required fields in this list. However, there are a couple of important points to keep in mind: 1. The
cursor_field
is required if the
sync_mode
is set to
incremental
, unless there is a default cursor field defined by the source [Airbyte Public API](https://reference.airbyte.com/reference/start). 2. The
cursor_field
should be an array of strings that serves as a path to the desired field. For example, if the structure of a stream is
{ value: 2, metadata: { updated_at: 2020-11-01 } }
, the
cursor_field
might be
["metadata", "updated_at"]
[Airbyte Protocol](https://docs.airbyte.com/understanding-airbyte/airbyte-protocol#cursor). 3. Currently, there's a limitation in the Terraform provider and the underlying SDK/API that doesn't support extracting the list of selected fields in a stream. This makes round-tripping impossible with the API alone and cumbersome otherwise [GitHub Discussion](https://github.com/airbytehq/airbyte/discussions/41944). Remember to always include the primary key and cursor fields in your selected fields list when using Terraform to configure your Airbyte connection.