@@ -16,23 +16,24 @@ import subprocess
1616
1717from urllib .parse import urlparse
1818
19- PARENT_FOLDER = os .path .realpath (os .path .join (os .path .dirname (__file__ ), '..' ))
20- if os .path .isdir (os .path .join (PARENT_FOLDER , ' .venv' )):
19+ PARENT_FOLDER = os .path .realpath (os .path .join (os .path .dirname (__file__ ), ".." ))
20+ if os .path .isdir (os .path .join (PARENT_FOLDER , " .venv" )):
2121 sys .path .insert (0 , PARENT_FOLDER )
2222
2323from localstack_client import config # noqa: E402
2424import hcl2 # noqa: E402
2525
2626DEFAULT_REGION = "us-east-1"
2727DEFAULT_ACCESS_KEY = "test"
28+ AWS_ENDPOINT_URL = os .environ .get ("AWS_ENDPOINT_URL" )
2829CUSTOMIZE_ACCESS_KEY = str (os .environ .get ("CUSTOMIZE_ACCESS_KEY" )).strip ().lower () in ["1" , "true" ]
2930LOCALHOST_HOSTNAME = "localhost.localstack.cloud"
3031S3_HOSTNAME = os .environ .get ("S3_HOSTNAME" ) or f"s3.{ LOCALHOST_HOSTNAME } "
3132USE_EXEC = str (os .environ .get ("USE_EXEC" )).strip ().lower () in ["1" , "true" ]
3233TF_CMD = os .environ .get ("TF_CMD" ) or "terraform"
3334LS_PROVIDERS_FILE = os .environ .get ("LS_PROVIDERS_FILE" ) or "localstack_providers_override.tf"
34- LOCALSTACK_HOSTNAME = os .environ .get ("LOCALSTACK_HOSTNAME" ) or "localhost"
35- EDGE_PORT = int (os .environ .get ("EDGE_PORT" ) or 4566 )
35+ LOCALSTACK_HOSTNAME = urlparse ( AWS_ENDPOINT_URL ). hostname or os .environ .get ("LOCALSTACK_HOSTNAME" ) or "localhost"
36+ EDGE_PORT = int (urlparse ( AWS_ENDPOINT_URL ). port or os .environ .get ("EDGE_PORT" ) or 4566 )
3637TF_PROVIDER_CONFIG = """
3738provider "aws" {
3839 access_key = "<access_key>"
@@ -337,12 +338,12 @@ def get_or_create_ddb_table(table_name: str, region: str = None):
337338def parse_tf_files () -> dict :
338339 """Parse the local *.tf files and return a dict of <filename> -> <resource_dict>"""
339340 result = {}
340- for _file in glob .glob (' *.tf' ):
341+ for _file in glob .glob (" *.tf" ):
341342 try :
342- with open (_file , 'r' ) as fp :
343+ with open (_file , "r" ) as fp :
343344 result [_file ] = hcl2 .load (fp )
344345 except Exception as e :
345- print (f" Unable to parse ' { _file } ' as HCL file: { e } " )
346+ print (f' Unable to parse " { _file } " as HCL file: { e } ' )
346347 return result
347348
348349
@@ -408,5 +409,5 @@ def main():
408409 os .remove (config_file )
409410
410411
411- if __name__ == ' __main__' :
412+ if __name__ == " __main__" :
412413 main ()
0 commit comments