-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Managed SQL database instance #1747
Comments
i second this! :) |
I think this needs to be done now that it is in GA. |
Is there anyone working on this or can I start writing a PR for the functionality? |
@jeffreyCline have you started looking into this yet? If not I don't think anybody's working on this from HashiCorp/Microsoft's side, so you should be good @mb290 👍 (thanks in advance 😄) |
@tombuildsstuff maybe I've bitten off much more than I can chew! The RestAPI documentation is available here and relatively straight forward, however i'm really struggling to find a concise list of the options for SKUs: https://docs.microsoft.com/en-us/rest/api/sql/managedinstances/createorupdate There are also lots of dependencies on the VNet that the subnet is in, so i'm trying to figure out the best way to either a) document or b) template this. https://docs.microsoft.com/en-us/azure/sql-database/sql-database-managed-instance-vnet-configuration#requirements The final challenge is for the first SQL MI in a Subnet MS take up to 6 hours to provision so TF is going to require a very large timeout. |
Bump - just checking in to see if there is any movement on this. |
@theharleyquin not at this time - as @mb290 has mentioned the first Managed Instance in a Subnet can take around 6 hours to provision (up to a maximum of 30h) - which makes developing support for this fairly challenging, unfortunately. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I had a chat yesterday with an Azure representative and he promise me that first deployment takes around 35 minutes now. They are selling Managed SQL instances as the way to go for SQL data bases, this Terraform resource is highly needed. |
Currently handling MI db creation with azurerm inline script task within a Azure DevOps release pipeline. All other tasks for IaC uses terraform tasks. Using both task types mean that I have to store release variables in the DevOps variable group and .tfvars. Would be nice to do away with the DevOps variable group and only use the .tfvars but I can't do that until terraform supports MI db creation. YAML for the DevOps task. steps:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@a138076 as mentioned in this comment (in the PR #2727) unfortunately this requires a change coming in 2.0 (custom timeouts) - as such support for this is currently blocked on v2.0 (which we're working on the dependencies for at the moment) |
@TheKangaroo reading the reply from support I believe that's implying "the API is currently working" (e.g. green on the status page) which is unrelated and unfortunately we're still blocked for the reasons outlined above. There's an internal thread with the product/engineering teams tracking this (which support won't have access too) - but afaik at this point we're waiting on the service team to make some changes to the API to support this. Once that's done we should be able to take another look here 👍 |
Ah thank you for the clarification @tombuildsstuff :) |
This comment has been minimized.
This comment has been minimized.
hi @katbyte / @tombuildsstuff , Just a quick question. Currently as per my understanding, Managed instance in TF is not supported yet because of below items:
for option2, if there is any possibility to get Virtual cluster name from the managed instance GET endpoint, use Virtual cluster endpoints to check if it has any other managed instances and delete the virtual cluster if the current managed instance was the last one in it and we handle all this in Managed instance delete method, would that be enough to accept managed instance PR until a more permanent solution for virtual cluster is available ? Asking this because SQL prod team is ready to add extra field for virtual cluster name in get mi rest endpoint and we handle the VC delete logic ourselves in azurerm provider (if the VC doesnt has any other managed instance or pools in it) if and only if Hashicorp team accepts the temp solution I mentioned above. Let me know if that is enough to get my PR for MI get accepted. |
Hey @PriyankaRanganath, thanks for taking the time to right out a detailed response. I will say that the first item on long creation time isn't so much of an issue but the second item is definitely the hangup for us. Unfortunately, while your proposed solution looks straightforward on paper, it causes quite a few issues in implementation. The first that comes to mind is what happens if the virtual cluster fails to delete? The managed instance is gone and now we don't have a way to get to that virtual cluster. We've left the user stranded because of a resource that they didn't even know was created. Since the virtual cluster is the concern of the service, when the last database is gone, it should be safe to remove the subnet; so perhaps the subnet should be de-associated from the virtual cluster during deletion of the db. Terraform users expect Terraform to manage their infrastructure end to end but the virtual cluster that's created outside Terraform breaks that model. I wish we could work around that in Terraform but there aren't any good solutions that we'd be comfortable supporting other than having the service team handle the virtual cluster end to end in a timely manner or to let Terraform handle the virtual cluster end to end. |
Hi @mbfrahry , Thanks for the quick response. Would that temp solution work? |
@PriyankaRanganath the API either needs to expose the VC so that it's manageable by third parties, or delete ths whilst the last MI is being deleted, so I don't believe this approach changes anything unfortunately? |
Hi @tombuildsstuff , If the product team is ready to expose the VC in API endpoint(as well as in Go SDK) so that it could be managed by 3rd parties, As I mentioned previously, SQL product team is ready to expose VC details in the API if and only if Hashicorp team accepts my temp proposed solution. |
@PriyankaRanganath unfortunately whilst the proposed temporary solution may work for the tests in that example, in practice that's not sufficient. To go into a few of these scenarios:
Whilst the solution you've proposed above may fix the first use-case I've mentioned, unfortunately it doesn't work for the rest. We've spent a little time investigating how this API works, and it appears the following Payload is available for Get-ing and Updating Virtual Cluster:
Since the Delete, Get and Update API's are available - meaning Virtual clusters can already be managed by users; and the payload appears to be quite simple - we believe it should be possible to expose the Create API without exposing any further implementation details? This allows for the longer initial provisioning time of the Virtual Cluster to be provisioned one time in these scenarios, and referenced as necessary - enabling users to share this as necessary. The Azure API here could then provision one if a user doesn't specify the ID of an existing Managed Cluster (as is the case in AKS and some other Azure API's). This approach would both allow users to provision/reference existing clusters (which would allow this to work in Terraform) - and have the existing approach working of provisioning a Virtual Cluster behind the scenes. Alternatively Azure could automatically manage the provisioning/deletion of the Virtual Cluster /during/ the deletion of the last Managed Instance within that API - however that would again cause extended deletions when "tainting" (deleting and immediately recreating) the last SQL Managed Instance within a Virtual Cluster. Based on the use-cases above - I don't see how it'd be possible to use this resource without Terraform being able to manage the lifecycle of the Virtual Cluster. It's worth noting from a implementation perspective, since the Delete, Get and Update API calls for a Virtual Cluster are already exposed - this doesn't expose any more implementation details of the Virtual Cluster. It's also possible to do this in a backwards compatible manner - where a user either specifies the ID of an existing Virtual Cluster to provision the Managed Instance within it - or (if they omit this field) then the Azure API can spin up the Virtual Cluster behind the scenes as is done today (and the automatically clean this up as needed). As such is it possible to expose the Create API call here too? cc @JeffreyRichter - since this seems extremely curious from an an ARM perspective that a Resource can be retrieved, updated and deleted - but not provisioned; which feels like an anti-pattern? |
Would it be possible to add at least a data source for the "Azure SQL Managed Instance" and resource for the "Managed database"? Something like this
Also it would be totally wonderful if I could read the existing connection string of the managed instance from supported attributes and move it into a key vault. Also - I cannot imagine anyone using terraform for MI with the instance starting for so many hours, but creation of single databases don't take that long.
edit: grammar |
This comment has been minimized.
This comment has been minimized.
For now, our workaround is using an ARM template. Since it took me a lot of time figuring out how to do it best, I want to spare you the pain and copy past it here for reference. templatemi.tf
mi.json
You can hardcode any of the paramters to make it way shorter. |
Hi juanjojulian, I encounter the same problem. some routes created by SQL MI, Terraform can't control those so My quesion is how you to solve this? thanks a lot |
Hi @cuntoulishifu , we decided not to control any resource related to SQL MI via Terraform, we let SQL MI deployment process create a dedicated route table and NSG and we keep both of them out of Terraform state. Be aware that once deployed, Azure will change both NSG and route table at any time to accommodate any needed change, we found this behaviour in a locked route table associated with a SQL MI and Azure support confirmed it, those resources are under their control and they change them if needed. |
Thank @juanjojulian for your great reply! then looks like hardcode doesn't work as well ... anyway thanks again! |
@juanjojulian and @cuntoulishifu |
I am also using ARM template to deploy Managed Instance, I also want to set Active Directory Admin. I am using below resource however it is asking me to assign Directory Readers role to Instance. Any idea how to tackle this in ARM template? |
I've never done this in arm, I try do deploy as much as I can in terraform, but |
I have tried this. This is actually to deploy RBAC roles. It will not work with Active Directory Roles. |
I would happily wait 6 hours for a managed instance cluster to be created if I could get it under terraform. |
Similarly to others I was forced to do so in ARM, Attached module for reference, it's short, concise and supports create both MI and databases (and returning resource IDs as needed). supports internal only (though it's trivial to change that) and creates the subnet as needed (paradigm I'm using generally as to logically state what I want from a module without inner-wrokings) usage example:
module's main.tf:
module's variables.tf
module's output.tf
|
Is this completed or am i getting confused the changelog for v2.76 mentions azurerm_sql_managed_database but not that azurerm_sql_managed_instance now exists. |
Looks complete: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/sql_managed_instance |
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. |
Community Note
It would be nice if we have a terraform feature for Azure SQL Managed database instance.
The text was updated successfully, but these errors were encountered: