Repository: honeycombio/terraform-provider-honeycombio (language: python)

Issue:
honeycombio_dataset - add import support
The `honeycombio_dataset` resource currently does not support imports. Having it support imports makes it behave more idiomatically and -- despite the current "import if already exists" behaviour -- in a less surprising way.


Discussion / hints:

Fix patch:
diff --git a/docs/resources/dataset.md b/docs/resources/dataset.md
index 04e987ab..c23638a1 100644
--- a/docs/resources/dataset.md
+++ b/docs/resources/dataset.md
@@ -30,3 +30,13 @@ In addition to all arguments above, the following attributes are exported:
 * `slug` - The slug of the dataset.
 * `created_at` - ISO8601 formatted time the column was created
 * `last_written_at` - ISO8601 formatted time the column was last written to (received event data)
+
+## Import
+
+Datasets can be imported by their slug, e.g.
+
+```shell
+$ terraform import honeycombio_dataset.my_dataset my-dataset
+```
+
+You can find the slug in the URL bar when visiting the Dataset from the UI.
diff --git a/honeycombio/resource_dataset.go b/honeycombio/resource_dataset.go
index 8378aeac..da881197 100644
--- a/honeycombio/resource_dataset.go
+++ b/honeycombio/resource_dataset.go
@@ -16,6 +16,9 @@ func newDataset() *schema.Resource {
 		ReadContext:   resourceDatasetRead,
 		UpdateContext: resourceDatasetUpdate,
 		DeleteContext: schema.NoopContext,
+		Importer: &schema.ResourceImporter{
+			StateContext: schema.ImportStatePassthroughContext,
+		},
 
 		Schema: map[string]*schema.Schema{
 			"name": {


Test patch:
diff --git a/honeycombio/resource_dataset_test.go b/honeycombio/resource_dataset_test.go
index 9bec1d92..54b6e4bb 100644
--- a/honeycombio/resource_dataset_test.go
+++ b/honeycombio/resource_dataset_test.go
@@ -25,6 +25,12 @@ func TestAccHoneycombioDataset_basic(t *testing.T) {
 					resource.TestCheckResourceAttr("honeycombio_dataset.test", "expand_json_depth", "3"),
 				),
 			},
+			{
+				ResourceName:      "honeycombio_dataset.test",
+				ImportStateId:     testDatasetName,
+				ImportState:       true,
+				ImportStateVerify: true,
+			},
 		},
 	})
 }