File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- #! /bin/bash#
1+ #! /bin/bash
22
33# === Config ===
44
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -e
3+
4+ # Start LocalStack (assumes localstack is installed and in path)
5+ echo " Starting LocalStack for S3..."
6+ localstack start -d
7+ sleep 5
8+
9+ export AWS_ACCESS_KEY_ID=test
10+ export AWS_SECRET_ACCESS_KEY=test
11+ export AWS_DEFAULT_REGION=us-east-1
12+ export AWS_ENDPOINT_URL=http://localhost:4566
13+
14+ # Create mock S3 bucket
15+ aws --endpoint-url=$AWS_ENDPOINT_URL s3 mb s3://test-bucket
16+
17+ # Create test file
18+ echo ' { "test": "value" }' > testfile.json
19+
20+ # Run the script
21+ echo " Testing manual_config_upload.sh..."
22+ ./manual_config_upload.sh testfile.json test-bucket
23+
24+ # List contents
25+ echo " Contents of bucket:"
26+ aws --endpoint-url=$AWS_ENDPOINT_URL s3 ls s3://test-bucket/manual-uploads/
27+
28+ # Cleanup
29+ rm testfile.json
30+ localstack stop
Original file line number Diff line number Diff line change 33# === Config ===
44DEFAULT_TABLE=" eligibility_data_store"
55REGION=" eu-west-2"
6+ AWS_ENDPOINT_URL=" ${AWS_ENDPOINT_URL:- https:// dynamodb.${REGION} .amazonaws.com} "
67
78# === Usage Check ===
89
@@ -57,7 +58,8 @@ echo "Uploading item from $FILE to table $TABLE ..."
5758aws dynamodb put-item \
5859 --table-name " $TABLE " \
5960 --item " file://$FILE " \
60- --region " $REGION "
61+ --region " $REGION " \
62+ --endpoint-url " $AWS_ENDPOINT_URL "
6163
6264if [ $? -eq 0 ]; then
6365 echo " Upload complete."
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -e
3+
4+ # Start LocalStack (assumes localstack is installed and in path)
5+ echo " Starting LocalStack for DynamoDB..."
6+ localstack start -d
7+ sleep 5
8+
9+ export AWS_ACCESS_KEY_ID=test
10+ export AWS_SECRET_ACCESS_KEY=test
11+ export AWS_DEFAULT_REGION=eu-west-2
12+ export AWS_ENDPOINT_URL=http://localhost:4566
13+
14+ # Create DynamoDB table
15+ aws --endpoint-url=$AWS_ENDPOINT_URL dynamodb create-table \
16+ --table-name test-table \
17+ --attribute-definitions AttributeName=UserId,AttributeType=S \
18+ --key-schema AttributeName=UserId,KeyType=HASH \
19+ --billing-mode PAY_PER_REQUEST
20+
21+ # Create test item in DynamoDB JSON format
22+ cat << EOF > testitem.json
23+ {
24+ "UserId": { "S": "123" },
25+ "Email": { "S": "localstack@test.com" },
26+ "Score": { "N": "100" }
27+ }
28+ EOF
29+
30+ # Run the script
31+ echo " Testing manual_dynamo_upload.sh..."
32+ ./manual_dynamo_upload.sh testitem.json test-table
33+
34+ # Query item
35+ echo " Querying DynamoDB table:"
36+ aws --endpoint-url=$AWS_ENDPOINT_URL dynamodb get-item \
37+ --table-name test-table \
38+ --key ' { "UserId": { "S": "123" } }'
39+
40+ # Cleanup
41+ rm testitem.json
42+ localstack stop
You can’t perform that action at this time.
0 commit comments