-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into onemacmmdl
- Loading branch information
Showing
59 changed files
with
1,969 additions
and
262 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
This /scripts Folder simply contains scripts that are not used in the application or deployed via lambda but are useful for admin type functions. | ||
|
||
##### | ||
|
||
generate_packages - creates new records in Under Review status by inserting both a OneMAC record and a SEATool record | ||
rebuildPackagesbyPK - force a rebuild of the package record for all packages listed in pk_values.json | ||
setPOCs - set the action_officers (srt) and lead_analyst (cpoc) for all packages listed in pk_values.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/bin/bash | ||
|
||
# Variables | ||
USER_POOL_ID="us-east-1_9NXuk7ucb" | ||
INPUT_FILE="users.json" | ||
DYNAMODB_TABLE="onemac-masterclone-one" | ||
DATE=$(date +%s%3N) # Current timestamp in milliseconds | ||
|
||
# Read the JSON file and loop through each user | ||
jq -c '.users[]' $INPUT_FILE | while read -r user; do | ||
PASSWORD=$(echo $user | jq -r '.password') | ||
EMAIL=$(echo $user | jq -r '.email') | ||
FAMILY_NAME=$(echo $user | jq -r '.family_name') | ||
GIVEN_NAME=$(echo $user | jq -r '.given_name') | ||
ROLE=$(echo $user | jq -r '.role') | ||
|
||
# Concatenate given name and family name to form full name | ||
FULL_NAME="$GIVEN_NAME $FAMILY_NAME" | ||
|
||
# Determine territory and GSI fields based on role | ||
if [ "$ROLE" = "systemadmin" ]; then | ||
TERRITORY="N/A" | ||
GSI1SK="Boss" | ||
GSI1PK="systemadmin#N/A" | ||
else | ||
TERRITORY=$(echo $user | jq -r '.territory') | ||
GSI1SK="statesystemadmin#$TERRITORY" | ||
GSI1PK="USER" | ||
fi | ||
|
||
echo "Creating user with email: $EMAIL" | ||
|
||
# Use the email as the username in Cognito | ||
aws cognito-idp admin-create-user \ | ||
--user-pool-id "$USER_POOL_ID" \ | ||
--username "$EMAIL" \ | ||
--user-attributes Name="email",Value="$EMAIL" \ | ||
Name="family_name",Value="$FAMILY_NAME" \ | ||
Name="given_name",Value="$GIVEN_NAME" \ | ||
Name="email_verified",Value="true" \ | ||
--message-action SUPPRESS | ||
|
||
# Set the password and mark the user as confirmed | ||
aws cognito-idp admin-set-user-password \ | ||
--user-pool-id "$USER_POOL_ID" \ | ||
--username "$EMAIL" \ | ||
--password "$PASSWORD" \ | ||
--permanent | ||
|
||
echo "User created with email (used as username): $EMAIL" | ||
|
||
# Insert ContactInfo record into DynamoDB | ||
aws dynamodb put-item --table-name "$DYNAMODB_TABLE" --item \ | ||
'{"pk": {"S": "'"$EMAIL"'"}, | ||
"sk": {"S": "ContactInfo"}, | ||
"email": {"S": "'"$EMAIL"'"}, | ||
"fullName": {"S": "'"$FULL_NAME"'"}, | ||
"GSI1pk": {"S": "'"$GSI1PK"'"}, | ||
"GSI1sk": {"S": "'"$EMAIL"'"} }' | ||
|
||
echo "ContactInfo record created for user: $EMAIL" | ||
|
||
# Insert Roles record into DynamoDB | ||
aws dynamodb put-item --table-name "$DYNAMODB_TABLE" --item \ | ||
'{"pk": {"S": "'"$EMAIL"'"}, | ||
"sk": {"S": "v0#'"$ROLE"'#'"$TERRITORY"'"}, | ||
"date": {"N": "'"$DATE"'"}, | ||
"doneByEmail": {"S": "'"$EMAIL"'"}, | ||
"doneByName": {"S": "'"$FULL_NAME"'"}, | ||
"email": {"S": "'"$EMAIL"'"}, | ||
"fullName": {"S": "'"$FULL_NAME"'"}, | ||
"GSI1pk": {"S": "'"$GSI1PK"'"}, | ||
"GSI1sk": {"S": "'"$GSI1SK"'"}, | ||
"GSI2pk": {"S": "'"$ROLE"'#'"$TERRITORY"'"}, | ||
"GSI2sk": {"S": "active"}, | ||
"Latest": {"S": "1"}, | ||
"role": {"S": "'"$ROLE"'"}, | ||
"status": {"S": "active"}, | ||
"territory": {"S": "'"$TERRITORY"'"} }' | ||
|
||
echo "Roles record created for user: $EMAIL" | ||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# Variables | ||
DYNAMODB_TABLE="onemac-masterclone-one" | ||
PK_VALUES=("NY-24-9356" "NY-24-6035" "NY-24-3865" "NY-24-1282" "NY-24-1036" "NY-24-9253" "NY-24-9972" "NY-24-1717" "NY-24-5342" "NY-24-8523" "NY-24-1571" "NY-24-7203" "NY-80815.R01.02" "NY-66338.R01.02" "NY-84734.R01.00" "NY-23214.R01.02" "NY-94872.R00.00" "NY-93400.R00.00" "NY-72598.R01.02" "NY-84074.R01.00" "NY-49584.R00.01" "NY-52227.R00.00" "NY-27845.R01.00" "NY-95809.R00.01" "NY-53801.R01.02" "NY-38783.R00.01" "NY-75550.R00.01" "NY-92181.R01.00" "NY-18445.R00.00" "NY-57782.R01.00" "NY-52513.R00.00" "NY-99845.R00.01" "NY-76823.R00.01" "NY-42146.R01.02" "NY-52725.R00.00" "NY-14938.R01.00") | ||
|
||
# Counter for deleted items | ||
DELETED_COUNT=0 | ||
|
||
# Loop through each pk value | ||
for PK in "${PK_VALUES[@]}"; do | ||
# Query DynamoDB for items with the specified pk | ||
ITEMS=$(aws dynamodb query \ | ||
--table-name "$DYNAMODB_TABLE" \ | ||
--key-condition-expression "pk = :pk" \ | ||
--expression-attribute-values '{":pk": {"S": "'"$PK"'"}}' \ | ||
--projection-expression "pk, sk" \ | ||
--output json | jq -c '.Items[]') | ||
|
||
# Loop through the found items and delete them | ||
echo "$ITEMS" | while read -r item; do | ||
pk=$(echo "$item" | jq -r '.pk.S') | ||
sk=$(echo "$item" | jq -r '.sk.S') | ||
|
||
# Skip if pk or sk is empty | ||
if [[ -z "$pk" || -z "$sk" ]]; then | ||
continue | ||
fi | ||
|
||
# Delete the record | ||
aws dynamodb delete-item \ | ||
--table-name "$DYNAMODB_TABLE" \ | ||
--key "{\"pk\": {\"S\": \"$pk\"}, \"sk\": {\"S\": \"$sk\"}}" | ||
|
||
echo "Deleted record with pk: $pk and sk: $sk" | ||
((DELETED_COUNT++)) | ||
done | ||
done | ||
|
||
# Output the total number of deleted items | ||
echo "Total number of deleted items: $DELETED_COUNT" |
Oops, something went wrong.