Skip to content

Commit 8b49a05

Browse files
committed
minor refactoring
1 parent ac8bcc0 commit 8b49a05

8 files changed

Lines changed: 24 additions & 25 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ You can install the respective extension by calling `localstack install <Install
6767

6868
| Extension | Install name | Version | Support status |
6969
|----------------------------------------------------------------------------------------------------| ------------ | ------- | -------------- |
70-
| [AWS Proxy](https://github.com/localstack/localstack-extensions/tree/main/aws-proxy) | localstack-extension-aws-proxy | 0.1.7 | Experimental |
70+
| [AWS Proxy](https://github.com/localstack/localstack-extensions/tree/main/aws-proxy) | localstack-extension-aws-proxy | 0.1.25 | Experimental |
7171
| [Diagnosis Viewer](https://github.com/localstack/localstack-extensions/tree/main/diagnosis-viewer) | localstack-extension-diagnosis-viewer | 0.1.0 | Stable |
7272
| [Hello World](https://github.com/localstack/localstack-extensions/tree/main/hello-world) | localstack-extension-hello-world | 0.1.0 | Stable |
7373
| [httpbin](https://github.com/localstack/localstack-extensions/tree/main/httpbin) | localstack-extension-httpbin | 0.1.0 | Stable |

aws-proxy/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This enables one flavor of "hybrid" or "remocal" setups where you can easily bri
77

88
⚠️ Please note that this extension is experimental and still under active development.
99

10-
⚠️ Note: Given that the scope of this extension has recently changed (see [below](#resource-proxy-cli-deprecated)) - it has been recently renamed from `aws-replicator` to `aws-proxy`.
10+
⚠️ Note: Given that the scope of this extension has recently changed (see [below](#resource-replicator-cli-deprecated)) - it has been recently renamed from `aws-replicator` to `aws-proxy`.
1111

1212
## Prerequisites
1313

@@ -53,12 +53,12 @@ $ localstack aws proxy -s dynamodb,s3,cognito-idp
5353

5454
1. Start Localstack with extra CORS
5555
```
56-
EXTRA_CORS_ALLOWED_ORIGINS=https://aws-replicator.localhost.localstack.cloud:4566 localstack start -d
56+
EXTRA_CORS_ALLOWED_ORIGINS=https://aws-proxy.localhost.localstack.cloud:4566 localstack start -d
5757
```
5858

59-
2. Enable Localstack AWS replicator from the Web Application Extension Library
59+
2. Enable Localstack AWS Proxy from the Web Application Extension Library
6060

61-
3. Once the extension is installed, it will expose a small configuration endpoint in your LocalStack container under the following endpoint: http://localhost:4566/_localstack/aws-replicator/index.html .
61+
3. Once the extension is installed, it will expose a small configuration endpoint in your LocalStack container under the following endpoint: http://localhost:4566/_localstack/aws-proxy/index.html .
6262

6363
4. Use this Web UI to define the proxy configuration (in YAML syntax), as well as the AWS credentials (AWS access key ID, secret access key, and optionally session token) and save configuration. The proxy should report enabled state and on the host a proxy container should spawn.
6464

@@ -111,9 +111,9 @@ A more comprehensive sample, involving local Lambda functions combined with remo
111111
### Configuration
112112

113113
In addition to the proxy services configuration shown above, the following configs can be used to customize the behavior of the extension itself (simply pass them as environment variables to the main LocalStack container):
114-
* `REPLICATOR_CLEANUP_PROXY_CONTAINERS`: whether to clean up (remove) the proxy Docker containers once they shut down (default `1`). Can be set to `0` to help debug issues, e.g., if a proxy container starts up and exits immediately.
115-
* `REPLICATOR_LOCALSTACK_HOST`: the target host to use when the proxy container connects to the LocalStack main container (automatically determined by default)
116-
* `REPLICATOR_PROXY_DOCKER_FLAGS`: additional flags that should be passed when creating the proxy Docker containers
114+
* `PROXY_CLEANUP_CONTAINERS`: whether to clean up (remove) the proxy Docker containers once they shut down (default `1`). Can be set to `0` to help debug issues, e.g., if a proxy container starts up and exits immediately.
115+
* `PROXY_LOCALSTACK_HOST`: the target host to use when the proxy container connects to the LocalStack main container (automatically determined by default)
116+
* `PROXY_DOCKER_FLAGS`: additional flags that should be passed when creating the proxy Docker containers
117117

118118
**Note:** Due to some recent changes in the core framework, make sure to start up your LocalStack container with the `GATEWAY_SERVER=hypercorn` configuration enabled, for backwards compatibility. This will be fixed in an upcoming release.
119119

aws-proxy/aws_proxy/client/cli.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import click
55
import yaml
66
from localstack.cli import LocalstackCli, LocalstackCliPlugin, console
7-
from localstack.logging.setup import setup_logging
87
from localstack.utils.files import load_file
98

109
from aws_proxy.shared.models import ProxyConfig, ProxyServiceConfig

aws-proxy/aws_proxy/client/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
from localstack.utils.functions import run_safe
66
from localstack.utils.strings import to_str, truncate
77

8-
from aws_proxy.config import HANDLER_PATH_REPLICATE
8+
from aws_proxy.config import HANDLER_PATH_PROXY
99
from aws_proxy.shared.models import ReplicateStateRequest
1010

1111

1212
def post_request_to_instance(request: ReplicateStateRequest = None):
13-
url = f"{get_edge_url()}{HANDLER_PATH_REPLICATE}"
13+
url = f"{get_edge_url()}{HANDLER_PATH_PROXY}"
1414
response = requests.post(url, json=request or {})
1515
if not response.ok:
1616
raise Exception(f"Invocation failed (code {response.status_code}): {response.content}")

aws-proxy/aws_proxy/server/extension.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@
88
LOG = logging.getLogger(__name__)
99

1010

11-
class AwsReplicatorExtension(Extension):
12-
name = "aws-replicator"
11+
class AwsProxyExtension(Extension):
12+
name = "aws-proxy"
1313

1414
def on_extension_load(self):
1515
if config.GATEWAY_SERVER == "twisted":
1616
LOG.warning(
17-
"AWS resource replicator: The aws-replicator extension currently requires hypercorn as "
17+
"AWS Proxy: The aws-proxy extension currently requires hypercorn as "
1818
"gateway server. Please start localstack with GATEWAY_SERVER=hypercorn"
1919
)
2020

2121
def update_gateway_routes(self, router: http.Router[http.RouteHandler]):
22-
from aws_replicator.server.request_handler import RequestHandler
22+
from aws_proxy.server.request_handler import RequestHandler
2323

24-
LOG.info("AWS resource replicator: adding routes to activate extension")
24+
LOG.info("AWS Proxy: adding routes to activate extension")
2525
get_internal_apis().add(RequestHandler())
2626

2727
def update_request_handlers(self, handlers: CompositeHandler):
28-
from aws_replicator.server.aws_request_forwarder import AwsProxyHandler
28+
from aws_proxy.server.aws_request_forwarder import AwsProxyHandler
2929

30-
LOG.debug("AWS resource replicator: adding AWS proxy handler to the request chain")
30+
LOG.debug("AWS Proxy: adding AWS proxy handler to the request chain")
3131
handlers.handlers.append(AwsProxyHandler())

aws-proxy/aws_proxy/server/request_handler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
CONTAINER_NAME_PREFIX,
2626
start_aws_auth_proxy_in_container,
2727
)
28-
from aws_proxy.config import HANDLER_PATH_PROXIES, HANDLER_PATH_REPLICATE
28+
from aws_proxy.config import HANDLER_PATH_PROXIES, HANDLER_PATH_PROXY
2929
from aws_proxy.server import ui as web_ui
3030
from aws_proxy.server.aws_request_forwarder import AwsProxyHandler
3131
from aws_proxy.shared.models import AddProxyRequest, ReplicateStateRequest, ResourceReplicator
@@ -37,7 +37,7 @@
3737

3838

3939
class RequestHandler:
40-
@route(HANDLER_PATH_REPLICATE, methods=["POST"])
40+
@route(HANDLER_PATH_PROXY, methods=["POST"])
4141
def handle_replicate(self, request: Request, **kwargs):
4242
replicator = _get_replicator()
4343
payload = _get_json(request)
@@ -110,7 +110,7 @@ def handle_replicate_request(request: ReplicateStateRequest):
110110

111111

112112
def _get_replicator() -> ResourceReplicator:
113-
from aws_replicator.server.resource_replicator import ResourceReplicatorFormer2
113+
from aws_proxy.server.resource_replicator import ResourceReplicatorFormer2
114114

115115
# TODO deprecated - fix the implementation of the replicator/copy logic!
116116
# return ResourceReplicatorInternal()

aws-proxy/aws_proxy/server/resource_replicator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
from localstack.utils.files import mkdir
1010
from localstack.utils.run import run
1111

12-
from aws_replicator.client.service_states import ExtendedResourceStateReplicator
13-
from aws_replicator.shared.models import ResourceReplicator
14-
from aws_replicator.shared.utils import get_resource_type
12+
from aws_proxy.client.service_states import ExtendedResourceStateReplicator
13+
from aws_proxy.shared.models import ResourceReplicator
14+
from aws_proxy.shared.utils import get_resource_type
1515

1616
LOG = logging.getLogger(__name__)
1717

aws-proxy/setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ aws_proxy =
5151

5252
[options.entry_points]
5353
localstack.extensions =
54-
aws-proxy = aws_proxy.server.extension:AwsReplicatorExtension
54+
aws-proxy = aws_proxy.server.extension:AwsProxyExtension
5555
localstack.plugins.cli =
5656
aws-proxy = aws_proxy.client.cli:AwsReplicatorPlugin

0 commit comments

Comments
 (0)