8 months ago
    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
    that handles TLS. My provider point to localhost:3307 where cloud_sql_proxy is listening.
    new mysql.Grant(
        user: 'applications',
        host: '%',
        database: 'applications',
        privileges: ['ALL'],
        provider: new mysql.Provider(`import-applications-grant`, {
          username: 'root',
          endpoint: '',
          password: config.requireSecret('MY_SQL_APPLICATIONS_SECRET'),
        import: 'applications@%:applications',
        protect: true,
    But then I get the following error:
      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?


    8 months ago
    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 ("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'@''). 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.


    8 months ago
    This is great @little-cartoon-10569. Gonna try that. Many thanks.