Skip to content

Commit

Permalink
Lock prod resources (#1100)
Browse files Browse the repository at this point in the history
* secrets

* add resource-group to query

* check if scope is right for role
  • Loading branch information
sondresjolyst authored Nov 22, 2023
1 parent 0d9db52 commit e2c5202
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/lock-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
permissions:
id-token: write
contents: read

jobs:
lock-clusters-prod:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scripts/check_resource_lock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ SLACK_WEBHOOK_URL="$(az keyvault secret show \
--name "${KV_SECRET_SLACK_WEBHOOK}" \
--subscription "${AZ_SUBSCRIPTION_ID}" |
jq -r .value)"
CLUSTERS=$(az aks list --output json | jq '{k8s:[.[] | {name: .name, resourceGroup: .resourceGroup, id: .id}]}')
CLUSTERS=$(az aks list --resource-group "${AZ_RESOURCE_GROUP_CLUSTERS}" --output json | jq '{k8s:[.[] | {name: .name, resourceGroup: .resourceGroup, id: .id}]}')

createLock() {
local NAME=$1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function assign_role() {
--assignee "${id}" \
--subscription "${AZ_SUBSCRIPTION_ID}" \
--all \
--query "[?roleDefinitionName=='${role_name}']" \
--query "[?roleDefinitionName=='${role_name}' && scope=='${scope}']" \
--output tsv 2>/dev/null)"

printf "Assigning \"%s\" to \"%s\"... " "${role_name}" "${id_name}"
Expand Down

0 comments on commit e2c5202

Please sign in to comment.