terraform-provider-azurerm
terraform-provider-azurerm copied to clipboard
Support for Azure App Service Slot Swap
I was able to successfully deploy followed the document https://docs.microsoft.com/en-us/azure/developer/terraform/provision-infrastructure-using-azure-deployment-slots. However, any subsequence slot swap of the same slot will not work since Terraform configuration won't change from application deployment to the slot. This seems to be a one way push from any slot to production. The deployment slot designed to have bi-directional swap. The user should be able to swap the slots back i.e. dev to production or production to dev. Terraform module is https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service_active_slot. It would be great to have this capability.
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Description
New or Affected Resource(s)
- azurerm_XXXXX
Potential Terraform Configuration
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.
References
https://docs.microsoft.com/en-us/azure/developer/terraform/provision-infrastructure-using-azure-deployment-slots https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service_active_slot
- #0000
I just ran across this issue. As a workaround, I created an isolated swap folder with basically the bare minimum for the swap active slot action. Then on the terraform plan (or apply depending on your setup), I used the -replace option in order to get the swap to always happen. It forces the replacement of the swap resource, which is not an actual mapped entity to azure, only to terraform. So replacing it gets the desired effect.
Example:
terraform plan -replace="azurerm_app_service_active_slot.mySlot"
terraform apply
The swapping between slots seems to be a feature that still needs to be tackled. A full implementation of slot swapping I would imagine would have:
-
Support for swapping any slot with any other slot.
-
An attribute showing which slot was the last swapped slot?
-
A data source showing what the last slot swap was?
-
If the API supports it, rampup routing using percentage like can be achieved from the slot page in the portal.