Skip to content

Commit c332bb6

Browse files
authored
Merge pull request #15 from aws-samples/fix-grooming-res
chore: move and refactor bootstrap scripts
2 parents e18d340 + 9fe21c1 commit c332bb6

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.

import_ddb_data.sh renamed to script/init/import.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
#!/bin/bash
2+
3+
export AWS_REGION=us-west-2
4+
15
#Get the list of dynamodb tables from amplify cli
2-
table_name=$(aws dynamodb list-tables --query 'TableNames[0]')
6+
table_name=$(aws dynamodb list-tables --output text --region $AWS_REGION --query 'TableNames[0]')
37

48
#Get the index from the dynamodb tables
59
index_name=$(echo "${table_name}" | awk -F '-' '{print $2}')
@@ -18,11 +22,13 @@ echo "class_name: ${class_name}"
1822
current_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
1923

2024
#Replace the table_name
21-
sed -i "s/Course/$course_name/g" Course.json
22-
sed -i "s/Class/$class_name/g" Class.json
23-
sed -i "s/replace_time/$current_time/g" Course.json
24-
sed -i "s/replace_time/$current_time/g" Class.json
25+
sed -i '' -e "s/Course/$course_name/g" Course.json
26+
sed -i '' -e "s/Class/$class_name/g" Class.json
27+
sed -i '' -e "s/replace_time/$current_time/g" Course.json
28+
sed -i '' -e "s/replace_time/$current_time/g" Class.json
2529

2630
#Insert the data into tables
2731
aws dynamodb batch-write-item --request-items file://Course.json
28-
aws dynamodb batch-write-item --request-items file://Class.json
32+
aws dynamodb batch-write-item --request-items file://Class.json
33+
34+
unset AWS_REGION
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)