-
Notifications
You must be signed in to change notification settings - Fork 3
NI-191: WIP to fit floci into local dev build #105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
teddmason
wants to merge
10
commits into
development
Choose a base branch
from
feature/floci-spike
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b20851c
WIP to fit floci into local dev build
teddmason 0d2a684
updating to use floci 2.0.1 after pr completion
teddmason 6876e8c
documentation and variable updates for floci update
teddmason 088aecd
updating aws calls to set --endpoint-url
teddmason 38882ec
Fix CPX_AGW_URL to select REST API by name and use AWS_ENDPOINT_URL
Copilot 2572bfd
Fix load-dummy-data.sh to select REST API by name via AWS_ENDPOINT_URL
Copilot f5edabc
Potential fix for pull request finding
teddmason e727581
Potential fix for pull request finding
teddmason 8fd9b3f
Fix create_resource clobbering global root resource id
Copilot d251fe5
removing -debug from bootstrap command#
teddmason File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,4 @@ | ||
| { | ||
| "version": "2.0.0", | ||
| "tasks": [ | ||
| { | ||
| "label": "Wait Remote Debugger Server", | ||
| "type": "shell", | ||
| "command": "while [[ -z $(docker ps | grep :9229) ]]; do sleep 1; done; sleep 1;" | ||
| } | ||
| ] | ||
| "tasks": [] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,14 @@ | ||
| # Activate LocalStack Pro: https://docs.localstack.cloud/getting-started/auth-token/ | ||
| LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN:-} # required for Pro, not processed via template due to security reasons | ||
| LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY:-} | ||
| # LocalStack configuration: https://docs.localstack.cloud/references/configuration/ | ||
| ACTIVATE_PRO=false | ||
| DEBUG=false | ||
| LS_LOG=info | ||
| PERSISTENCE=false | ||
| AWS_ENDPOINT_URL=http://localhost.localstack.cloud:4566 | ||
| LOCALSTACK_HOST=localhost.localstack.cloud:4566 | ||
| AUTO_LOAD_POD= | ||
| ENFORCE_IAM=false | ||
| AWS_REGION=eu-west-2 | ||
| FLOCI_SERVICES_LAMBDA_HOT_RELOAD_ENABLED=true | ||
| # FLOCI_STORAGE_MODE=memory | ||
| AWS_ENDPOINT_URL=http://localhost:4566 | ||
| AWS_ACCESS_KEY_ID=test | ||
| AWS_SECRET_ACCESS_KEY=test | ||
| AWS_DEFAULT_REGION=eu-west-2 | ||
| # LocalStack community edition is sufficient | ||
| IMAGE_NAME=localstack/localstack:latest | ||
| AWS_REGION=eu-west-2 | ||
| AWS_PAGER= | ||
| # FLOCI_HOSTNAME=floci | ||
| FLOCI_DEFAULT_REGION=eu-west-2 | ||
| LAMBDA_TIMEOUT=9999999 | ||
| # Comment the line below and create a new containerised development environment to disable debugging of Lambda functions. | ||
| # IMPORTANT - If cloning the remote repository into a container volume, the change must be pushed to a pull request | ||
| # branch from which a new containerised development environment is created. If a new containerised development environment | ||
| # is not created, running multiple Lambda functions without remote debug limitations will not be possible. | ||
| LAMBDA_DOCKER_FLAGS="-e NODE_OPTIONS=--inspect-brk=0.0.0.0:9229 -p 9229:9229" | ||
| # Let Docker select a matching image based on the host operating system and architecture. | ||
| LAMBDA_IGNORE_ARCHITECTURE=1 | ||
|
|
||
| # The address of the host running the Lambda function to be debugged. | ||
| # | ||
| # IMPORTANT | ||
| # When using a development container based local development environment, if the address does not match | ||
| # the address of the container running the Lambda function to be debugged, the debugger will NOT attach. | ||
| # The default value is for use in a development container based local development environment running | ||
| # four containers on the host machine BEFORE the container running the Lambda function to be debugged. | ||
| # - Dev container | ||
| # - LocalStack container | ||
| # - Postgres container | ||
| # - PgAdmin4 container | ||
| # | ||
| # When not using a development container the Lambda function to be debugged will run on the host machine | ||
| # (IP address 127.0.0.1). When not using a development container and using Visual Studio Code for debugging, | ||
| # this environment variable MUST be set to 127.0.0.1 and available to the session used to launch Visual Studio | ||
| # Code WITHOUT modifying this file. | ||
| # IMPORTANT - A change to this value MUST NOT be pushed to the remote repository as it will prevent | ||
| # debugging when cloning the remote repository into a container volume. | ||
| DEBUG_HOST_ADDRESS=192.168.0.5 | ||
| CPX_DB_HOST=capxmldb | ||
| NODEJS_VERSION=24 | ||
| [email protected] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,12 +3,15 @@ | |
| # See https://containers.dev/implementors/json_reference/. | ||
| set -e | ||
|
|
||
| . docker/scripts/set-local-aws-environment.sh | ||
|
|
||
| main() { | ||
| # Reference - https://docs.localstack.cloud/user-guide/aws/apigateway/ | ||
| # Reference - https://docs.aws.amazon.com/cli/latest/reference/apigateway/ | ||
| echo "Creating API Gateway" | ||
| echo $AWS_ENDPOINT_URL | ||
|
|
||
| cap_xml_rest_api_id=$(awslocal apigateway create-rest-api --name "FWS API Gateway" | jq -r '.id') | ||
| cap_xml_rest_api_root_resource_id=$(awslocal apigateway get-resources --rest-api-id $cap_xml_rest_api_id | jq -r '.items[0].id') | ||
| cap_xml_rest_api_id=$(aws --endpoint-url "$AWS_ENDPOINT_URL" apigateway create-rest-api --name "CPX API Gateway" | jq -r '.id') | ||
| cap_xml_rest_api_root_resource_id=$(aws --endpoint-url "$AWS_ENDPOINT_URL" apigateway get-resources --rest-api-id "$cap_xml_rest_api_id" | jq -r '.items[] | select(.path == "/") | .id') | ||
| lambda_functions_dir="lib/functions" | ||
|
Copilot marked this conversation as resolved.
|
||
|
|
||
| find "$lambda_functions_dir" -type f -name "*.js" | while read -r lambda_function; do | ||
|
|
@@ -37,9 +40,13 @@ main() { | |
|
|
||
| done | ||
|
|
||
| awslocal apigateway create-deployment \ | ||
| --rest-api-id $cap_xml_rest_api_id \ | ||
| --stage-name local | ||
| deployment_id=$(aws --endpoint-url "$AWS_ENDPOINT_URL" apigateway create-deployment \ | ||
| --rest-api-id $cap_xml_rest_api_id | jq -r '.id') | ||
|
|
||
| aws --endpoint-url "$AWS_ENDPOINT_URL" apigateway create-stage \ | ||
| --rest-api-id $cap_xml_rest_api_id \ | ||
| --stage-name local \ | ||
| --deployment-id $deployment_id | ||
|
|
||
| echo "Created API Gateway deployment" | ||
| return 0 | ||
|
|
@@ -94,19 +101,32 @@ register_api_gateway_support_for_process_message() { | |
| } | ||
|
|
||
| create_resource() { | ||
| cap_xml_rest_api_root_resource_id=$1 | ||
| cap_xml_rest_api_parent_resource_id=$1 | ||
| cap_xml_rest_api_path_part=$2 | ||
|
Comment on lines
103
to
105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 8fd9b3f: |
||
| echo $(awslocal apigateway create-resource \ | ||
|
|
||
| # A resource with the same parent and path part may already have been created | ||
| # by another lambda function (e.g. GET /message/{id} and POST /message share /message). | ||
| existing_resource_id=$(aws --endpoint-url "$AWS_ENDPOINT_URL" apigateway get-resources \ | ||
| --rest-api-id $cap_xml_rest_api_id \ | ||
| | jq -r --arg parent "$cap_xml_rest_api_parent_resource_id" --arg path "$cap_xml_rest_api_path_part" \ | ||
| '.items[] | select(.parentId == $parent and .pathPart == $path) | .id') | ||
|
|
||
| if [ -n "$existing_resource_id" ]; then | ||
| echo $existing_resource_id | ||
| return 0 | ||
| fi | ||
|
|
||
| echo $(aws --endpoint-url "$AWS_ENDPOINT_URL" apigateway create-resource \ | ||
| --rest-api-id $cap_xml_rest_api_id \ | ||
| --parent-id $cap_xml_rest_api_root_resource_id \ | ||
| --parent-id $cap_xml_rest_api_parent_resource_id \ | ||
| --path-part $cap_xml_rest_api_path_part | jq -r '.id') | ||
| return 0 | ||
| } | ||
|
|
||
| put_method_and_integration() { | ||
| resource_id=$1 | ||
|
|
||
| awslocal apigateway put-method \ | ||
| aws --endpoint-url "$AWS_ENDPOINT_URL" apigateway put-method \ | ||
| --rest-api-id $cap_xml_rest_api_id \ | ||
| --resource-id $resource_id \ | ||
| --http-method $http_method \ | ||
|
|
@@ -131,7 +151,7 @@ put_integration() { | |
|
|
||
| case $lambda_function_name in | ||
| getMessage|getMessage_v2) | ||
| awslocal apigateway put-integration \ | ||
| aws --endpoint-url "$AWS_ENDPOINT_URL" apigateway put-integration \ | ||
| --rest-api-id $cap_xml_rest_api_id \ | ||
| --resource-id $resource_id \ | ||
| --http-method $http_method \ | ||
|
|
@@ -145,7 +165,7 @@ put_integration() { | |
| put_responses_for_get_message | ||
| ;; | ||
| getMessagesAtom|getMessagesAtom_v2) | ||
| awslocal apigateway put-integration \ | ||
| aws --endpoint-url "$AWS_ENDPOINT_URL" apigateway put-integration \ | ||
| --rest-api-id $cap_xml_rest_api_id \ | ||
| --resource-id $resource_id \ | ||
| --http-method $http_method \ | ||
|
|
@@ -158,7 +178,7 @@ put_integration() { | |
| put_responses_for_get_messages_atom | ||
| ;; | ||
| processMessage) | ||
| awslocal apigateway put-integration \ | ||
| aws --endpoint-url "$AWS_ENDPOINT_URL" apigateway put-integration \ | ||
| --rest-api-id $cap_xml_rest_api_id \ | ||
| --resource-id $resource_id \ | ||
| --http-method $http_method \ | ||
|
|
@@ -188,15 +208,15 @@ put_method_response_for_http_200_status_code() { | |
| # by a function. This results in some duplication. | ||
| case $lambda_function_name in | ||
| getMessage|getMessagesAtom) | ||
| awslocal apigateway put-method-response \ | ||
| aws --endpoint-url "$AWS_ENDPOINT_URL" apigateway put-method-response \ | ||
| --rest-api-id $cap_xml_rest_api_id \ | ||
| --resource-id $resource_id \ | ||
| --http-method $http_method \ | ||
| --status-code 200 \ | ||
| --response-models '{"application/xml": "Empty"}' | ||
| ;; | ||
| processMessage) | ||
| awslocal apigateway put-method-response \ | ||
| aws --endpoint-url "$AWS_ENDPOINT_URL" apigateway put-method-response \ | ||
| --rest-api-id $cap_xml_rest_api_id \ | ||
| --resource-id $resource_id \ | ||
| --http-method $http_method \ | ||
|
|
@@ -217,7 +237,7 @@ put_responses_for_get_message() { | |
|
|
||
| put_responses_for_http_200_get | ||
|
|
||
| awslocal apigateway put-integration-response \ | ||
| aws --endpoint-url "$AWS_ENDPOINT_URL" apigateway put-integration-response \ | ||
| --rest-api-id $cap_xml_rest_api_id \ | ||
| --resource-id $resource_id \ | ||
| --http-method $http_method \ | ||
|
|
@@ -237,7 +257,7 @@ put_responses_for_get_messages_atom() { | |
| } | ||
|
|
||
| put_responses_for_process_message() { | ||
| awslocal apigateway put-integration-response \ | ||
| aws --endpoint-url "$AWS_ENDPOINT_URL" apigateway put-integration-response \ | ||
| --rest-api-id $cap_xml_rest_api_id \ | ||
| --resource-id $resource_id \ | ||
| --http-method $http_method \ | ||
|
|
@@ -252,7 +272,7 @@ put_responses_for_http_200_get() { | |
|
|
||
| put_method_response_for_http_200_status_code | ||
|
|
||
| awslocal apigateway put-integration-response \ | ||
| aws --endpoint-url "$AWS_ENDPOINT_URL" apigateway put-integration-response \ | ||
| --rest-api-id $cap_xml_rest_api_id \ | ||
| --resource-id $resource_id \ | ||
| --http-method $http_method \ | ||
|
|
@@ -264,7 +284,7 @@ put_responses_for_http_200_get() { | |
|
|
||
| put_integration_response_for_http_500() { | ||
|
|
||
| awslocal apigateway put-integration-response \ | ||
| aws --endpoint-url "$AWS_ENDPOINT_URL" apigateway put-integration-response \ | ||
| --rest-api-id $cap_xml_rest_api_id \ | ||
| --resource-id $resource_id \ | ||
| --http-method $http_method \ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #!/bin/sh | ||
| # Sourced (not executed) by scripts that call the AWS CLI, so that every call is | ||
| # guaranteed to target the local Floci emulator rather than a real AWS account. | ||
|
|
||
| AWS_ENDPOINT_URL="${AWS_ENDPOINT_URL:-http://localhost:4566}" | ||
|
|
||
| # Fail fast rather than provision resources in a real AWS account. | ||
| case "$AWS_ENDPOINT_URL" in | ||
| http://localhost:* | http://127.0.0.1:* | http://floci:* | http://floci-main:*) ;; | ||
| *) | ||
| echo "Refusing to run: AWS_ENDPOINT_URL is '$AWS_ENDPOINT_URL', which is not a local Floci endpoint." >&2 | ||
| echo "Unset it, or set it to the local Floci endpoint (http://localhost:4566), before retrying." >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| # Dummy values so the CLI can never fall back to a real profile or region. | ||
| AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID:-test}" | ||
| AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY:-test}" | ||
| AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION:-eu-west-2}" | ||
| AWS_PROFILE="" | ||
|
|
||
| export AWS_ENDPOINT_URL AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_DEFAULT_REGION | ||
| unset AWS_PROFILE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.