Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using the provider without pre-defined configuration #5

Closed
fernandocarletti opened this issue May 13, 2019 · 3 comments
Closed

Comments

@fernandocarletti
Copy link

In many cases we use cloud providers to create a MySQL server. When using services such as RDS, the endpoint, username and password are created right before the databases are created.

If the configuration is not previously set, the following error is thrown:

Previewing update (development):

     Type                 Name                       Plan     Info
     pulumi:pulumi:Stack  mysql-example-development           1 error

Diagnostics:
  pulumi:pulumi:Stack (mysql-example-development):
    error: Missing required configuration variable 'mysql:endpoint'
    	please set a value using the command `pulumi config set mysql:endpoint <value>`

This is the approach mentioned above:

import * as mysql from '@pulumi/mysql';
import * as aws from '@pulumi/aws';


const rds = new aws.rds.Instance('sample', {
  identifier: "sample",
  engine: "mysql",
  username: "rootUser",
  password: "rootPassword",
  dbSubnetGroupName: "xxxxx",
  availabilityZone: "us-east-1b",
  instanceClass: "db.t2.micro",
  allocatedStorage: 20,
  vpcSecurityGroupIds: ['sg-c1cxxxxx'],
  skipFinalSnapshot: true,
});

const mysqlProvider = new mysql.Provider('mysql', {
  endpoint: rds.endpoint,
  username: rds.username,
  password: rds.password.apply(p => p.toString()),
});

const databaase = new mysql.Database('sample', {
  name: 'sample',
}, {
  provider: mysqlProvider
});

Maybe defaulting the configuration to localhost, root and empty password as many tools do could be a good approach. WDYT?

@fernandocarletti
Copy link
Author

This scenario is being discussed here: pulumi/pulumi#2725

@fernandocarletti
Copy link
Author

Hello @lukehoban. It seems the issue is a bit worse right now. Even with defaults set, I get a missing required key error:
image

@fernandocarletti
Copy link
Author

fernandocarletti commented Jun 14, 2019

The issue was in our side. We were referencing another stack and using the wrong username attribute:

const mysqlProvider = new mysql.Provider('mysql', {
    endpoint: rds.apply(r => r.endpoint),
-    username: rds.apply(r => r.username),
+    username: rds.apply(r => r.masterUsername),
    password: rdsRootDatabasePassword.apply(p => p.toString()),
});

Since the username was undefined, it was trying to fallback to the defaults.

I'm closing it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant