Skip to content
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

fix aws-replicator compatibility with localstack >=3.4 #63

Merged
merged 2 commits into from
Jun 5, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/aws-replicator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:

find /home/runner/.cache/localstack/volume/lib/extensions/python_venv/lib/python3.11/site-packages/aws*
ls -la /home/runner/.cache/localstack/volume/lib/extensions/python_venv/lib/python3.11/site-packages/aws*
DEBUG=1 localstack start -d
DEBUG=1 GATEWAY_SERVER=hypercorn localstack start -d
localstack wait

- name: Run linter
Expand Down
12 changes: 6 additions & 6 deletions aws-replicator/aws_replicator/server/aws_request_forwarder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
import requests
from localstack.aws.api import RequestContext
from localstack.aws.chain import Handler, HandlerChain
from localstack.constants import (
APPLICATION_JSON,
LOCALHOST,
LOCALHOST_HOSTNAME,
TEST_AWS_ACCESS_KEY_ID,
)
from localstack.constants import APPLICATION_JSON, LOCALHOST, LOCALHOST_HOSTNAME
from localstack.http import Response
from localstack.utils.aws import arns
from localstack.utils.aws.arns import sqs_queue_arn
Expand All @@ -22,6 +17,11 @@
from localstack.utils.strings import to_str, truncate
from requests.structures import CaseInsensitiveDict

try:
from localstack.testing.config import TEST_AWS_ACCESS_KEY_ID
except ImportError:
from localstack.constants import TEST_AWS_ACCESS_KEY_ID

from aws_replicator.shared.models import ProxyInstance, ProxyServiceConfig

LOG = logging.getLogger(__name__)
Expand Down
8 changes: 8 additions & 0 deletions aws-replicator/aws_replicator/server/extension.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging

from localstack import config
from localstack.aws.chain import CompositeHandler
from localstack.extensions.api import Extension, http
from localstack.services.internal import get_internal_apis
Expand All @@ -10,6 +11,13 @@
class AwsReplicatorExtension(Extension):
name = "aws-replicator"

def on_extension_load(self):
if config.GATEWAY_SERVER == "twisted":
LOG.warning(
"AWS resource replicator: The aws-replicator extension currently requires hypercorn as "
"gateway server. Please start localstack with GATEWAY_SERVER=hypercorn"
)

def update_gateway_routes(self, router: http.Router[http.RouteHandler]):
from aws_replicator.server.request_handler import RequestHandler

Expand Down
7 changes: 6 additions & 1 deletion aws-replicator/tests/test_proxy_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@
import pytest
from botocore.exceptions import ClientError
from localstack.aws.connect import connect_to
from localstack.constants import TEST_AWS_ACCOUNT_ID
from localstack.utils.aws.arns import sqs_queue_arn, sqs_queue_url_for_arn
from localstack.utils.net import wait_for_port_open
from localstack.utils.sync import retry

from aws_replicator.client.auth_proxy import start_aws_auth_proxy
from aws_replicator.shared.models import ProxyConfig

try:
from localstack.testing.config import TEST_AWS_ACCOUNT_ID
except ImportError:
# backwards compatibility
from localstack.constants import TEST_AWS_ACCOUNT_ID

# binding proxy to 0.0.0.0 to enable testing in CI
PROXY_BIND_HOST = "0.0.0.0"

Expand Down
Loading