Skip to content

feat: use the cloud endpoints from the credentials for sovereign clouds - #156

Open
blacksoxx wants to merge 1 commit into
upbound:mainfrom
blacksoxx:sovereign-cloud-endpoints
Open

blacksoxx wants to merge 1 commit into
upbound:mainfrom
blacksoxx:sovereign-cloud-endpoints

Conversation

@blacksoxx

Copy link
Copy Markdown

Description of your changes

Both credential paths created the azidentity credential and the armresourcegraph client with nil options, so every query went to login.microsoftonline.com and management.azure.com whatever cloud the subscription lived in; with Azure Government credentials that fails with NoValidSubscriptionsInQueryRequest, as reported in #73.

The function now reads the endpoint URLs that az ad sp create-for-rbac --sdk-auth writes into the credentials JSON. activeDirectoryEndpointUrl and resourceManagerEndpointUrl select the cloud: the public, Government and China endpoints map to the SDK's built-in cloud.Configuration values, so the Resource Manager audience is the SDK's own; any other pair is used as given, with managementEndpointUrl as the token audience when present; and an unknown Resource Manager endpoint without its authority is an error rather than a silent fallback to the public cloud. The configuration is passed to the credential and to the Resource Graph client for both service principal and workload identity credentials. Credentials without these keys behave exactly as before. The README gains a "Sovereign clouds" section.

Fixes #73

I have:

TestCloudConfiguration covers the public, Government and China endpoints (with and without trailing slashes, and with only the authority given), a custom cloud with and without managementEndpointUrl, and the error case. go test ./... passes and the repository's golangci-lint configuration reports only the goconst findings that fn_test.go already has on main. Not run against a live Azure Government tenant.

The identity and the Resource Graph client were created with nil options,
so every query targeted the public cloud and Azure Government credentials
failed with NoValidSubscriptionsInQueryRequest. The endpoint URLs that
az ad sp create-for-rbac --sdk-auth writes into the credentials now select
the cloud: the public, Government and China endpoints map to the SDK's own
configurations, any other pair is used as given with managementEndpointUrl
as the token audience, and the configuration reaches both the credential
and the client for service principal and workload identity alike.

Signed-off-by: Youssef Omar Bouden <youssef.bouden2002@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Azure US Government

1 participant