-
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
Implement State Backend (with locking) on MySQL/MariaDB #23531
Comments
What advantage would this offer over encrypted S3 / DynamoDB storage? |
Large enterprises sometimes prefer to keep their state on premises; I guess that's what the Postgres remote state backend is for; etcv2 and etcv3 can have the same role, but they have a hard limit on key and tfstate size, so as of today one is effectively left with a limited choice. So, why not add a MySQL state backend? Some shops may even prefer MySQL over Postgres... Terraform is not only for cloud systems, we're using it for internal systems management (AD, Oracle DB, Jenkins...) with a few custom providers and no public cloud resource involved and it plays its role nicely. That said, I'd like to point out that S3 has a limitation when not used in the implementation provided my AWS: lack of locking (sorry, no DynamoDB on premises...). The "standard" S3 APIs only support "WORM" locks on a specific version of an object in a versioned bucket, no advisory locks. For enterprises that have bought their own appliances exporting S3 storage - BTW there's a whole market with players such as IBM, Hitachi, NetApp, Scality, EMC and many others - it's a big shortcoming. I believe that maybe workspace locking should be considered a cross-cutting concern that might, as well as might not, be implemented by the same state backend provider. That's what I'm planning to implement next on S3 state backend once I've cut my teeth on MySQL, in the hope it will be accepted upstream someday. |
Please take a look at the pull request, we're here for your comments and suggestions. |
@dihedron I just closed the linked PR because we are not currently accepting community-contributed state backends. I wrote up a full explanation of why in that PR, so I'll quote it here in case other folks are watching:
|
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. |
Proposal
The current version of Terraform does not support MySQL/MariaDB as a backend for tfstate management.
After taking a look at the sources, it seems to me that the addition should be attainable with limited effort; at first glance it looks like these are the necessary changes:
postgres
withmysql
insql.Open
instructionsname
andstate
toLONGTEXT
(IIRCTEXT
on MySQL can store up to 65k, whereas on Postgres it has no limit);create table
SQL statement to add the unique index onname
contextually, in order to avoid the followingcreate unique index
statement.Put()
func inclient.go
so that the SQL readsselect get_lock(name, timeout)
( see https://dev.mysql.com/doc/refman/5.7/en/locking-functions.html).The code changes don't seem to be overwhelming (am I missing something???) and it looks like it may even be possible to have a single "RDBMS" backend with support for both PG and MySQL by adding a single parameter to the backend db_type = "mysql|posgres" and a few switches where the SQL syntax differs. I expect Oracle to be quite like Postgres but have not investigated yet and have no Oracle DB available at home.
I have very little spare time but I'd be very glad to invest it in implementing this feature if you think it may be useful to others too.
The text was updated successfully, but these errors were encountered: