segmentio / terraform-provider-segment

Terraform provider for Segment, using the Public API
https://registry.terraform.io/providers/segmentio/segment/latest
MIT License
25 stars 3 forks source link

Unable to make updates to 'segment_source' resource for Snowflake #119

Closed sharanya-v closed 1 month ago

sharanya-v commented 1 month ago

Description

I have a 'segment_source' resource set up for a Snowflake source. I've been unable to make any changes to this source without an error popping up around authentication:

│ Error: Unable to update Source
│ 
│   with segment_source.snowflake,
│   on snowflake.tf line 1, in resource "segment_source" "snowflake":
│    1: resource "segment_source" "snowflake" {
│ 
│ 500 Internal Server Error
│ {
│   "errors": [
│     {
│       "type": "unknown",
│       "message": "Connection settings are invalid: missing credentials, pick either basic auth, key-pair auth or oauth to connect"
│     }
│   ]
│}

I'm not sure how to address this issue because there's nothing about connection settings in the documentation for the resource. Additionally, when I use the Segment API to return the source I don't see any parameters for connection settings there either. Any help would be appreciated if I'm missing something here!

To Reproduce

Here is an example of how the resource is configured. I'm on the latest version of the provider (1.0.1)

resource "segment_source" "snowflake" {
  slug    = "snowflake"
  name    = "Snowflake"
  enabled = true
  metadata = {
    id = "abc123"
  }
  settings = jsonencode({
    "account" : "account_name",
    "database" : "database_name",
    "username" : "snowflake_username",
    "warehouse" : "warehouse"
  })
  labels = [
    {
      key   = "environment"
      value = "prod"
    }
  ]
}
deanhuynh commented 1 month ago

Hi thanks for raising this issue! This looks to be a bug that allowed you to create the snowflake source without the proper connection settings. To fix this, I'd recommend deleting this resource and recreating it with the correct auth settings. snowflake source has it's own unique settings which is why you don't see them in the Terraform documentation. Here are the options for the Snowflake source metadata, which you can look up yourself through Public API or the source_metadata Terraform data source:

"options": [
                    {
                        "name": "account",
                        "required": true,
                        "type": "string",
                        "defaultValue": "",
                        "description": "Your Snowflake account ID, including a region suffix if applicable."
                    },
                    {
                        "name": "authentication_method",
                        "required": false,
                        "type": "string",
                        "defaultValue": "",
                        "description": ""
                    },
                    {
                        "name": "database",
                        "required": true,
                        "type": "string",
                        "defaultValue": "",
                        "description": "The name of a database in your Snowflake account."
                    },
                    {
                        "name": "password",
                        "required": false,
                        "type": "password",
                        "defaultValue": "",
                        "description": "The password used for accessing your Snowflake database."
                    },
                    {
                        "name": "private_key",
                        "required": false,
                        "type": "string",
                        "defaultValue": "",
                        "description": "You can upload .p8 file format. Key length must be at least 2048-bit. An encrypted key is recommended but not required."
                    },
                    {
                        "name": "private_key_passphrase",
                        "required": false,
                        "type": "password",
                        "defaultValue": "",
                        "description": "Enter the passphrase associated with this encrypted private key."
                    },
                    {
                        "name": "username",
                        "required": true,
                        "type": "string",
                        "defaultValue": "",
                        "description": "The user name for accessing your Snowflake database."
                    },
                    {
                        "name": "warehouse",
                        "required": true,
                        "type": "string",
                        "defaultValue": "",
                        "description": "The name of the Snowflake Warehouse to use for compute."
                    }
                ],
sharanya-v commented 1 month ago

Thanks for taking a look! It says authentication_method is not required, is that incorrect? And what are the accepted values for the Snowflake source?

deanhuynh commented 1 month ago

I think it should be safe to ignore authentication_method and just use password and username to connect. But definitely let me know if that doesn't work.