@@ -370,7 +370,7 @@ def test_dry_run(monkeypatch):
370370 override_file = os .path .join (temp_dir , "localstack_providers_override.tf" )
371371 assert check_override_file_exists (override_file )
372372
373- assert check_override_file_backend_endpoints_content (override_file , is_legacy = is_legacy_tf )
373+ check_override_file_backend_endpoints_content (override_file , is_legacy = is_legacy_tf )
374374
375375 # assert that bucket with state file exists
376376 s3 = client ("s3" , region_name = "us-east-2" )
@@ -501,7 +501,7 @@ def test_s3_backend_endpoints_merge(monkeypatch, endpoints: str):
501501 temp_dir = deploy_tf_script (config , cleanup = False , user_input = "yes" )
502502 override_file = os .path .join (temp_dir , "localstack_providers_override.tf" )
503503 assert check_override_file_exists (override_file )
504- assert check_override_file_backend_endpoints_content (override_file , is_legacy = is_legacy_tf )
504+ check_override_file_backend_endpoints_content (override_file , is_legacy = is_legacy_tf )
505505 rmtree (temp_dir )
506506
507507
@@ -510,34 +510,34 @@ def check_override_file_exists(override_file):
510510
511511
512512def check_override_file_backend_endpoints_content (override_file , is_legacy : bool = False ):
513- legacy_options = (
513+ legacy_options = {
514514 "endpoint" ,
515515 "iam_endpoint" ,
516516 "dynamodb_endpoint" ,
517517 "sts_endpoint" ,
518- )
519- new_options = (
518+ }
519+ new_options = {
520520 "iam" ,
521521 "dynamodb" ,
522522 "s3" ,
523523 "sso" ,
524524 "sts" ,
525- )
525+ }
526526 try :
527527 with open (override_file , "r" ) as fp :
528528 result = hcl2 .load (fp )
529529 result = result ["terraform" ][0 ]["backend" ][0 ]["s3" ]
530530 except Exception as e :
531531 print (f'Unable to parse "{ override_file } " as HCL file: { e } ' )
532532
533- new_options_check = "endpoints" in result and all (map (lambda x : x in result .get ("endpoints" ), new_options ))
534-
535533 if is_legacy :
536- legacy_options_check = all ( map ( lambda x : x in result , legacy_options ))
537- return not new_options_check and legacy_options_check
534+ assert "endpoints" not in result
535+ assert legacy_options <= set ( result )
538536
539- legacy_options_check = any (map (lambda x : x in result , legacy_options ))
540- return new_options_check and not legacy_options_check
537+ else :
538+ assert "endpoints" in result
539+ assert new_options <= set (result ["endpoints" ])
540+ assert not legacy_options & set (result )
541541
542542
543543def test_provider_aliases_ignored (monkeypatch ):
0 commit comments