I would think you should be able to check for the presence of the directory during your build, and only call
yarn install if the directory is not present. For example:
if [ ! -d "/codebuild/output/src11111111/src/github.com/OUR_ORG/OUR_PROJECT/node_modules/@OUR_PACKAGE/common" ]; then yarn install fi
This would only run
yarn install if the directory does not exist, avoiding this error when the package cache exists due to local caching.
That said, S3 caching does tend to be faster than installing packages, since the files can be pulled without leaving the AWS network, and there is also less processing involved with the cache than there is with any package manager, so this option is worth exploring if the above doesn't work for you.
As for speeding up the build times, there aren't many general suggestions I can make, although if a significant portion of your build is in the
PROVISIONING state, you may find better performance by ensuring you are on the latest release of the CodeBuild image, as the docker image for this is cached, whereas the older versions may not be.
Unfortunately, I wouldn't have any examples I can offer for large repos using CodeBuild, however you are certainly free to open a case if you'd like us to take a closer look at your environment!
Difference between a Job that is tied to a Project vs Recipe + Datasetasked 2 years ago
Paying a bonus to a large number of workersasked 8 months ago
How to Get CodeBuild to Build Develop NOT the PR Branch?asked 6 months ago
Is there a way to change the name of the artifact getting stored in s3 during build stage of codepipeline?asked 2 months ago
How to query Codebuild/Cloudwatch Logs from Buildspec.yml in CodeBuildasked 2 months ago
stopping a codepipeline build does not stop the codebuild batchAccepted Answerasked 3 months ago
CodeBuild - Extremely long build times/cachingasked 5 months ago
CodeBuild job triggered by Githab occasionally gets wrong commitasked 6 months ago
Codebuild local cache with a more permanent timeasked 3 years ago
[CDK Pipelines] Is it possible to run a Codebuild step without an input?asked 9 months ago