Closed Krobar closed 5 months ago
@Krobar currently, it is not possible.
I am open to PRs implementing it - it could be a separate resource with user and default role.
Here a workaround implementation using a null_resource
:
resource "null_resource" "activate_default_roles" {
for_each = mysql_grant.users
provisioner "local-exec" {
command = <<-EOT
mysql \
--user='${sensitive(var.target_database_server_administrator_login)}' \
--password='${sensitive(var.target_database_server_administrator_password)}' \
--host='${var.target_database_server_hostname}' \
--port='${var.target_database_server_port}' \
--database='${each.value.database}' \
--execute="SET DEFAULT ROLE ALL TO '${each.value.user}'@'${each.value.host}';"
EOT
interpreter = ["/bin/bash", "-c"]
working_dir = path.module
}
}
... where:
var.target_database_server_administrator_login
var.target_database_server_administrator_password
var.target_database_server_hostname
var.target_database_server_port
Are the same values supplied to the provider config, ex:
# Configure the MySQL provider
provider "mysql" {
endpoint = "my-database.example.com:3306"
username = "app-user"
password = "app-password"
}
The new resource was released as a part of provider version 3.0.55 - thanks to @rneascu5
Is this possible with this provider?