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
20 changes: 11 additions & 9 deletions .github/workflows/aws-proxy.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
name: LocalStack AWS Proxy Extension Tests

on:
push:
paths:
- aws-proxy/**
branches:
- main
pull_request:
paths:
- .github/workflows/aws-proxy.yml
- aws-proxy/**
# TODO: temporarily disabled - AWS proxy codebase needs to be fixed, to accommodate recent
# changes in CLI and runtime repos, see: https://github.com/localstack/localstack/pull/13704
# push:
# paths:
# - aws-proxy/**
# branches:
# - main
# pull_request:
# paths:
# - .github/workflows/aws-proxy.yml
# - aws-proxy/**
workflow_dispatch:

jobs:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ You can install the respective extension by calling `localstack extensions insta
| [Stripe](https://github.com/localstack/localstack-extensions/tree/main/stripe) | localstack-extension-stripe | 0.2.0 | Stable |
| [Terraform Init](https://github.com/localstack/localstack-extensions/tree/main/terraform-init) | localstack-extension-terraform-init | 0.2.0 | Experimental |
| [TypeDB](https://github.com/localstack/localstack-extensions/tree/main/typedb) | localstack-extension-typedb | 0.1.3 | Experimental |
| [ParadeDB](https://github.com/localstack/localstack-extensions/tree/main/paradedb) | localstack-extension-paradedb | 0.1.0 | Experimental |
| [WireMock](https://github.com/localstack/localstack-extensions/tree/main/wiremock) | localstack-wiremock | 0.1.0 | Experimental |
| [ParadeDB](https://github.com/localstack/localstack-extensions/tree/main/paradedb) | localstack-extension-paradedb | 0.1.0 | Experimental |


## Developing Extensions
Expand Down
18 changes: 0 additions & 18 deletions paradedb/localstack_paradedb/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from localstack_extensions.utils.docker import ProxiedDockerContainerExtension
from localstack import config
from localstack.extensions.api import http

# Environment variables for configuration
ENV_POSTGRES_USER = "PARADEDB_POSTGRES_USER"
Expand Down Expand Up @@ -57,23 +56,6 @@ def _tcp_health_check():
tcp_ports=[postgres_port], # Enable TCP proxying through gateway
)

# TODO: this should be migrated into the base class directly ..!
def update_gateway_routes(self, router: http.Router[http.RouteHandler]):
"""
Override to set up only TCP routing without HTTP proxy.

ParadeDB uses the native PostgreSQL wire protocol (not HTTP), so we
only need TCP protocol routing - not HTTP proxying. Adding an HTTP
proxy without a host restriction would cause all HTTP requests to be
forwarded to the PostgreSQL container, breaking other services.
"""
# Start the container
self.start_container()

# Set up only TCP protocol routing (skip HTTP proxy from base class)
if self.tcp_ports:
self._setup_tcp_protocol_routing()

def tcp_connection_matcher(self, data: bytes) -> bool:
"""
Identify PostgreSQL/ParadeDB connections by protocol handshake.
Expand Down
2 changes: 1 addition & 1 deletion paradedb/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dev = [
"boto3",
"build",
"jsonpatch",
"localstack",
"localstack-core",
"psycopg2-binary",
"pytest",
"rolo",
Expand Down
19 changes: 11 additions & 8 deletions paradedb/tests/test_extension.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import boto3
import psycopg2
from localstack.utils.strings import short_uid
from localstack.utils.sync import retry


# Connection details for ParadeDB
Expand All @@ -13,14 +14,16 @@


def get_connection():
"""Create a connection to ParadeDB."""
return psycopg2.connect(
host=HOST,
port=PORT,
user=USER,
password=PASSWORD,
database=DATABASE,
)
"""Create a connection to ParadeDB, retrying until the server is ready."""
def _connect():
return psycopg2.connect(
host=HOST,
port=PORT,
user=USER,
password=PASSWORD,
database=DATABASE,
)
return retry(_connect, retries=15, sleep=2.0)


def test_connect_to_paradedb():
Expand Down
2 changes: 1 addition & 1 deletion typedb/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dev = [
"boto3",
"build",
"jsonpatch",
"localstack",
"localstack-core",
"pytest",
"rolo",
"ruff",
Expand Down
20 changes: 15 additions & 5 deletions utils/localstack_extensions/utils/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,21 @@ def update_gateway_routes(self, router: http.Router[http.RouteHandler]):
)
# note: for simplicity, starting the external container at startup - could be optimized over time ...
self.start_container()
# add resource for HTTP/1.1 requests
resource = RuleAdapter(ProxyResource(self.container_host, self.main_port))
if self.host:
resource = WithHost(self.host, [resource])
router.add(resource)

# Determine if HTTP proxy should be set up. Skip it when all container ports are
# TCP-only and no host restriction is set, since a catch-all HTTP proxy would
# intercept all requests and break other services.
uses_http = (
self.host
and set(self.container_ports) - set(self.tcp_ports or [])
)

if uses_http:
# add resource for HTTP/1.1 requests
resource = RuleAdapter(ProxyResource(self.container_host, self.main_port))
if self.host:
resource = WithHost(self.host, [resource])
router.add(resource)

# apply patches to serve HTTP/2 requests
for port in self.http2_ports or []:
Expand Down
4 changes: 2 additions & 2 deletions utils/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ dev = [
"boto3",
"build",
"jsonpatch",
"localstack",
"localstack-core",
"pytest",
"ruff",
]
test = [
"grpcio>=1.60.0",
"grpcio-tools>=1.60.0",
"jsonpatch",
"localstack",
"localstack-core",
"pytest>=7.0",
"pytest-timeout>=2.0",
]
Expand Down
11 changes: 11 additions & 0 deletions wiremock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ localstack start

- `WIREMOCK_API_TOKEN`: Your WireMock Cloud API token (required for runner mode)
- `WIREMOCK_CONFIG_DIR`: Path to the directory containing your `.wiremock` folder (required for runner mode)
- `WIREMOCK_IMAGE`: Custom Docker image name for the Wiremock OSS image (default: `wiremock/wiremock`)
- `WIREMOCK_IMAGE_RUNNER`: Custom Docker image name for the Wiremock Cloud runner image (default: `wiremock/wiremock-runner`)

Note: When using the LocalStack CLI, prefix environment variables with `LOCALSTACK_` to forward them to the container.

Expand All @@ -118,3 +120,12 @@ See the `sample-app-runner/` directory for a complete example using Terraform th
- Creating an API Gateway
- Lambda function that calls WireMock stubs
- Integration testing with mocked external APIs

## Change Log

- `0.1.1`: Add environment variables to customize the WireMock image names
- `0.1.0`: Initial release of the extension

## License

This project is licensed under the Apache License, Version 2.0.
8 changes: 4 additions & 4 deletions wiremock/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "localstack-wiremock"
version = "0.1.0"
version = "0.1.1"
description = "WireMock Extension for LocalStack"
readme = {file = "README.md", content-type = "text/markdown; charset=UTF-8"}
requires-python = ">=3.9"
Expand All @@ -14,8 +14,8 @@ authors = [
keywords = ["LocalStack", "WireMock"]
classifiers = []
dependencies = [
"priority",
"localstack-extensions-utils"
"localstack-extensions-utils",
"priority"
]

[project.urls]
Expand All @@ -26,7 +26,7 @@ dev = [
"boto3",
"build",
"jsonpatch",
"localstack",
"localstack-core",
"pytest",
"rolo",
"ruff",
Expand Down