hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io
Other
43.14k stars 9.58k forks source link

Terraform support for Migrating Standard to Premium Namespaces in Azure Service Bus #34828

Open rokazeme opened 8 months ago

rokazeme commented 8 months ago

Terraform Version

N/A

Use Cases

The end goal of the feature request is to see if there's any upcoming plans or to open a path in order to support Migration from Standard to Premium Namespaces via Terraform for Azure Service Bus. There are scenarios in which infrastructure as code is used to deploy resources to Azure using a CI/CD pipeline to deploy changes.

Currently Service Bus only supports migration via Azure Portal and CLI : https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-migrate-standard-premium

When using the above methods, we see issues that causes the terraform state to be incompatible and I'd like to see if there are options to automate this using Terraform.

Attempted Solutions

We attempted to alternative approaches:

Option #1:

1. Perform the migration in the Azure Portal/CLI then use the 'import' function to import the properties of the new premium namespace https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/servicebus_namespace#import / [Import | Terraform | HashiCorp Developer](https://developer.hashicorp.com/terraform/cli/import) since we're using CI/CD this appears to be supported also [Import - Configuration Language | Terraform | HashiCorp Developer](https://developer.hashicorp.com/terraform/language/import)

2. Additionally, there's a tool called terrafy [Azure Terrafy – Import your existing Azure infrastructure into Terraform (microsoft.com)](https://techcommunity.microsoft.com/t5/itops-talk-blog/azure-terrafy-import-your-existing-azure-infrastructure-into/ba-p/3357653) that we tried do the import and generate the code for existing resources. 

Option # 2

1. We tried using the AzApi module [Overview of the Terraform AzAPI provider | Microsoft Learn](https://learn.microsoft.com/en-us/azure/developer/terraform/overview-azapi-provider) to recreate the calls made by the portal for migration. For this we wanted to make sure to add plenty of wait time or else the pipeline will fail. We understand this option would probably take the most development, because we'd have to convert the API calls into the terraform syntax.

Proposal

Provide a stream-lined method to support Migration from Standard to Premium Azure Service Bus Namespaces via Terraform.

References

No response

apparentlymart commented 8 months ago

Hi @rokazeme,

I think you are describing something that would be the responsibility of the Azure provider rather than of Terraform Core, but I'm not familiar enough with Azure to know for sure.

Aside from the azure backend for state storage, nothing in this codebase is Azure-specific. The Azure provider's repository would be a good place to discuss Azure-specific needs that are not about the azure state storage backend. The provider development team can open a new issue in this repository if they conclude that what you're asking for is something they'd like to support but would need something new in Terraform Core to achieve it, but we can't do anything in this repository until the Azure provider team has some specific ideas about what new features they might need.