-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
mysql provider and mysql_database resource #3122
Conversation
sounds awesome, but do we really want this in mainline tf? I wish we could have this be in its own repo, but also be able to use it from atlas. le sigh |
@josephholsten, @phinze suggested to me that "non-esoteric" use-cases belong in Terraform core. I think MySQL passes that test, since it's used by many different organizations. However, I'd be happy to maintain this as an out-of-tree plugin if that is preferred. (That comment from @phinze also includes a trick for using out-of-tree plugins with Atlas.) |
I'm sold on non-esoteric. And I must have misread your RDS use case, it makes total sense. Is this ready for beta testers? (& I was afraid that was the trick into atlas doing what I want.) |
I believe this is ready, but I've not actually put it into practical use yet since I've not reached the point of setting up the shared RDS cluster that this was intended for. So far I've only tested it in a very academic way on a local mysql server, so if others would like to test it in other contexts that would be much appreciated. |
Based on the experiences of @chelarua in #3653 I have reworked this so that it is the resource actions themselves that create the database connection, rather than trying to share a connection across the whole Terraform run. This serves two purposes:
|
My intended future scope for this provider is to get the database set up to the point where an app's own database management infrastructure can take over. In my experience most applications expect to be provided with the following:
I specifically do not intend this provider to ever have things like |
Incidentally, since my earlier comment I've started using this provider in real infrastructure configs, to create databases on RDS instances. Aside from the aforementioned chicken-and-egg problem when creating the RDS instance and the MySQL database within a single config (which my latest modifications should work around) it has been working just fine. (So far we've been working around it by using |
The ``mysql_database`` resource creates and manages a database on a MySQL | ||
server. | ||
|
||
~> **Caution:** The ``consul_database`` resource can completely delete your |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here, mysql_database
I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha that's a pretty great typo. I can only imagine what was going on in my brain when I typed that. Thanks, will fix!
Just got a chance to review this. One doc typo but otherwise this is looking great! Merge at will. |
@apparentlymart Is it possible to configure multiple mysql providers? for example if we have multiple |
@winglian Terraform core has the idea of a "provider alias" that allows multiple providers of the same type to be instantiated. For the MySQL provider that would look something like this: provider "mysql" {
alias = "foo"
// ... and then other mysql provider arguments
}
provider "mysql" {
alias = "bar"
// ... and then other mysql provider arguments
}
resource "mysql_database" "foo" {
// Select the appropriate provider using its alias
provider = "mysql.foo"
// ... and then other mysql_database arguments
}
resource "mysql_database" "bar" {
// Select the appropriate provider using its alias
provider = "mysql.bar"
// ... and then other mysql_database arguments
} You can read more about this in the "Multiple Provider Instances" section of the provider configuration docs page. |
+1 on high level objects. Is somebody already working on user/grants resources? |
was just wondering about this myself… |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Allows databases on pre-existing MySQL servers to be created and managed by Terraform.
In future I imagine this provider growing to be able to manage other top-level MySQL objects like users, permission grants and system configuration variables. To start it supports only databases, since that is my main use-case for now (creating additional databases on an RDS instance once it has booted.)