Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: quarkiverse/quarkus-amazon-services
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: dabg3/quarkus-amazon-services
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Mar 28, 2024

  1. Copy the full SHA
    415ea0e View commit details
  2. Copy the full SHA
    f7acfee View commit details
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
import java.util.stream.Stream;

import org.jboss.logging.Logger;
import org.testcontainers.Testcontainers;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.localstack.LocalStackContainer;
import org.testcontainers.containers.localstack.LocalStackContainer.EnabledService;
@@ -304,6 +305,10 @@ public String getSecretKey() {
.toArray(EnabledService[]::new))
.withLabel(DEV_SERVICE_LABEL, devServiceName);

if (localStackDevServicesBuildTimeConfig.accessToHost()) {
Testcontainers.exposeHostPorts(localStackDevServicesBuildTimeConfig.hostPort());
}

localStackDevServicesBuildTimeConfig.port().ifPresent(
port -> container.setPortBindings(Collections.singletonList("%s:%s".formatted(port, PORT))));

Original file line number Diff line number Diff line change
@@ -48,4 +48,17 @@ public interface LocalStackDevServicesBuildTimeConfig {
* Optional fixed port localstack will listen to.
*/
Optional<Integer> port();

/**
* Indicates if the container would make a connection to the host network.
*/
@WithDefault("false")
boolean accessToHost();

/**
* port which the application listen to.
*/
@WithDefault("${quarkus.http.port:8080}")
int hostPort();

}
18 changes: 18 additions & 0 deletions docs/modules/ROOT/pages/dev-services.adoc
Original file line number Diff line number Diff line change
@@ -61,6 +61,24 @@ The key is the name of the service to enable and must be a valid LocalStack serv

Some extensions support additional configuration to be applied at startup. Refer to the extension documentation.

== Connect to host network

Dev Services for Amazon Services can support communication from the localstack container to the host network.

If the container needs to communicate with the application running in dev mode, the property `quarkus.http.host` must be set to make the application listen on `0.0.0.0`.
Otherwise, network traffic must be forwarded somehow to `127.0.0.1` which is the default listening address.

By default, the host exposes port `8080` or the one set via `quarkus.http.port` property to the LocalStack container.
In case the exposed port is incorrectly evaluated, it can be manually forced by specifying the desired value via `quarkus.aws.devservices.localstack.host-port`.

[source, properties]
----
quarkus.http.host=0.0.0.0
quarkus.aws.devservices.localstack.access-to-host=true
----

Connection to host network DOES NOT support `quarkus.http.port=0`

== Cognito

The Cognito extension is not using LocalStack but Moto.
Original file line number Diff line number Diff line change
@@ -95,6 +95,40 @@ endif::add-copy-button-to-env-var[]
|


a|icon:lock[title=Fixed at build time] [[quarkus-aws-devservices-localstack-local-stack-dev-services-build-time-config_quarkus-aws-devservices-localstack-access-to-host]]`link:#quarkus-aws-devservices-localstack-local-stack-dev-services-build-time-config_quarkus-aws-devservices-localstack-access-to-host[quarkus.aws.devservices.localstack.access-to-host]`


[.description]
--
Indicates if the container would make a connection to the host network.

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_AWS_DEVSERVICES_LOCALSTACK_ACCESS_TO_HOST+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_AWS_DEVSERVICES_LOCALSTACK_ACCESS_TO_HOST+++`
endif::add-copy-button-to-env-var[]
--|boolean
|`false`


a|icon:lock[title=Fixed at build time] [[quarkus-aws-devservices-localstack-local-stack-dev-services-build-time-config_quarkus-aws-devservices-localstack-host-port]]`link:#quarkus-aws-devservices-localstack-local-stack-dev-services-build-time-config_quarkus-aws-devservices-localstack-host-port[quarkus.aws.devservices.localstack.host-port]`


[.description]
--
port which the application listen to.

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_AWS_DEVSERVICES_LOCALSTACK_HOST_PORT+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_AWS_DEVSERVICES_LOCALSTACK_HOST_PORT+++`
endif::add-copy-button-to-env-var[]
--|int
|`${quarkus.http.port:8080}`


a|icon:lock[title=Fixed at build time] [[quarkus-aws-devservices-localstack-local-stack-dev-services-build-time-config_quarkus-aws-devservices-localstack-container-properties-container-properties]]`link:#quarkus-aws-devservices-localstack-local-stack-dev-services-build-time-config_quarkus-aws-devservices-localstack-container-properties-container-properties[quarkus.aws.devservices.localstack.container-properties]`