Use stdlib urlparse to strip out the scheme
@@ -3,6 +3,7 @@ import sys
sys.path.insert(0, "..")
from typing import Mapping, cast
+from urllib.parse import urlparse
import pulumi_aws as aws
from infra import config, dynamodb, log_levels
@@ -144,11 +145,10 @@ def main() -> None:
upstream_stacks = UpstreamStacks()
nomad_provider = get_nomad_provider_address(upstream_stacks.nomad_server)
- nomad_endpoint = nomad_provider.address
- # we need to strip off the prepended http:// because that combined with a non-standard port is
+ # The nomad address is prepended with http:// by default. However that combined with a non-standard port is an invalid hostname, which causes the otel-collector to break. As such we need to strip this out.
nomad_endpoint = pulumi.Output.all(
- nomad_endpoint=nomad_endpoint,
- ).apply(lambda endpoint: f"{nomad_endpoint}".replace("http://", ""))
+ nomad_endpoint=nomad_provider.address,
+ ).apply(lambda endpoint: urlparse(f"{nomad_endpoint}").netloc)
# Using get_output instead of require_output so that preview passes.
# NOTE wimax Feb 2022: Not sure the above is still the case
