hashicorp / go-azure-helpers

This repository contains various helpers and wrappers for working with Azure and the Azure SDK for Go.
Mozilla Public License 2.0
57 stars 43 forks source link

Resource IDs: support for parsing Data Plane IDs #187

Open tombuildsstuff opened 10 months ago

tombuildsstuff commented 10 months ago

The Resource ID Parser (that is, the resourceids.Parse.Parse function) assumes that we're parsing an ARM-style Resource ID (although these also work for Microsoft Graph), e.g.

/providers/Microsoft.Blah /subscriptions/XXX /subscriptions/XXX/resourceGroups/XXX

However most Data Plane resources use Resource IDs in the format:

https://{accountName}.{domainSuffix}/{segment}/{segment}

Which means these have to be defined by hand today - and means that these don't use the new Resource ID Parser logic, which we'll want going forwards.


Note

Some APIs also (incorrectly) return:

https://{accountName}.{domainSuffix}:{port}/{segment}/{segment}

Note: when the protocol is https and a value for port of 443 is specified, we should be able to trim this from the Domain Suffix for normalization purposes.


As such we're going to need to extend the Resource ID Parser - and the Resource ID Segment types to support parsing Resource IDs in this format.

Whilst the examples above - and the majority of Resource IDs in this format use https as the protocol, we have some instances in AzureRM where it could be useful to validate additional protocols too (e.g. tcp://).

As such I suspect we're going to need to introduce 3 new Resource ID Segment types here:

In addition the Resource ID format functions (.ID() and .String()) will need to be updated to account for this at the same time.

Once this work is completed, Pandora also needs to become aware of the new Resource ID Segment Types - however this can be done in two stages:

  1. Adding the new Constants to Pandora (Importer, Data API and SDK).
  2. Open an issue to track implementing full support for the new Resource ID Segment Types - which'll be needed for supporting Data Plane functionality in Pandora.
manicminer commented 4 months ago

Suggest we consider keeping the segment types generic enough to support nested subdomains, even if it's just a slice of subdomain names. I don't think we need this now but it could cater for a future where mycontainer.myaccount.azureservice.com could arise, and may make it easier to pull out the subdomain type for the likes of Storage.