diff --git a/README.md b/README.md index a42eb22..e961d03 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ The output will be: ```bash CloudFront URL: https://1e372b81.cloudfront.localhost.localstack.cloud -API Gateway Endpoint: http://localhost:4566/_aws/execute-api/4xu5emxibf/test/_user_request_ +API Gateway Endpoint: http://localhost:4566/_aws/execute-api/4xu5emxibf/test ``` Navigate to the CloudFront URL to check out the app. The script would also seed some quiz data and user data to make local testing easier. diff --git a/bin/deploy.sh b/bin/deploy.sh index 41279ca..056d464 100755 --- a/bin/deploy.sh +++ b/bin/deploy.sh @@ -91,18 +91,18 @@ FUNCTIONS=( log "Creating IAM policies and roles for Lambda functions..." for FUNCTION_INFO in "${FUNCTIONS[@]}"; do read FUNCTION_NAME POLICY_FILE ROLE_NAME <<< "$FUNCTION_INFO" - + log "Creating IAM policy for $FUNCTION_NAME..." awslocal iam create-policy \ --policy-name ${FUNCTION_NAME}Policy \ --policy-document file://${POLICY_FILE} >/dev/null - + log "Creating IAM role $ROLE_NAME..." ROLE_ARN=$(awslocal iam create-role \ --role-name ${ROLE_NAME} \ --assume-role-policy-document file://configurations/lambda_trust_policy.json \ --query 'Role.Arn' --output text) - + log "Attaching policy to role $ROLE_NAME..." awslocal iam attach-role-policy \ --role-name ${ROLE_NAME} \ @@ -141,7 +141,7 @@ LAMBDAS=( for LAMBDA_INFO in "${LAMBDAS[@]}"; do read FUNCTION_NAME ZIP_FILE ROLE_NAME <<< "$LAMBDA_INFO" - + log "Creating Lambda function $FUNCTION_NAME..." awslocal lambda create-function \ --function-name ${FUNCTION_NAME} \ @@ -190,21 +190,21 @@ ENDPOINTS=( for ENDPOINT_INFO in "${ENDPOINTS[@]}"; do read PATH_PART HTTP_METHOD FUNCTION_NAME <<< "$ENDPOINT_INFO" - + log "Setting up API endpoint /$PATH_PART [$HTTP_METHOD] -> $FUNCTION_NAME" - + RESOURCE_ID=$(awslocal apigateway create-resource \ --rest-api-id $API_ID \ --parent-id $PARENT_ID \ --path-part $PATH_PART \ --query 'id' --output text) - + awslocal apigateway put-method \ --rest-api-id $API_ID \ --resource-id $RESOURCE_ID \ --http-method $HTTP_METHOD \ --authorization-type "NONE" >/dev/null - + awslocal apigateway put-integration \ --rest-api-id $API_ID \ --resource-id $RESOURCE_ID \ @@ -220,7 +220,7 @@ log "Deploying API..." awslocal apigateway create-deployment \ --rest-api-id $API_ID \ --stage-name test >/dev/null -API_ENDPOINT="http://localhost:4566/_aws/execute-api/$API_ID/test/_user_request_" +API_ENDPOINT="http://localhost:4566/_aws/execute-api/$API_ID/test" log "API deployed. Endpoint: $API_ENDPOINT" # SQS DLQ -> EventBridge Pipes -> SNS @@ -348,7 +348,7 @@ LAMBDA_PERMISSIONS=( for PERMISSION_INFO in "${LAMBDA_PERMISSIONS[@]}"; do read FUNCTION_NAME HTTP_METHOD PATH_PART <<< "$PERMISSION_INFO" - + log "Adding permission for $FUNCTION_NAME to be invoked by API Gateway..." awslocal lambda add-permission \ --function-name ${FUNCTION_NAME} \ diff --git a/bin/seed.sh b/bin/seed.sh index e306fcb..bf9e5d6 100755 --- a/bin/seed.sh +++ b/bin/seed.sh @@ -25,14 +25,14 @@ if [ -z "$API_ID" ]; then exit 1 fi -API_ENDPOINT="$AWS_ENDPOINT_URL/_aws/execute-api/$API_ID/test/_user_request_" +API_ENDPOINT="$AWS_ENDPOINT_URL/_aws/execute-api/$API_ID/test" create_quiz() { local quiz_data=$1 local response=$(curl -s -X POST "$API_ENDPOINT/createquiz" \ -H "Content-Type: application/json" \ -d "$quiz_data") - + if [ "$(echo $response | jq -r 'has("QuizID")')" = "true" ]; then local quiz_id=$(echo $response | jq -r '.QuizID') log "Created quiz with ID: $quiz_id" diff --git a/frontend/scripts/populate.sh b/frontend/scripts/populate.sh index 4ee6b7e..00f3507 100755 --- a/frontend/scripts/populate.sh +++ b/frontend/scripts/populate.sh @@ -14,7 +14,7 @@ if [ -z "$API_ID" ]; then exit 1 fi -API_ENDPOINT="$AWS_ENDPOINT_URL/_aws/execute-api/$API_ID/test/_user_request_" +API_ENDPOINT="$AWS_ENDPOINT_URL/_aws/execute-api/$API_ID/test" echo "REACT_APP_API_ENDPOINT=$API_ENDPOINT" > .env.local diff --git a/tests/test_infra.py b/tests/test_infra.py index cb900f4..c6c73fc 100644 --- a/tests/test_infra.py +++ b/tests/test_infra.py @@ -19,7 +19,7 @@ def api_endpoint(): raise Exception(f"API {API_NAME} not found.") API_ID = api['id'] - API_ENDPOINT = f"http://localhost:4566/_aws/execute-api/{API_ID}/test/_user_request_" + API_ENDPOINT = f"http://localhost:4566/_aws/execute-api/{API_ID}/test" print(f"API Endpoint: {API_ENDPOINT}") diff --git a/tests/test_outage.py b/tests/test_outage.py index b47eced..5ead843 100644 --- a/tests/test_outage.py +++ b/tests/test_outage.py @@ -28,7 +28,7 @@ def api_endpoint(apigateway_client): raise Exception(f"API {API_NAME} not found.") API_ID = api['id'] - API_ENDPOINT = f"{LOCALSTACK_ENDPOINT}/_aws/execute-api/{API_ID}/test/_user_request_" + API_ENDPOINT = f"{LOCALSTACK_ENDPOINT}/_aws/execute-api/{API_ID}/test" print(f"API Endpoint: {API_ENDPOINT}") @@ -38,11 +38,11 @@ def api_endpoint(apigateway_client): def test_dynamodb_outage(api_endpoint): outage_rule = FaultRule(region="us-east-1", service="dynamodb") - + # Using fault_configuration context manager to apply and automatically clean up the fault rule with fault_configuration(fault_rules=[outage_rule]): print("DynamoDB outage initiated within context.") - + # Attempt to create a quiz during the outage create_quiz_payload = { "Title": "Outage Test Quiz",