# During AWS hosted events using event engine tool # we pre-provision cloudfront and s3 buckets which hosts UI code. # So that it improves this labs total execution time. # Below code checks if cloudfront and s3 buckets are # pre-provisioned or not and then concludes if the workshop # is running in AWS hosted event through event engine tool or not. IS_RUNNING_IN_EVENT_ENGINE=false PREPROVISIONED_ADMIN_SITE=$(aws cloudformation list-exports --query "Exports[?Name=='Serverless-SaaS-AdminAppSite'].Value" --output text) if [ ! -z "$PREPROVISIONED_ADMIN_SITE" ]; then echo "Workshop is running in WorkshopStudio" IS_RUNNING_IN_EVENT_ENGINE=true ADMIN_SITE_URL=$(aws cloudformation list-exports --query "Exports[?Name=='Serverless-SaaS-AdminAppSite'].Value" --output text) LANDING_APP_SITE_URL=$(aws cloudformation list-exports --query "Exports[?Name=='Serverless-SaaS-LandingApplicationSite'].Value" --output text) APP_SITE_URL=$(aws cloudformation list-exports --query "Exports[?Name=='Serverless-SaaS-ApplicationSite'].Value" --output text) fi echo "server code is getting deployed" cd ../server REGION=$(aws configure get region) echo "Validating server code using pylint" python3 -m pylint -E -d E0401 $(find . -iname "*.py" -not -path "./.aws-sam/*" -not -path "./TenantPipeline/node_modules/*") if [[ $? -ne 0 ]]; then echo "****ERROR: Please fix above code errors and then rerun script!!****" exit 1 fi sam build -t shared-template.yaml --use-container if [ "$IS_RUNNING_IN_EVENT_ENGINE" = true ]; then sam deploy --config-file shared-samconfig.toml --region=$REGION --parameter-overrides EventEngineParameter=$IS_RUNNING_IN_EVENT_ENGINE AdminUserPoolCallbackURLParameter=$ADMIN_SITE_URL TenantUserPoolCallbackURLParameter=$APP_SITE_URL else sam deploy --config-file shared-samconfig.toml --region=$REGION --parameter-overrides EventEngineParameter=$IS_RUNNING_IN_EVENT_ENGINE fi echo "Pooled tenant server code is getting deployed" REGION=$(aws configure get region) sam build -t tenant-template.yaml --use-container sam deploy --config-file tenant-samconfig.toml --region=$REGION cd ../scripts if [ "$IS_RUNNING_IN_EVENT_ENGINE" = false ]; then ADMIN_SITE_URL=$(aws cloudformation describe-stacks --stack-name serverless-saas --query "Stacks[0].Outputs[?OutputKey=='AdminAppSite'].OutputValue" --output text) LANDING_APP_SITE_URL=$(aws cloudformation describe-stacks --stack-name serverless-saas --query "Stacks[0].Outputs[?OutputKey=='LandingApplicationSite'].OutputValue" --output text) APP_SITE_URL=$(aws cloudformation describe-stacks --stack-name serverless-saas --query "Stacks[0].Outputs[?OutputKey=='ApplicationSite'].OutputValue" --output text) fi echo "Admin site URL: https://$ADMIN_SITE_URL" echo "Landing site URL: https://$LANDING_APP_SITE_URL" echo "App site URL: https://$APP_SITE_URL"