Skip to content

Commit

Permalink
Add support for user-assigned managed identity login for TFE agent
Browse files Browse the repository at this point in the history
  • Loading branch information
chianw authored Nov 2, 2023
1 parent 6d647ea commit efd36d8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions agents/tfc/login.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ if [[ -v ARM_CLIENT_SECRET ]]; then
az login --service-principal -u $ARM_CLIENT_ID -p $ARM_CLIENT_SECRET -t $ARM_TENANT_ID --allow-no-subscriptions >/dev/null >&1
fi

if [[ -v ARM_SUBSCRIPTION_ID ]]; then
if [[ -v MSI-RESOURCE-ID ]]; then
echo "Logging with the user-assigned managed identity. ($MSI-RESOURCE-ID)"
az login --identity -u $(MSI-RESOURCE-ID) -t $ARM_TENANT_ID --allow-no-subscriptions >/dev/null >&1
fi

if [[ -v ARM_SUBSCRIPTION_ID ] || [ -v SUBSCRIPTION_ID ]]; then
ARM_SUBSCRIPTION_ID=${ARM_SUBSCRIPTION_ID:="$SUBSCRIPTION_ID"}
echo "Set the subscription to $ARM_SUBSCRIPTION_ID."
az account set -s $ARM_SUBSCRIPTION_ID
az account show -o json | jq
fi
fi

0 comments on commit efd36d8

Please sign in to comment.