Skip to content

Commit 579263f

Browse files
committed
addding manual upload scripts to dynamo and s3
1 parent 8749553 commit 579263f

4 files changed

Lines changed: 76 additions & 2 deletions

File tree

scripts/manual_uploads/manual_config_upload.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash#
1+
#!/bin/bash
22

33
# === Config ===
44

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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

scripts/manual_uploads/manual_dynamo_upload.sh

100644100755
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# === Config ===
44
DEFAULT_TABLE="eligibility_data_store"
55
REGION="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 ..."
5758
aws dynamodb put-item \
5859
--table-name "$TABLE" \
5960
--item "file://$FILE" \
60-
--region "$REGION"
61+
--region "$REGION" \
62+
--endpoint-url "$AWS_ENDPOINT_URL"
6163

6264
if [ $? -eq 0 ]; then
6365
echo "Upload complete."
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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

0 commit comments

Comments
 (0)