Open Konnor5092 opened 1 week ago
Hi @Konnor5092 thanks for opening this issue. In this case, you could add create_before_destroy = true
in the lifecycle of the azurerm_resource_group_template_deployment.logic_app_workflow_test_5
to ensure that the dependent resource is updated after it is re-created. For detailed usage of create_before_destroy
, please refer to here.
Hi @Konnor5092 thanks for opening this issue. In this case, you could add
create_before_destroy = true
in the lifecycle of theazurerm_resource_group_template_deployment.logic_app_workflow_test_5
to ensure that the dependent resource is updated after it is re-created. For detailed usage ofcreate_before_destroy
, please refer to here.
This doesn't seem to work unfortunately because although the azurerm_resource_group_template_deployment.logic_app_workflow_test_5
resource now waits for the azurerm_logic_app_workflow.logic_app_test_5
resource to finish it's modifications, it just ends up deleting the logic app in the portal when it does the destroy after the create.
E.g. consider the following plan....
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated
with the following symbols:
~ update in-place
+/- create replacement and then destroy
Terraform will perform the following actions:
# azurerm_logic_app_workflow.logic_app_test_5 will be updated in-place
~ resource "azurerm_logic_app_workflow" "logic_app_test_5" {
id = "/subscriptions/1df892a8-7803-4661-ae7f-1fd171821a6a/resourceGroups/pip-exec-dev/providers/Microsoft.Logic/workflows/product-feed-dev-5"
name = "product-feed-dev-5"
tags = {}
# (12 unchanged attributes hidden)
~ access_control {
~ content {
~ allowed_caller_ip_address_range = [
- "82.38.118.111/32",
+ "82.38.118.110/31",
]
}
# (2 unchanged blocks hidden)
}
}
# azurerm_resource_group_template_deployment.logic_app_workflow_test_5 must be replaced
+/- resource "azurerm_resource_group_template_deployment" "logic_app_workflow_test_5" {
~ id = "/subscriptions/1df892a8-7803-4661-ae7f-1fd171821a6a/resourceGroups/pip-exec-dev/providers/Microsoft.Resources/deployments/workflow-product-feed-5-542409e0cedb1c6f17be55805b4e91d7" -> (known after apply)
~ name = "workflow-product-feed-5-542409e0cedb1c6f17be55805b4e91d7" -> "workflow-product-feed-5-3747d1eb0875c87cdc321f95d8c4fa13" # forces replacement
~ output_content = jsonencode({}) -> (known after apply)
- tags = {} -> null
~ template_content = jsonencode(
~ {
~ resources = [
~ {
name = "[parameters('workflow_name')]"
~ properties = {
~ accessControl = {
~ contents = {
~ allowedCallerIpAddresses = [
~ {
~ addressRange = "82.38.118.111/32" -> "82.38.118.110/32"
},
]
}
# (2 unchanged attributes hidden)
}
# (3 unchanged attributes hidden)
}
# (3 unchanged attributes hidden)
},
]
# (4 unchanged attributes hidden)
}
)
# (5 unchanged attributes hidden)
}
Plan: 1 to add, 1 to change, 1 to destroy.
Retuns the following.....
azurerm_logic_app_workflow.logic_app_test_5: Modifying... [id=/subscriptions/1df892a8-7803-4661-ae7f-1fd171821a6a/resourceGroups/pip-exec-dev/providers/Microsoft.Logic/workflows/product-feed-dev-5]
azurerm_logic_app_workflow.logic_app_test_5: Modifications complete after 0s [id=/subscriptions/1df892a8-7803-4661-ae7f-1fd171821a6a/resourceGroups/pip-exec-dev/providers/Microsoft.Logic/workflows/product-feed-dev-5]
azurerm_resource_group_template_deployment.logic_app_workflow_test_5: Creating...
azurerm_resource_group_template_deployment.logic_app_workflow_test_5: Still creating... [10s elapsed]
azurerm_resource_group_template_deployment.logic_app_workflow_test_5: Still creating... [20s elapsed]
azurerm_resource_group_template_deployment.logic_app_workflow_test_5: Still creating... [30s elapsed]
azurerm_resource_group_template_deployment.logic_app_workflow_test_5: Creation complete after 32s [id=/subscriptions/1df892a8-7803-4661-ae7f-1fd171821a6a/resourceGroups/pip-exec-dev/providers/Microsoft.Resources/deployments/workflow-product-feed-5-3747d1eb0875c87cdc321f95d8c4fa13]
azurerm_resource_group_template_deployment.logic_app_workflow_test_5 (deposed object b7097105): Destroying... [id=/subscriptions/1df892a8-7803-4661-ae7f-1fd171821a6a/resourceGroups/pip-exec-dev/providers/Microsoft.Resources/deployments/workflow-product-feed-5-542409e0cedb1c6f17be55805b4e91d7]
azurerm_resource_group_template_deployment.logic_app_workflow_test_5: Still destroying... [id=/subscriptions/1df892a8-7803-4661-ae7f-...eed-5-542409e0cedb1c6f17be55805b4e91d7, 10s elapsed]
azurerm_resource_group_template_deployment.logic_app_workflow_test_5: Destruction complete after 18s
When you create first, you end up with 2 ARM deployments pointing at the same resource after the create completes
It then deletes the old ARM deployment, which unfortunately deletes the resource it's linked to for both ARM deployment records.
If you try to go to the resource via the newer ARM deployment you just see this...
Is there an existing issue for this?
Community Note
Terraform Version
1.85
AzureRM Provider Version
3.62.1
Affected Resource(s)/Data Source(s)
azurerm_resource_group_template_deployment
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
When updating a
azurerm_resource_group_template_deployment
resource that depends on aazurerm_logic_app_workflow
resource that is also updated in the same plan, theazurerm_resource_group_template_deployment
resource should finish destroying and recreating before theazurerm_logic_app_workflow
resource updatesActual Behaviour
The
azurerm_logic_app_workflow
resource tries updating before theazurerm_resource_group_template_deployment
resource has finished recreating, resulting in the following error.You can see the problem here - You get
Destruction complete
and beforeazurerm_resource_group_template_deployment
has been recreated, it attempts to modifyazurerm_logic_app_workflow
which now doesn't existSteps to Reproduce
../logic-apps/product-feed-5.json
plan
andapply
azurerm_resource_group_template_deployment.logic_app_workflow_test_5
resource, e.g. changing a value on the ip address inaccess_control
../logic-apps/product-feed-5.json
, e.g. changing a value on the ip address inaccessControl
plan
andapply
Root object was present, but now absent
error generatedExample simple logic app workflow ARM template here...
Example terraform plan that causes this problem
Important Factoids
No response
References
No response