airbytehq / airbytehq/terraform-provider-airbyte

Wrong docs on how to run terraform import

Ouverte
#166 1 commentaire 1 réaction 0 personnes assignées Voir sur GitHub
Langage dominant
Go
Étoiles
67
Forks
33
Merge moyen
2 min
PR mergées (30 j)
1

Description

Here's how the docs suggest a resource is imported into Terraform https://registry.terraform.io/providers/airbytehq/airbyte/latest/docs/resources/destination_bigquery#import:

```
terraform import airbyte_destination_bigquery.my_airbyte_destination_bigquery ""
```

If the following import command pattern is executed against an existing resource, all imported values are `null` or just empty, so the import doesn't actually do anything besides creating the bare structure:

```
{
"mode": "managed",
"type": "airbyte_destination_bigquery",
"name": "resourceName",
"provider": "provider[\"registry.terraform.io/airbytehq/airbyte\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"configuration": {
"big_query_client_buffer_size_mb": null,
"credentials_json": null,
"dataset_id": null,
"dataset_location": null,
"disable_type_dedupe": null,
"loading_method": null,
"project_id": null,
"raw_data_dataset": null,
"transformation_priority": null
},
"definition_id": null,
"destination_id": "",
"destination_type": "",
"name": "",
"workspace_id": ""
},
"sensitive_attributes": [
[
{
"type": "get_attr",
"value": "configuration"
},
{
"type": "get_attr",
"value": "credentials_json"
}
]
]
}
]
},
```

Normally (see eg. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/bigquery_dataset#import), Terraform would expect the import to use some identifier, eg `resourceName`, not be blank `""`

```
$ terraform import google_bigquery_dataset.default projects/{{project}}/datasets/{{dataset_id}}
$ terraform import google_bigquery_dataset.default {{project}}/{{dataset_id}}
$ terraform import google_bigquery_dataset.default {{dataset_id}}
```

So I tried running the following code, but there's an error:

```
% terraform import airbyte_destination_bigquery.resourceName "resourceName"
│ Error: failure to invoke API

│ unknown status code returned: Status 500
│ {"message":"Internal Server Error: Invalid UUID string: "resourceName","exceptionClassName":"java.lang.IllegalArgumentException","exceptionStack":[],"rootCauseExceptionStack":[]}
```

So then I tried using UUIDS. While trying to use `definitionId` causes yet another error...:

```
│ Error: Cannot import non-existent remote object

│ While attempting to import an existing object to "airbyte_destination_bigquery.resourceName", 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.
```

... using `destinationId` seems to pass with no errors (`% terraform import airbyte_destination_bigquery.resourceName "destinationId"`) and at least basic parameters get imported. So my assumption is that the docs should get updated accordingly?

```
{
"mode": "managed",
"type": "airbyte_destination_bigquery",
"name": "resourceName",
"provider": "provider[\"registry.terraform.io/airbytehq/airbyte\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"configuration": {
"big_query_client_buffer_size_mb": null,
"credentials_json": null,
"dataset_id": null,
"dataset_location": null,
"disable_type_dedupe": null,
"loading_method": null,
"project_id": null,
"raw_data_dataset": null,
"transformation_priority": null
},
"definition_id": null,
"destination_id": "660abd9b-35c1-4882-9ed6-9dbf88b5657b",
"destination_type": "bigquery",
"name": "resourceName",
"workspace_id": "74fe0166-1b1c-4f5f-8a4e-a1dfb8cf255d"
},
"sensitive_attributes": [
[
{
"type": "get_attr",
"value": "configuration"
},
{
"type": "get_attr",
"value": "credentials_json"
}
]
]
}
]
},
```

As you can see though, the import, even using the seemingly correct syntax, still causes some `nulls` to be created. I created a separate ticket for that: https://github.com/airbytehq/terraform-provider-airbyte/issues/165

Also, the whole logic on how Airbyte handles `configuration {}` blocks seems to be wrong: https://github.com/airbytehq/terraform-provider-airbyte/issues/160

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.