Skip to content

Following inletsctl create docs for Azure fails with authorization errors. #116

Open
@eltariel

Description

The reference docs for AWS and GCE both contain detailed instructions for setting up the authorization needed to run inletsctl create. The corresponding docs for Azure are incomplete and following them doesn't work without an extra step.

Expected Behaviour

  1. Install inletsctl
  2. Follow the steps listed here: https://docs.inlets.dev/reference/inletsctl/#example-usage-with-azure
  3. Inlets is deployed successfully

Current Behaviour

  • az ad sp create-for-rbac --sdk-auth > ~/Downloads/client_credentials.json prints the following but succeeds anyway:
WARNING: Option '--sdk-auth' has been deprecated and will be removed in a future release.
  • The inletsctl create command shown in the docs (with my subscription id instead of the one in the docs) fails with the following output:
Using provider: azure
Requesting host: elegant-sammet6 in eastus, from azure
2022/01/30 15:40:01 Provisioning host with Azure
2022/01/30 15:40:01 Creating resource group inlets-elegant-sammet6
resources.GroupsClient#CreateOrUpdate: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: Service returned an error. Status=403 Code="AuthorizationFailed" Message="The client '<service-principal-object-id>' with object id '<service-principal-object-id>' does not have authorization to perform action 'Microsoft.Resources/subscriptions/resourcegroups/write' over scope '/subscriptions/<my subscription id>/resourcegroups/
inlets-elegant-sammet6' or the scope is invalid. If access was recently granted, please refresh your credentials."

Possible Solution

The service principal needs to be granted the appropriate authorization to be able to create the resources needed. This is clearly overkill, but assigning the service principle the 'Owner' role at the subscription level works:

az ad sp create-for-rbac -n inletsctl --sdk-auth > az-sp.json
CLIENT_ID=$(jq -r '.clientId' az-sp.json)
SUBSCRIPTION_ID=$(jq -r '.subscriptionId' az-sp.json)
az role assignment create --assignee $CLIENT_ID --role "Owner" --subscription $SUBSCRIPTION_ID
inletsctl create --provider=azure --subscription-id=$SUBSCRIPTION_ID --region=australiaeast --access-token-file=az-sp.json

It should be possible to narrow down the actual permissions required to run the deployment.

Your Environment

  • inlets PRO version: 0.9.3 - 8e96997499ae53c6fb2ae9f9e13fa9b48dcb6514
  • inletsctl version: 0.8.14 - 4034ead
  • Cloud provider and region being used: Azure, eastus and australiaeast
  • Operating System and version (e.g. Linux, Windows, MacOS): WSL2

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions