Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ usage: ## Show usage for this Makefile
deploy: ## Deploy the application to LocalStack
bin/deploy.sh

deploy-cdk: ## Deploy the application to LocalStack via CDK
AWS_CMD=awslocal CDK_CMD=cdklocal bin/deploy_cdk.sh

web: ## Open the Web app in the browser (after the app is deployed)
DOMAIN_NAME=$$(awslocal cloudfront list-distributions | jq -r '.DistributionList.Items[0].DomainName'); \
echo "CloudFront URL: https://$$DOMAIN_NAME"; \
Expand Down
4 changes: 2 additions & 2 deletions bin/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ log "API endpoints set up successfully."
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"
--stage-name prod >/dev/null
API_ENDPOINT="http://localhost:4566/_aws/execute-api/$API_ID/prod"
log "API deployed. Endpoint: $API_ENDPOINT"

# SQS DLQ -> EventBridge Pipes -> SNS
Expand Down
5 changes: 5 additions & 0 deletions bin/deploy_cdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ if [ ! -d frontend/build ]; then
)
fi

# bootstrap the stack
(cd cdk
npm run ${CDK_CMD} bootstrap
)

# deploy bulk of the application
(cd cdk
npm run ${CDK_CMD} -- deploy --require-approval never QuizAppStack
Expand Down
2 changes: 1 addition & 1 deletion bin/seed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if [ -z "$API_ID" ]; then
exit 1
fi

API_ENDPOINT="$AWS_ENDPOINT_URL/_aws/execute-api/$API_ID/test"
API_ENDPOINT="$AWS_ENDPOINT_URL/_aws/execute-api/$API_ID/prod"

create_quiz() {
local quiz_data=$1
Expand Down
7 changes: 5 additions & 2 deletions tests/test_infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
import json
import time

API_NAME = 'QuizAPI'
STAGE_NAME = "prod"


@pytest.fixture(scope='module')
def api_endpoint():
apigateway_client = boto3.client('apigateway', endpoint_url='http://localhost:4566')
lambda_client = boto3.client('lambda', endpoint_url='http://localhost:4566')

API_NAME = 'QuizAPI'
response = apigateway_client.get_rest_apis()
api_list = response.get('items', [])
api = next((item for item in api_list if item['name'] == API_NAME), None)
Expand All @@ -19,7 +22,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"
API_ENDPOINT = f"http://localhost:4566/_aws/execute-api/{API_ID}/{STAGE_NAME}"

print(f"API Endpoint: {API_ENDPOINT}")

Expand Down
5 changes: 3 additions & 2 deletions tests/test_outage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from localstack.sdk.chaos.managers import fault_configuration

LOCALSTACK_ENDPOINT = "http://localhost.localstack.cloud:4566"
API_NAME = 'QuizAPI'
API_NAME = "QuizAPI"
STAGE_NAME = "prod"

class TestLocalStackClient:
client = localstack.sdk.chaos.ChaosClient()
Expand All @@ -28,7 +29,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"
API_ENDPOINT = f"{LOCALSTACK_ENDPOINT}/_aws/execute-api/{API_ID}/{STAGE_NAME}"

print(f"API Endpoint: {API_ENDPOINT}")

Expand Down