Created
September 26, 2023 20:06
-
-
Save craigmdennis/f75deadeedc2626eea79e2d003bd974a to your computer and use it in GitHub Desktop.
Update Cloudflare Access Group IP address based on current public IP address from the requestor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ACCOUNT_ID="YOUR_ACCOUNT_ID" | |
GROUP_ID="YOUR_ACCESS_GROUP_ID" | |
GROUP_NAME="YOUR_ACCESS_GROUP_NAME" | |
API_TOKEN="YOUR_CLOUDFLARE_API_KEY" | |
IP_ADDRESS=$(curl -s https://api.ipify.org) | |
curl --request PUT \ | |
--url https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/groups/$GROUP_ID \ | |
--header 'Content-Type: application/json' \ | |
--header "Authorization: Bearer $API_TOKEN" \ | |
--data '{ | |
"include": [ | |
{ | |
"ip": { | |
"ip": "'"$IP_ADDRESS"'" | |
} | |
} | |
], | |
"name": "$GROUP_NAME" | |
}' | |
echo "Updated $GROUP_NAME to include $IP_ADDRESS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment