Open bdorplatt opened 2 years ago
Hi,
I suspect it is because of mock_outputs_merge_strategy_with_state
value which can take no_merge/shallow/deep_map_only
values, true
works with legacy field mock_outputs_merge_with_state
https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/
Hello, I realize now that the sample code I pasted above was after a last ditch attempt to get this working. It, of course, errored out with Include merge strategy true is unknown. Valid strategies are: no_merge, shallow, deep, deep_map_only"
Using any of the newer options below results in Error: could not read new Service Plan to check tier Service Plan mock_outputs_merge_strategy_with_state = "shallow" mock_outputs_merge_strategy_with_state = "no_merge" mock_outputs_merge_strategy_with_state = "deep_map_only"
Since the legacy field is now deprecated and the documentation is telling is to use mock_outputs_merge_strategy_with_state, it seems there may be a need to fix this with the new merge options.
I've update the issue above with the correct code.
Providing an update here. With further testing through an Issue on the Terraform side, we found that a plan does run successfully when using the resource ID of an existing App Service Plan (actual resource existing in Azure) entered as the mock output in the terragrunt.hcl of the Function app. For reference: https://github.com/hashicorp/terraform-provider-azurerm/issues/17376
Since the whole point of mock outputs is to not have resources already existing, an adjustment to how Terragrunt handles this resource type will probably be needed.
While using a real ASP ID is a sort of workaround, it isn't sustainable since if the referenced App Service Plan is deleted, the code will be broken. This also doesn't work if the app is being deployed in a new subscription or a subscription that doesn't have any App Service Plans deployed yet.
Is there a resource that can take a look at this?
We are having this issue as well - anyone have an update to this?
Is this still an issue? Any workaround other then specifying the actual service plan?
We haven't found a workaround yet and occasionally have deployments fail as old ASP's referenced are decommissioned. We then have to reference another real service plan, unfortunately, to get things going again. We opened a more recent issue https://github.com/gruntwork-io/terragrunt/issues/2324 for this with more detail and it has been added to the Terragrunt Roadmap so hopefully it will be resolved in the near future.
Running a plan against the new azurerm_windows_function_app resource results in the error below and will not accept a mock output and continue. The exact same setup with the deprecated azurerm_function_app works as expected and honors the mock values. Based on the error details, it appears the new resource requires actually seeing what tier the service plan is on and it can't get that from a mock value. Both tests were performed using the new azurerm_service_plan resource for the app service plan.
Error: could not read new Service Plan to check tier Service Plan: (Serverfarm Name "mock-asp" / Resource Group "mock-rg"): web.AppServicePlansClient#Get: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceGroupNotFound" Message="Resource group 'mock-rg' could not be found."
Function App resource resource "azurerm_windows_function_app" "function_app" { app_settings = var.fa_app_settings location = var.region name = "test-azf" resource_group_name = var.resource_group_name service_plan_id = var.fa_service_plan_id }
Dependency and Input in Terrarunt.hcl include { path = find_in_parent_folders() } dependency "app_service_plan01" { config_path = "../../appserviceplan/appserviceplan01" mock_outputs = { asp_id = "/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/mockrg/providers/Microsoft.Web/serverfarms/mockasp" } mock_outputs_allowed_terraform_commands = ["validate", "plan"] mock_outputs_merge_strategy_with_state = "shallow" }
inputs = { fa_service_plan_id = dependency.app_service_plan01.outputs.asp_id }
Output from the App Service Plan module output "asp_id" { description = "ID of ASP" value = module.asp.asp_id }