[Python] How can I speed up my CDK Synth step in code pipeline by caching requirements?

Discussão em 'Python' iniciado por Stack, Setembro 14, 2024.

  1. Stack

    Stack Membro Participativo

    Currently, the synth step in my code pipeline looks something like this:

    synth=pipelines.ShellStep(
    "Synth",
    input=pipelines.CodePipelineSource.connection(
    self.repository,
    self.branch,
    connection_arn="arn:aws:codestar-connections:us-east-1:613431292675:connection/db5d023d-5eed-4bb7-808c-df5d5fe5452f",
    trigger_on_push=True,
    ),
    commands=[
    "cd eval-infra",
    "npm install -g aws-cdk", # Installs the cdk cli on Codebuild
    "pip install -r requirements.txt", # Instructs Codebuild to install required packages
    "npx cdk synth EvalInfraPipeline",
    ],
    primary_output_directory="eval-infra/cdk.out",
    ),


    Unfortunately, this takes almost two minutes to run - and the bulk of this is the npm install and the pip install commands. Two minutes is not a lot in isolation, but when combined with the rest of the build process, it adds up to 10 minute+ build times.

    Is it possible to use caching somehow to speed this up? I looked into using a CodeBuildStep instead, with some kind of local or s3 cache, but I couldn't find a working example. Has anyone done something like this before?

    Continue reading...

Compartilhe esta Página