Hello folks, I'm trying to import some databases g...
# general
f
Hello folks, I'm trying to import some databases grants created using Terraform. We have a MySQL instance running on GCP, to which I'm connecting using
cloud_sql_proxy
that handles TLS. My provider point to localhost:3307 where cloud_sql_proxy is listening.
Copy code
new mysql.Grant(
  'applications',
  {
    user: 'applications',
    host: '%',
    database: 'applications',
    privileges: ['ALL'],
  },
  {
    provider: new mysql.Provider(`import-applications-grant`, {
      username: 'root',
      endpoint: '127.0.0.1:3307',
      password: config.requireSecret('MY_SQL_APPLICATIONS_SECRET'),
    }),
    import: 'applications@%:applications',
    protect: true,
  }
);
But then I get the following error:
Copy code
Diagnostics:
  pulumi:pulumi:Stack (env-staging):
    error: preview failed
 
  mysql:index:Grant (applications@%:applications):
    error: Preview failed: refreshing urn:pulumi:staging::env::mysql:index/grant:Grant::applications@%:applications: user with host or a role is required
Any ideas?
l
Based only on reading the docs (so caveat lector): host values with wildcards must be quoted within the username, so "applications@%" isn't valid. You need "applications@'%'. This is according to my reading of https://dev.mysql.com/doc/refman/5.7/en/grant.html ("Object Quoting Guidelines"):
However, quotation marks are necessary to specify a user_name string containing special characters (such as -), or a host_name string containing special characters or wildcard characters such as % (for example, 'test-user'@'%.com'). Quote the user name and host name separately.
Which I think can be done with
host: "'%'"
Probably need this in both the grant and the opts objects.
f
This is great @little-cartoon-10569. Gonna try that. Many thanks.
👍 1