Terraform-provider-azurerm: Regenerating azurerm_traffic_manager_profile orphans azurerm_traffic_manager_endpoint resources

Created on 27 Jan 2018  ·  6Comments  ·  Source: terraform-providers/terraform-provider-azurerm

EDIT 1/29/2017:

As it turns out, changing the dns_config property _does_ force recreating the traffic manager profile, while changes to the monitor_config _does NOT_ force recreation, _but the endpoint resources are_ ___still orphaned regardless of the change.___


Hi there,

I'm having an issue that when I am forced to regenerate an azurerm_traffic_manager_profile resource, the associated azurerm_traffic_manager_endpoint resources get quietly orphaned from their parent resource and are not regenerated. This results in my traffic manager being regenerated without any endpoints!

These concerns over dependent resource lifecycles appears to to be pretty much the same problem that's described in issue #240 on the AWS provider repo, but I think that just fixing this may not be enough of a solution. That problem needs to be addressed, but the real issue here may be that my traffic manager is getting regenerated when the only thing I change is a value on the monitor_config parameter.

Expected Behavior

When an azurerm_traffic_manager_profile is regenerated, any azurerm_traffic_manager_endpoint resources associated with it are also regenerated.

Also: Changing the monitor_config or dns_config parameters on an azurerm_traffic_manager_profile resource should be low-impact and not destroy resources.

Actual Behavior

Regenerating an azurerm_traffic_manager_profile resource leaves its dependent azurerm_traffic_manager_endpoint resources orphaned and does not recreate them.

Also: Changing non-destructive parameters destroys and regenerates the resource, adding significant risk to modifying an existing, production-deployed resource.

Terraform Version

Terraform v0.11.2
+ provider.azurerm v1.0.1

Affected Resource(s)

Please list the resources as a list, for example:

  • azurerm_traffic_manager_profile
  • azurerm_traffic_manager_endpoint

Terraform Configuration Files

# ***** Traffic Manager *****
resource "azurerm_traffic_manager_profile" "tm" {
    name                             = "${var.traffic_manager_name}"
    resource_group_name  = "${data.azurerm_resource_group.rg.name}"
    traffic_routing_method = "Weighted"

    dns_config {
        relative_name = "${var.traffic_manager_name}"
        ttl           = 60
    }

    monitor_config {
        protocol = "https"
        port     = 443
        path     = "/health"
    }

    tags = "${merge(
        local.common_tags,
        map("objectname", "${var.traffic_manager_name}")
    )}"
}

# ***** Traffic Manager Endpoints *****
resource "azurerm_traffic_manager_endpoint" "east" {
    name                = "${var.east_endpoint_target}"
    resource_group_name = "${data.azurerm_resource_group.rg.name}"
    profile_name        = "${azurerm_traffic_manager_profile.tm.name}"

    target              = "${var.east_endpoint_target}"
    type                = "externalEndpoints"
    endpoint_status     = "${var.enable_east_endpoint ? "Enabled" : "Disabled"}"
    weight              = "${var.east_endpoint_weight}"
}

resource "azurerm_traffic_manager_endpoint" "west" {
    # Some environments won't need a WestUS region. Therefore, no need to have an endpoint pointing there.
    count               = "${var.provision_west_endpoint ? 1 : 0}"

    name                = "${var.west_endpoint_target}"
    resource_group_name = "${data.azurerm_resource_group.rg.name}"
    profile_name        = "${azurerm_traffic_manager_profile.tm.name}"

    target              = "${var.west_endpoint_target}"
    type                = "externalEndpoints"
    endpoint_status     = "${var.enable_west_endpoint ? "Enabled" : "Disabled"}"
    weight              = "${var.west_endpoint_weight}"
}
bug servictraffic-manager upstream-terraform

Most helpful comment

Are there any plans to fix this asap? If I tag traffic manager profile, and the tag changed, the endpoint resources are still orphaned

All 6 comments

We are in the same situation here. When recreating the azure traffic manager because of changing the monitoring port we get our existing endpoints removed.

Running another plan makes terraform notice there are missing endpoints and they get added.

Running version 0.10.0
Azurerm 0.1.2

Might be related to this specific function not gathering endpoint configs?

https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/azurerm/resource_arm_traffic_manager_profile.go#L216

Are there any plans to fix this asap? If I tag traffic manager profile, and the tag changed, the endpoint resources are still orphaned

I agree that this is quite serious. It seems that the only way to change a traffic manager profile is to completely remove it first and then rebuild it from scratch. Just changing it removes the endpoints from the profile.

Same here. Endpoints get created the first time and then removed on any consecutive run even if there is no change to traffic manager. This is obviously pretty bad and takes down everything behind TM.

👋 hi all

Taking a look into this this appears to be an issue in Terraform Core which has previously been requested in this repository in https://github.com/terraform-providers/terraform-provider-azurerm/issues/326. Rather than having multiple issues open tracking the same thing I'm going to close this issue in favour of that one; however in either case this needs to be fixed in Terraform Core (as such it may get moved again, but I figure it's easier to track this in a single issue).

Thanks!

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.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings