Skip to content

URL parameter is not working in provider setup  #48

@williamohara

Description

@williamohara

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.
v1.1.3

Affected Resource(s)

Please list the resources as a list, for example:
-data "sql_query"

Terraform Configuration Files

terraform {
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = ">= 2.26"
    }
    
    sql = {
      source = "paultyng/sql"
      version = "0.4.0"
      
    }
  }
  required_version = ">= 0.14.9"
  backend "azurerm" {
    resource_group_name  = "blabla"
    storage_account_name = "blabal"
    container_name       = "tfstate"
    key                  = "bla.stage-1.tfstate"
  }
}

provider "azurerm" {
  features {}
}

provider "sql" {
  alias = "mysql"
  url   = "mysql://SfEuj2w4nrHeHoD6@my-server-name:<redacted password>@tcp(my-server-name:3306)/mysql?tls=true"
  max_idle_conns = 20
  max_open_conns = 4
}



data "sql_query" "test" {
  query = "CREATE USER 'test_user'@'%';"
}.

Debug Output

│ Error: Invalid provider configuration
│ 
│ Provider "registry.terraform.io/paultyng/sql" requires explicit configuration. Add a provider block to the root module and configure the provider's required arguments as described in
│ the provider documentation.
│ 
╵
╷
│ Error: A `url` is required to connect to your database.
│ 
│   with provider["registry.terraform.io/paultyng/sql"],
│   on <empty> line 0:
│   (source code not available)

Steps to Reproduce

set up provider similar to above without setting SQL_URL environment variable
terraform apply
get error
set SQL_URL environment variable
everything runs just fine

Important Factoids

Database is on Azure, requires SSL, running on my local in Windows WSL Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions