I am currently building a codepipeline using AWS CDK in which I am making use of multiple codebuild projects for different codebuild actions that are part of several codepipeline stages. I have separate build specification files for each of the codebuild project under the folder - "buildspecs". This "buildspecs" resides in the root of my CDK project.
Now I want to refer to individual buildspec files from different pipeline source code files. For example, I want to refer to buildspecs/UnitTestsBuildSpec.yml from lib/infra/cicd/stages/unit-test-stage.ts. How can I do so? I saw different options in the documentations such as BuildSpec.fromSourceFileName, BuildSpec.fromObject, BuildSpec.fromAsset but I am confused which one to use because of lack of proper documentation around it.
For now, I have used BuildSpec.fromSourceFileName but not sure whether to use relative path from the file I am in (like ../../../buildspecs/UnitTestsBuildSpec.yml) or to use absolute path from the root of the project (like buildspec/UnitTestsBuildSpec.yml). I see people using other options like fromAsset and fromObject on other stackoverflow and github issues pages. Which one should I use and how? Any help would be appreciated. Thanks.