Looking for Recommendations on MySQL Terraform Providers

0
3
Asked By TechWhiz123 On

Hey everyone! I'm making a transition to configuration as code and we've had success using a PostgreSQL provider that helped us manage users and roles. Now I'm looking to do something similar with MySQL. Does anyone have suggestions for a good Terraform provider for MySQL?

6 Answers

Answered By LambdaWizard On

I went through the same search for a MySQL provider and ended up trying *petoju*, but I eventually moved to writing a custom lambda for kicking off my RDS setup. Just a note: Pulumi still seems to support PostgreSQL if that's something you're considering when evaluating your options.

QuestioningDev -

Is Pulumi free or do they have subscription costs?

Answered By DevOpsNerd On

We looked into this a while ago, and honestly, the *petoju/mysql* provider is a solid choice at the moment. It's not flawless, but it covers the basics like users and grants pretty well. Just keep in mind that MySQL's permission model can be a bit trickier than PostgreSQL, so you might run into some inconsistencies with idempotency.

Answered By AnsibleFan12 On

Have you considered using Ansible for these tasks instead of Terraform? Why are you leaning toward Terraform specifically?

Answered By CloudGuru78 On

A lot of teams are moving away from using Terraform for MySQL configuration. They often split it up like this:

- **Infrastructure (Terraform)**: Handles RDS/CloudSQL/MySQL instances, networking, backups, flags.
- **Schema + Users**: Managed with tools like Flyway or Liquibase.

The reason for this is that Terraform providers for database internals aren't as mature, and managing the lifecycle/state can get pretty messy. According to Atlas docs, while Terraform is great for provisioning DB infrastructure, schema management usually gets handled separately.

Answered By SkepticalDev On

We probably should, but honestly it's just me managing this, and I don't want to deal with AWX for Ansible. Some people argue that Ansible shouldn't be used for provisioning cloud resources, though!

Answered By CodeMaster99 On

The official HashiCorp MySQL provider is archived, so definitely avoid that. Check out the *petoju/mysql* provider instead; it's actively maintained and widely used now. It supports users, roles, databases, and grants, so it should feel familiar if you've used the PostgreSQL one. It even includes support for AWS RDS IAM, Azure AD, and GCP Cloud SQL. You can set it up like this:

```
terraform {
required_providers {
mysql = {
source = "petoju/mysql"
version = "~> 3.0"
}
}
}
```
I've had solid experiences with it! You can find more info in its registry docs [here](https://registry.terraform.io/providers/petoju/mysql/latest/docs).

CuriousDev -

That's just what I needed to hear. Thanks a ton!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.