Created
March 25, 2024 17:43
-
-
Save vdhanan/52f8fd9321dbedc3198488335bd2fd64 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
TABLE_NAME="identity-users" | |
ATTRIBUTE_NAME="farcasterID" | |
ATTRIBUTE_VALUE="7811" | |
# Step 1: Scan the table and filter items based on the condition | |
KEYS=$(aws dynamodb scan \ | |
--table-name "$TABLE_NAME" \ | |
--filter-expression "farcasterID = :val" \ | |
--expression-attribute-values '{":val":{"S":"'"$ATTRIBUTE_VALUE"'"}}' \ | |
--query "Items[].userID.S" \ | |
--output text) | |
# Step 2: Iterate over the keys and remove the attribute for each item | |
for KEY in $KEYS; do | |
aws dynamodb update-item \ | |
--table-name "$TABLE_NAME" \ | |
--key '{"userID": {"S": "'"$KEY"'"}}' \ | |
--update-expression "REMOVE $ATTRIBUTE_NAME" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment