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.51k stars 4.6k forks source link

Azure Orbital ContactProfile disallows not specifying a Link's IP Addres #21702

Closed andrewf78 closed 1 year ago

andrewf78 commented 1 year ago

Is there an existing issue for this?

Community Note

Terraform Version

1.4.6

AzureRM Provider Version

3.55.0

Affected Resource(s)/Data Source(s)

azurerm_orbital_contact_profile

Terraform Configuration Files

Unfortunately this is a difficult problem to repro on the fly- in order to create a `ContactProfile` where this issue rears it's head, one must first have an Azure Orbital `Spacecraft`, which is required to be manually approved by Azure Orbital Customer Support.

An example `terraform` configuration block which invokes this issue is (anonymized):

resource "azurerm_orbital_contact_profile" "spacecraft-contact-profile" {
  name                              = "my_spacecraft-${var.region_name}"
  resource_group_name               = var.resource_group_name
  location                          = var.region_name
  minimum_variable_contact_duration = "PT1M"
  minimum_elevation_degrees         = 5
  auto_tracking                     = "disabled"

  links {
    name         = "my_spacecraft-uplink-${var.region_name}"
    direction    = "Uplink"
    polarization = "RHCP"
    channels {
      name                 = "my_spacecraft-uplink-channel-${var.region_name}"
      center_frequency_mhz = local.uplinkCenterFrequencyMHz
      bandwidth_mhz        = local.uplinkBandwidthMHz
      end_point {
        end_point_name = var.uplink_source_vm_name
        # This commented out line below should not be necessary
        #ip_address     = 172.0.0.100
        port           = var.uplink_source_port
        protocol       = "UDP"
      }
    }
  }

Debug Output/Panic Output

Attempting to `plan` without specifying an IP Address in the `terraform` configuration:

$ terraform plan
│ Error: Missing required argument
│ 
│   on ../../modules/azure_orbital_musat1/main.tf line 135, in resource "azurerm_orbital_contact_profile" "musat1-profiles":
│  135:       end_point {
│ 
│ The argument "ip_address" is required, but no definition was found.

Attempting to parse a manually updated Link without an IP Address specified:

$ terraform plan
Stack trace from the terraform-provider-azurerm_v3.55.0_x5 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x5733648]

goroutine 1728 [running]:
github.com/hashicorp/terraform-provider-azurerm/internal/services/orbital.flattenContactProfileChannel({0xc001894c00?, 0x1, 0xc0005d94a0?})
        github.com/hashicorp/terraform-provider-azurerm/internal/services/orbital/helper.go:287 +0x148
github.com/hashicorp/terraform-provider-azurerm/internal/services/orbital.flattenContactProfileLinks({0xc001e1d080?, 0x3, 0x75e5100?})
        github.com/hashicorp/terraform-provider-azurerm/internal/services/orbital/helper.go:265 +0x190
github.com/hashicorp/terraform-provider-azurerm/internal/services/orbital.ContactProfileResource.Read.func1({0x75f2d48, 0xc001b5a840}, {0xc000a7fc00, {0x75f34f0, 0xc000556a08}, 0xc001abbb80, 0x0, {0x75f4670, 0xbb4de68}})
        github.com/hashicorp/terraform-provider-azurerm/internal/services/orbital/contact_profile_resource.go:195 +0x54b
github.com/hashicorp/terraform-provider-azurerm/internal/sdk.(*ResourceWrapper).Resource.func3({0x75f2d48, 0xc001b5a840}, 0x45d964b3ec?, {0x617ec60?, 0xc000a7fc00?})
        github.com/hashicorp/terraform-provider-azurerm/internal/sdk/wrapper_resource.go:65 +0x159
github.com/hashicorp/terraform-provider-azurerm/internal/sdk.diagnosticsWrapper.func1({0x75f2d48, 0xc001b5a840}, 0x0?, {0x617ec60, 0xc000a7fc00})
        github.com/hashicorp/terraform-provider-azurerm/internal/sdk/wrapper_resource.go:185 +0xbe
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0009da380, {0x75f2d80, 0xc002641ad0}, 0xd?, {0x617ec60, 0xc000a7fc00})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/resource.go:724 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0009da380, {0x75f2d80, 0xc002641ad0}, 0xc00130d1e0, {0x617ec60, 0xc000a7fc00})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/resource.go:1015 +0x585
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc00172ca98, {0x75f2d80?, 0xc0026419b0?}, 0xc002614bc0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/grpc_provider.go:613 +0x4a5
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc0012826e0, {0x75f2d80?, 0xc0026413e0?}, 0xc002957e60)
        github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/tf5server/server.go:748 +0x4b1
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x6918760?, 0xc0012826e0}, {0x75f2d80, 0xc0026413e0}, 0xc002b81260, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002501e0, {0x76027c0, 0xc0012d8000}, 0xc001f94c60, 0xc001826e70, 0xbb0d430, 0x0)
        google.golang.org/grpc@v1.51.0/server.go:1340 +0xd23
google.golang.org/grpc.(*Server).handleStream(0xc0002501e0, {0x76027c0, 0xc0012d8000}, 0xc001f94c60, 0x0)
        google.golang.org/grpc@v1.51.0/server.go:1713 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.51.0/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.51.0/server.go:963 +0x28a

Error: The terraform-provider-azurerm_v3.55.0_x5 plugin crashed!

Expected Behaviour

The Contact Profile link should be allowed to be configured without an IP Address, for Virtual RF type Uplink channels only, as this connection is made over a UDP socket.

Originally I had created the necessary resources via terraform, however for some "radio-in-the-loop" testing the Azure Orbital team had requested that we set the Uplink IP Address to empty. This is not possible via terraform, and changing it manually causes future plan operations to segfault (I would expect the change to be detected and reverted, but not for the provider to seg-fault)

The Azure Orbital Documentation explains the desired configuration of a network, for this virtual RF + Uplink use-case: image

Actual Behaviour

Referencing the error logs above:

1) link.ip_address is a required parameter, so one cannot create a resource in line with the desired configuration.

2) If a link is manually changed to the emtpy/null value, terraform seg-faults on refreshing the state. (See: Debug/Panic output section)

Steps to Reproduce

  1. terraform plan

Important Factoids

A spacecraft object required Azure CS approval, among other requirements.

References

No response

github-actions[bot] commented 1 year ago

This functionality has been released in v3.56.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

github-actions[bot] commented 3 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.