Skip to content

Instantly share code, notes, and snippets.

@mmaravich
Created March 23, 2026 14:10
Show Gist options
  • Select an option

  • Save mmaravich/ffedbea4e5319f8f740f782c324ebfb2 to your computer and use it in GitHub Desktop.

Select an option

Save mmaravich/ffedbea4e5319f8f740f782c324ebfb2 to your computer and use it in GitHub Desktop.
Atlas CLI add current IP to all projects
#!/bin/bash
# 1. Calculate the expiration time (ISO 8601 format) 24 hours from now
# This syntax works for GNU/Linux.
# For macOS, use: EXPIRY_DATE=$(date -u -v+24H +"%Y-%m-%dT%H:%M:%SZ")
EXPIRY_DATE=$(date -u -d "+24 hours" +"%Y-%m-%dT%H:%M:%SZ")
echo "Target Expiration: $EXPIRY_DATE"
echo "-----------------------------------"
# 2. Fetch all projects (extracting ID and Name for better logging)
# Requires 'jq' to be installed
projects=$(atlas projects list --output json | jq -c '.results[] | {id: .id, name: .name}')
if [ -z "$projects" ]; then
echo "No projects found or not logged in."
exit 1
fi
# 3. Loop through each project and add the current IP
echo "$projects" | while read -r project; do
id=$(echo "$project" | jq -r '.id')
name=$(echo "$project" | jq -r '.name')
echo "Updating Project: $name ($id)..."
atlas accessLists create --currentIp \
--projectId "$id" \
--deleteAfter "$EXPIRY_DATE" \
--comment "Temporary script-added access" \
--output json > /dev/null
if [ $? -eq 0 ]; then
echo "Successfully added IP to $name."
else
echo "Failed to add IP to $name."
fi
done
echo "-----------------------------------"
echo "Process Complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment