hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.64k forks source link

Azure Orbital Contact Profile - adding a channel should not require deleting the contact profile #25078

Closed rmelick-muon closed 8 months ago

rmelick-muon commented 8 months ago

Is there an existing issue for this?

Community Note

Terraform Version

1.3.9

AzureRM Provider Version

3.93.0

Affected Resource(s)/Data Source(s)

azurerm_orbital_contact_profile

Terraform Configuration Files

Original terraform configuration

resource "azurerm_resource_group" "modify-channels" {
  name     = "tests"
  location = "westus2"
}

resource "azurerm_virtual_network" "modify-channels" {
  name                = "modify-channels-vnet"
  resource_group_name = azurerm_resource_group.modify-channels.name
  location            = azurerm_resource_group.modify-channels.location

  address_space = [
    "192.168.1.0/24",
  ]
}

resource "azurerm_subnet" "modify-channels" {
  name                 = "modify-channels-subnet"
  resource_group_name  = azurerm_resource_group.modify-channels.name
  virtual_network_name = azurerm_virtual_network.modify-channels.name

  address_prefixes = [
    "192.168.1.0/24"
  ]

  delegation {
    name = "Microsoft.Orbital.orbitalGateways"
    service_delegation {
      name = "Microsoft.Orbital/orbitalGateways"
      actions = [
        "Microsoft.Network/publicIPAddresses/join/action",
        "Microsoft.Network/virtualNetworks/subnets/join/action",
        "Microsoft.Network/virtualNetworks/read",
        "Microsoft.Network/publicIPAddresses/read"
      ]
    }
  }
}

resource "azurerm_orbital_contact_profile" "modify-channels" {
  name                              = "ModifyChannels"
  resource_group_name               = azurerm_resource_group.modify-channels.name
  location                          = "westus2"
  minimum_variable_contact_duration = "PT1M"
  minimum_elevation_degrees         = 5
  auto_tracking                     = "disabled"

  links {
    name         = "Test-Downlink"
    direction    = "Downlink"
    polarization = "RHCP"
    channels {
      name                 = "Channel1"
      center_frequency_mhz = 8160
      bandwidth_mhz        = 15
      end_point {
        end_point_name = "test"
        ip_address     = "192.168.1.1"
        port           = "50000"
        protocol       = "UDP"
      }
    }

#    channels {
#      name                 = "Channel2"
#      center_frequency_mhz = 8060
#      bandwidth_mhz        = 15
#      end_point {
#        end_point_name = "test"
#        ip_address     = "192.168.1.1"
#        port           = "50001"
#        protocol       = "UDP"
#      }
#    }
  }

  network_configuration_subnet_id = azurerm_subnet.modify-channels.id
  event_hub_uri = "XXX"
}

Terraform config that adds a new channel to the Contact Profile


resource "azurerm_resource_group" "modify-channels" {
  name     = "tests"
  location = "westus2"
}

resource "azurerm_virtual_network" "modify-channels" {
  name                = "modify-channels-vnet"
  resource_group_name = azurerm_resource_group.modify-channels.name
  location            = azurerm_resource_group.modify-channels.location

  address_space = [
    "192.168.1.0/24",
  ]
}

resource "azurerm_subnet" "modify-channels" {
  name                 = "modify-channels-subnet"
  resource_group_name  = azurerm_resource_group.modify-channels.name
  virtual_network_name = azurerm_virtual_network.modify-channels.name

  address_prefixes = [
    "192.168.1.0/24"
  ]

  delegation {
    name = "Microsoft.Orbital.orbitalGateways"
    service_delegation {
      name = "Microsoft.Orbital/orbitalGateways"
      actions = [
        "Microsoft.Network/publicIPAddresses/join/action",
        "Microsoft.Network/virtualNetworks/subnets/join/action",
        "Microsoft.Network/virtualNetworks/read",
        "Microsoft.Network/publicIPAddresses/read"
      ]
    }
  }
}

resource "azurerm_orbital_contact_profile" "modify-channels" {
  name                              = "ModifyChannels"
  resource_group_name               = azurerm_resource_group.modify-channels.name
  location                          = "westus2"
  minimum_variable_contact_duration = "PT1M"
  minimum_elevation_degrees         = 5
  auto_tracking                     = "disabled"

  links {
    name         = "Test-Downlink"
    direction    = "Downlink"
    polarization = "RHCP"
    channels {
      name                 = "Channel1"
      center_frequency_mhz = 8160
      bandwidth_mhz        = 15
      end_point {
        end_point_name = "test"
        ip_address     = "192.168.1.1"
        port           = "50000"
        protocol       = "UDP"
      }
    }

    channels {
      name                 = "Channel2"
      center_frequency_mhz = 8060
      bandwidth_mhz        = 15
      end_point {
        end_point_name = "test"
        ip_address     = "192.168.1.1"
        port           = "50001"
        protocol       = "UDP"
      }
    }
  }

  network_configuration_subnet_id = azurerm_subnet.modify-channels.id
  event_hub_uri = "XXX"
}

Debug Output/Panic Output

Here is the output of terraform plan


Terraform will perform the following actions:

  # module.XXX.azurerm_orbital_contact_profile.modify-channels must be replaced
-/+ resource "azurerm_orbital_contact_profile" "modify-channels" {
      ~ id                                = "/subscriptions/XXX/resourceGroups/tests/providers/Microsoft.Orbital/contactProfiles/ModifyChannels" -> (known after apply)
        name                              = "ModifyChannels"
      - tags                              = {} -> null
        # (7 unchanged attributes hidden)

      ~ links {
            name         = "Test-Downlink"
            # (2 unchanged attributes hidden)

          ~ channels { # forces replacement
                name                 = "Channel1"
                # (2 unchanged attributes hidden)

                # (1 unchanged block hidden)
            }
          + channels { # forces replacement
              + bandwidth_mhz        = 15
              + center_frequency_mhz = 8060
              + name                 = "Channel2"

              + end_point {
                  + end_point_name = "test"
                  + ip_address     = "192.168.1.1"
                  + port           = "50001"
                  + protocol       = "UDP"
                }
            }
        }
    }

Plan: 1 to add, 0 to change, 1 to destroy.

Expected Behaviour

Adding an additional channel should not require deleting the contact profile. The API has a way to update the contact profile. And, from the Azure portal I am able to add a new channel without deleting the contact profile.

Screenshot 2024-02-28 at 6 53 40 AM Screenshot 2024-02-28 at 6 53 29 AM

Actual Behaviour

The terraform plan showed that it needed to delete the contact profile before it could add a channel.

Steps to Reproduce

  1. terraform plan

Important Factoids

No response

References

No response

rmelick-muon commented 8 months ago

Terraform needing to delete the contact profile is an issue, because you cannot delete a contact profile if you have ever used that profile to conduct a Contact in the past (unless you also delete all of those past Contact objects)

ziyeqf commented 8 months ago

Hi @rmelick-muon, thanks for reporting.

I have opened a PR for this(https://github.com/hashicorp/terraform-provider-azurerm/pull/25129), once it merged & released it should be fixed.

Thanks

rmelick-muon commented 8 months ago

Thanks @ziyeqf! Looking forward to testing once it's released :)

github-actions[bot] commented 6 months ago

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.