View the docs on the Terraform Registry.
This provider is an experiment using the new terraform-plugin-go SDK in order to utilize dynamic typing for its attributes.
Home Page: https://registry.terraform.io/providers/paultyng/sql/latest/docs
License: Mozilla Public License 2.0
View the docs on the Terraform Registry.
This provider is an experiment using the new terraform-plugin-go SDK in order to utilize dynamic typing for its attributes.
Use a *big.Float
instead of string?
When trying terraform plan
i get this error:
│ 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)
│
╵
ERRO[0016] 1 error occurred:
* exit status 1
This is my code:
#sql.tf
terraform {
required_providers {
sql = {
source = "paultyng/sql"
version = "0.4.0"
}
}
}
provider "sql" {
alias = "postgres"
url = "postgres://postgres:password@localhost:5432/mydatabase"
}
resource "sql_migrate" "migrate" {
migration {
id = "create api_keys table"
up = <<SQL
CREATE TABLE api_keys (
api_key varchar(40) NOT NULL PRIMARY KEY,
shop_id integer NOT NULL,
portal varchar(20) NOT NULL
);
SQL
down = "DROP TABLE IF EXISTS api_keys;"
}
}
It looks like the url argument is not readable.
When I use export SQL_URL="postgres://postgres:password@localhost:5432/mydatabase"
it starts working. But it is not a solution for me. I need to manage database, which is created also with terraform. in GCP (should not be relevant to this issue).
versions:
Terraform v1.0.11
on darwin_amd64
+ provider registry.terraform.io/hashicorp/google v4.0.0
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.
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.
Please list the resources as a list, for example:
If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.
Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.
If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log
.
What should have happened?
What actually happened?
Please list the steps required to reproduce the issue, for example:
terraform apply
Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?
Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:
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.
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.
Terraform v1.0.7
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v4.28.0
+ provider registry.terraform.io/paultyng/sql v0.4.0
Your version of Terraform is out of date! The latest version
is 1.2.9. You can update by downloading from https://www.terraform.io/downloads.html```
### Affected Resource(s)
Please list the resources as a list, for example:
provider "sql" {
alias = "postgres"
url = var.db_connection_string
}
data "sql_query" "create_audit_role" {
provider = sql.postgres
query = var.create_audit_role_query
}
data "sql_query" "create_extension" {
provider = sql.postgres
query = var.create_pgaudit_extension
}
data "sql_query" "alter_db_audit" {
provider = sql.postgres
query = "set pgaudit.log='All';"
depends_on = [
data.sql_query.create_audit_role,
data.sql_query.create_extension
]
}
Supposed to connect and run sql query
Received:
Error: Plugin error
│
│ with provider["registry.terraform.io/paultyng/sql"].postgres,
│ on main.tf line 1, in provider "sql":
│ 1: provider "sql" {
│
│ The plugin returned an unexpected error from plugin.(*GRPCProvider).ConfigureProvider: rpc error: code = Unknown desc =
│ ConfigureProvider - unable to ping database: failed to connect to `host=test.cluster-asdafascads.us-east-1.rds.amazonaws.com
│ user=postgres database=postgrestest`: dial error (dial tcp xx.xxx.xxx.xxx:5432: connect: operation timed out)
Please list the steps required to reproduce the issue, for example:
terraform init
terraform plan
Hello,
Are you going to add client key/cert feature to start working with mutual TLS? In GCP Cloud SQL database works in that mode and that's why your provider now is useless :|1
Regards,
Maciek
I've tried connecting to a Snowflake account, but it failed (provider version 0.4.0).
This was the template for the connection string, as suggested here: jdbc:snowflake://<account_identifier>.snowflakecomputing.com/?<connection_params>
.
Got this error:
unexpected datasource name scheme: jdbc
sql_query
should accept a map(any)
for a parameters
attribute.
Hi,
Great provider ! I'm really missing to be able to specify the url in the ressource.
Basically I want to be able to do something like this:
locals {
data = {
"DB_A" = {
"url" = "sql url goes here"
"up_script" = "a/b/up.sql"
"down_script" = "a/b/down.sql"
}
"DB_B" = {
"url" = "sql url goes here"
"up_script" = "a/b/up.sql"
"down_script" = "a/b/down.sql"
}
}
}
resource "sql_migrate" "schema" {
for_each = local.data
url = each.value.url
migration {
up = each.value.sql_up
down = each.value.sql_down
}
}
Thanks in advance :)
terraform import sql_migrate.db myid1,myid2,myid3,etc
I was playing with your provider. It will meet some of my needs but I will use another for updating databases (I may have to make my own) .
I ran a TF plan and found that it ran my query - it was expecting it to be a read and returning data - but i had put a "create user" in it and it created the user. I can see that you were only intending use for getting data to feed terraform.
You may want to run a check for any query that changes the database in any way and put a safeguard in it to ensure it does not run by giving an error message "updates to your database are not allowed"
Hi there,
1.3.2
sql
provider configuration itselfprovider "sql" {
url = "postgres://${local.postgresql.login}:${local.postgresql.password}@${local.postgresql.host}:${local.postgresql.port}/postgres?sslmode=${local.postgresql.sslmode}"
}
The provider should have been configured.
The provider fails to pass configuration invoking this error:
Error: Plugin error
│
│ The plugin returned an unexpected error from plugin6.(*GRPCProvider).ConfigureProvider: rpc error: code = Unknown desc = ConfigureProvider - unable to read url:
│ unmarshaling unknown values is not supported
Use any variable in the url
parameter with a value not known during the planning phase.
The connection string cannot be passed in advance in my case because the PostgreSQL server is provisioned during apply phase.
Postgresql provider (https://registry.terraform.io/providers/cyrilgdn/postgresql/) is ok with it.
Hi @paultyng ,
I recently stumbled upon this provider and when I was looking into provisioning database instance users with terraform.
On GCP there is an API to create users on CloudSQL instances, however they will be created as "superusers".
For readonly-users or similar, you have to drop down to SQL. By default CloudSQL instances are not directly reachable, but can be reached through a proxy. Luckily the proxy can be embedded directly in Go and even be used as SQL driver.
I went ahead and implemented a minimal provider myself earlier: https://github.com/trevex/terraform-provider-cloudsql
But if you are open to it I can see if I can draft up a PR implementing CloudSQL-support in this provider.
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.
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
Please list the resources as a list, for example:
-data "sql_query"
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'@'%';"
}.
│ 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)
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
Database is on Azure, requires SSL, running on my local in Windows WSL Linux
Hi there,
I have an issue with multiple insert by using the migration directory or without it.
I always getting MySQL syntax error if I have multiple line and any command but if I remove the rest and each file I add just one MySQL command it works.
INSERT INTO ReferenceData.topics (topicName,isTenor,batchSize,intervalTime,lambdaId,description) VALUES('derivedData',0,1500,10,NULL,'Data generated by KDA derived from the fiat topics'),('M1',1,1500,5,NULL,'Forward tenor'),('M10',1,1500,10,NULL,'Forward tenor'),('M11',1,1500,10,NULL,'Forward tenor'),('M12',1,1500,10,NULL,'Forward tenor'),('M18',1,1500,60,NULL,'Forward tenor'),('M2',1,1500,10,NULL,'Forward tenor'),('M21',1,1500,300,NULL,'Forward tenor'),('M3',1,1500,10,NULL,'Forward tenor'),('M4',1,1500,10,NULL,'Forward tenor');
INSERT INTO ReferenceData.topics (topicName,isTenor,batchSize,intervalTime,lambdaId,description) VALUES('M5',1,1500,10,NULL,'Forward tenor'),('M6',1,1500,10,NULL,'Forward tenor'),('M7',1,1500,10,NULL,'Forward tenor'),('M8',1,1500,10,NULL,'Forward tenor'),('M9',1,1500,10,NULL,'Forward tenor'),('ON',1,1500,5,NULL,'Forward tenor'),('SN',1,1500,5,NULL,'Forward tenor'),('SPT',1,1500,1,NULL,'Spot data'),('TN',1,1500,5,NULL,'Forward tenor'),('W1',1,1500,5,NULL,'Forward tenor');
INSERT INTO ReferenceData.topics (topicName,isTenor,batchSize,intervalTime,lambdaId,description) VALUES('W2',1,1500,5,NULL,'Forward tenor'),('W3',1,1500,5,NULL,'Forward tenor'),('Y2',1,1500,600,NULL,'Forward tenor'),('Y3',1,1500,6000,NULL,'Forward tenor'),('Y4',1,1500,6000,NULL,'Forward tenor'),('Y5',1,1500,6000,NULL,'Forward tenor');
v1.3.6
│ Error: Plugin error
│
│ The plugin returned an unexpected error from plugin6.(*GRPCProvider).ApplyResourceChange: rpc error: code = Unknown
│ desc = Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
│ version for the right syntax to use near 'INSERT INTO ReferenceData.topics
│ (topicName,isTenor,batchSize,intervalTime,lambd' at line 2
I'm having a problem with Aurora Cluster Mysql 5.7 data type
Terraform v1.1.7
on linux_amd64
Please list the resources as a list, for example:
If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.
data "sql_query" "users" {
query = "select `user` from mysql.`user`"
provider = sql.mysql_db_management
}
output "test"{
value = data.sql_query.users.result
}
mysql_grant.devops_all_schemas_grant: Refreshing state... [id=test.user@%:`gk`]
╷
│ Error: unable to convert value from database: unable to determine type for "user": unexpected type for "user": "CHAR" (slice sql.RawBytes)
│
│ with data.sql_query.users,
│ on terrafile.tf line 40, in data "sql_query" "users":
│ 40: data "sql_query" "users" {
│
╵
but if I change the query for
data "sql_query" "users" {
query ="select CAST(`user` AS CHAR CHARACTER SET utf8) as user_name from mysql.`user`"
provider = sql.mysql_db_management
}
output "test"{
value = data.sql_query.users.result
}
+ test = [
+ {
+ user_name = "user.user"
},
+ {
+ user_name = "airflow_dag"
},
.....
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.