diff --git a/tests/ci/cdk/util/build_spec_loader.py b/tests/ci/cdk/util/build_spec_loader.py index 145bb7e151c..7ce522e4d93 100644 --- a/tests/ci/cdk/util/build_spec_loader.py +++ b/tests/ci/cdk/util/build_spec_loader.py @@ -5,7 +5,7 @@ from aws_cdk import aws_codebuild as codebuild, aws_s3_assets from util.metadata import CAN_AUTOLOAD, TEAM_ACCOUNT, AWS_ACCOUNT, DEFAULT_REGION, AWS_REGION -import yaml +import tempfile class BuildSpecLoader(object): @@ -27,9 +27,10 @@ def load(file_path): TEAM_ACCOUNT: AWS_ACCOUNT, DEFAULT_REGION: AWS_REGION, } - with open(file_path) as file: - file_text = file.read() + with open(file_path) as original_file: + file_text = original_file.read() for key in placeholder_map.keys(): file_text = file_text.replace(key, placeholder_map[key]) - build_spec_content = yaml.safe_load(file_text) - return codebuild.BuildSpec.from_object(build_spec_content) + with tempfile.NamedTemporaryFile(mode='w+', delete=False) as temp_file: + temp_file.write(file_text) + return codebuild.BuildSpec.from_asset(temp_file.name)