Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces a new Rust-based “mock-service” Lambda (stubr) and wires it into the LocalStack/Terraform local environment to replace the existing WireMock container, including updating seeded supplier URLs to point at the mock API after deploy.
Changes:
- Add
mock-service/(Rust Lambda + build/package scripts + docs) that serves existing WireMock mapping JSON via API Gateway proxy routes. - Update local deployment flow (
package.json) to build/package the mock-service and updatesupplier.service_urlafterterraform apply. - Replace WireMock container usage in local environment (Terraform + docker-compose) and add new WireMock mapping stubs.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/terraform/post-apply-update-supplier-url.sh | New post-apply script to update seeded supplier URLs to the mock-service API Gateway base URL |
| package.json | Extends postinstall/local deploy scripts to include mock-service build/package and URL update |
| mock-service/src/main.rs | Rust Lambda entrypoint: starts stubr and proxies API Gateway requests after stripping /mock/* prefixes |
| mock-service/scripts/build.sh | Builds Lambda bootstrap via cargo lambda and bundles WireMock mappings into dist/ |
| mock-service/scripts/package.sh | Zips bootstrap + mappings for Terraform deployment |
| mock-service/package.json | Adds npm wrappers around build/package/clean operations |
| mock-service/Cargo.toml | Declares Rust dependencies for lambda_http + stubr proxy service |
| mock-service/README.md | Documents how the mock-service works and how it’s deployed/used locally and in AWS |
| mock-service/docs/test-scenario-routing.md | Documents patterns for scenario-based routing with file-based stubs (stubr limitations noted) |
| local-environment/infra/main.tf | Adds LocalStack Lambda + dedicated API Gateway for mock-service (proxy integration) |
| local-environment/infra/outputs.tf | Adds outputs for mock-service URLs and updates seeded supplier output description |
| local-environment/docker-compose.yml | Removes the WireMock container from the backend compose profile |
| database/03-seed-hometest-data.sql | Seeds suppliers with a placeholder URL to be replaced post-deploy |
| local-environment/wiremock/mappings/*.json | Adds additional stub mappings (health, jwks, postcode lookups) used by stubr |
Comment on lines
+10
to
+13
| echo "Building mock-service (stubr) for Lambda..." | ||
|
|
||
| cd "$ROOT_DIR" | ||
| cargo lambda build --release --arm64 |
| role = aws_iam_role.lambda_role.arn | ||
| handler = "bootstrap" | ||
| runtime = "provided.al2023" | ||
| architectures = ["arm64"] |
Comment on lines
+95
to
+113
| output "mock_api_base_url" { | ||
| description = "Base URL for the mock API on LocalStack" | ||
| value = "http://localhost:4566/_aws/execute-api/${aws_api_gateway_rest_api.mock_api.id}/${var.environment}" | ||
| } | ||
|
|
||
| output "mock_supplier_base_url" { | ||
| description = "Supplier mock base URL (use as service_url in supplier table)" | ||
| value = "http://localstack-main:4566/_aws/execute-api/${aws_api_gateway_rest_api.mock_api.id}/${var.environment}/mock/supplier" | ||
| } | ||
|
|
||
| output "mock_supplier_base_url_host" { | ||
| description = "Supplier mock base URL accessible from host machine" | ||
| value = "http://localhost:4566/_aws/execute-api/${aws_api_gateway_rest_api.mock_api.id}/${var.environment}/mock/supplier" | ||
| } | ||
|
|
||
| output "mock_cognito_jwks_url" { | ||
| description = "Mock Cognito JWKS URL" | ||
| value = "http://localhost:4566/_aws/execute-api/${aws_api_gateway_rest_api.mock_api.id}/${var.environment}/mock/cognito/.well-known/jwks.json" | ||
| } |
Comment on lines
+57
to
+63
| let body_text = resp.text().await?; | ||
|
|
||
| let mut builder = Response::builder().status(status); | ||
| for (name, value) in &resp_headers { | ||
| builder = builder.header(name, value); | ||
| } | ||
| Ok(builder.body(Body::Text(body_text))?) |
|
|
||
| [dependencies] | ||
| lambda_http = "0.13" | ||
| lambda_runtime = "0.13" |
Comment on lines
+20
to
+21
| zip -r "$ZIP_PATH" bootstrap mappings/ | ||
|
|
|
|
||
| docker exec postgres-db psql \ | ||
| "postgresql://app_user:STRONG_APP_PASSWORD@localhost:5432/local_hometest_db" \ | ||
| -c "SET search_path TO hometest; UPDATE supplier SET service_url = '${MOCK_SUPPLIER_URL}' WHERE service_url LIKE '%mock-service-placeholder%' OR service_url LIKE '%wiremock%';" |
| "private": true, | ||
| "scripts": { | ||
| "postinstall": "npm --prefix ui install && npm --prefix lambdas install && npm --prefix tests install", | ||
| "postinstall": "npm --prefix ui install && npm --prefix lambdas install && npm --prefix mock-service install && npm --prefix tests install", |
Contributor
|
@mikeeq is this needed still? |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Context
Type of changes
Checklist
Sensitive Information Declaration
To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.