Skip to content

Commit

Permalink
Add role assignment for Storage Account Contributor in bootstrap script
Browse files Browse the repository at this point in the history
  • Loading branch information
ShakutaiGit committed Feb 26, 2025
1 parent c496ab2 commit ad89b50
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions devops/terraform/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ else
az storage account show --resource-group "$TF_VAR_mgmt_resource_group_name" --name "$TF_VAR_mgmt_storage_account_name" --output table
fi

# shellcheck disable=SC1091
source ../scripts/mgmtstorage_enable_public_access.sh

# Grant user blob data contributor permissions
echo -e "\n\e[34m»»» 🔑 \e[96mGranting Storage Blob Data Contributor role to the current user\e[0m..."
Expand All @@ -38,6 +36,12 @@ if [ -n "${ARM_CLIENT_ID:-}" ]; then
else
USER_OBJECT_ID=$(az ad signed-in-user show --query id --output tsv)
fi

az role assignment create --assignee "$USER_OBJECT_ID" \
--role "Storage Account Contributor" \
--scope "/subscriptions/$ARM_SUBSCRIPTION_ID/resourceGroups/$TF_VAR_mgmt_resource_group_name/providers/Microsoft.Storage/storageAccounts/$TF_VAR_mgmt_storage_account_name"


az role assignment create --assignee "$USER_OBJECT_ID" \
--role "Storage Blob Data Contributor" \
--scope "/subscriptions/$ARM_SUBSCRIPTION_ID/resourceGroups/$TF_VAR_mgmt_resource_group_name/providers/Microsoft.Storage/storageAccounts/$TF_VAR_mgmt_storage_account_name"
Expand All @@ -55,6 +59,9 @@ while [ -z "$(check_role_assignment)" ]; do
done
echo "Role assignment applied."

# shellcheck disable=SC1091
source ../scripts/mgmtstorage_enable_public_access.sh

# Blob container
# shellcheck disable=SC2154
az storage container create --account-name "$TF_VAR_mgmt_storage_account_name" --name "$TF_VAR_terraform_state_container_name" --auth-mode login -o table
Expand Down

0 comments on commit ad89b50

Please sign in to comment.