Exporting connections, sources, destinations to Terraform

Summary

The user is asking if there is a way to export existing connections, sources, and destinations into Terraform.


Question

Hi, is there a way to export existing connections, sources, destinations into terraform?



This topic has been created from a Slack thread to give it more visibility.
It will be on Read-Only mode here. Click here if you want
to access the original thread.

Join the conversation on Slack

["exporting", "connections", "sources", "destinations", "terraform"]

I don’t know about any out-of-the-box solution.
For a few existing resources, usually I do something like this:

  1. define placeholders for resources, e.g. resource "airbyte_connection" "my_connection" { }
  2. terraform import <http://airbyte_connection.my|airbyte_connection.my>_airbyte_connection "connection-uuid"
  3. fill resource definition, with some help by checking content of terraform state
  4. run terraform plan to detect any drift
  5. repeat 1-4 until I’m good with changes and final terraform apply
    For many resources I’d write some script calling API and generating definitions for terraform resources.
    :warning: Keep in mind that you won’t get connectors’ credentials from API. You get only masked values **********. You can get credentials from database.

I’m getting an error with the terraform import
Provider "<http://registry.terraform.io/airbytehq/airbyte|registry.terraform.io/airbytehq/airbyte>" produced an unexpected new value

│ 
│ While attempting to import an existing object to "module.projects.airbyte_source_mysql.my_source", the provider detected that no object exists with the given id.
│ Only pre-existing objects can be imported; check that the id is correct and that it is associated with the provider's configured region or endpoint, or use
│ "terraform apply" to create a new remote object for this resource.```

and when try to do terraform plan , it looks to add as a new source
Plan: 1 to add, 0 to change, 0 to destroy.

<@U05JENRCF7C> - what version of the Terraform provider are you using?

terraform 1.8.3
terraform-provider-airbyte 0.6.0

I think I was able to do it by using an import block instead and then doing apply

what is the path for your connection? url in browser should have format /workspaces/&lt;workspace-uuid&gt;/connections/&lt;connection-uuid&gt;/status
how does your import block look like?

I’d start with “top-level” resource, without putting them into modules first
you can use moved block later

yeah, you can import if you have terraform version that supports it
I got used to terraform import ... because it has been around for a long time