question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[pipelines] SimpleSynthAction does not create a cdk.out directory

See original GitHub issue

❓ General Issue

The Question

I am attempting to create a CDK pipeline. I am following the blog post (https://aws.amazon.com/blogs/developer/cdk-pipelines-continuous-delivery-for-aws-cdk-applications/) and using Python/Pipenv. I do not commit the cdk.out directory that is created on build/deploy and that directory is usually .gitignore in all of the examples I’ve seen. I believe that gets created automatically on cdk synth. However that doesn’t happen and I get an error during the synth action: CLIENT_ERROR Message: no matching base directory path found for cdk.out during the build in the console. I am hoping I do not have to actually commit the cdk.out directory locally.

Environment

  • CDK CLI Version: 1.54.0 (build c01b9b9)
  • Module Version: Latest
  • Node.js Version: v12.14.0
  • OS: OSX Mojave
  • Language (Version): Python (3.7.3)

Other information

My pipeline stack code:

class TestPipelineStack(Stack):
    @property
    def env_string(self):
        return self.node.try_get_context("env")

    def __init__(self, scope: Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        # Output artifact
        source_artifact = _codepipeline.Artifact()
        # Artifact to hold the cloudAssemblyArtifact for the synth action (the template)
        cloud_assembly_artifact = _codepipeline.Artifact()

        # Define pipeline actions for stages

        # Source
        source_action = _codepipeline_actions.GitHubSourceAction(
            action_name="GithubSourceAction",
            output=source_artifact,
            oauth_token=SecretValue.secrets_manager("github-token"),
            owner="owner",
            repo="lambdas",
            branch="test",
        )

        # Build (On synth)
        synth_action = SimpleSynthAction(
            cloud_assembly_artifact=cloud_assembly_artifact,
            source_artifact=source_artifact,
            install_command="npm install -g aws-cdk && pip install pipenv",
            build_command="pipenv sync --dev",
            synth_command="export PYTHONPATH=$PWD pipenv run cdk synth",
        )

        # Define an AWS CodePipeline-based Pipeline to deploy CDK applications
        pipeline = CdkPipeline(
            self,
            "TestPipeline",
            cloud_assembly_artifact=cloud_assembly_artifact,
            source_action=source_action,
            synth_action=synth_action,
        )

Error during the Synth build:

.......
⠙ Locking...·✔ Success!
--
1065 | Updated Pipfile.lock (cb10c5)!
1066 | Installing dependencies from Pipfile.lock (cb10c5)…
1067 | To activate this project's virtualenv, run pipenv shell.
1068 | Alternatively, run a command inside the virtualenv with pipenv run.
1069 |  
1070 | [Container] 2020/08/27 01:48:18 Running command export PYTHONPATH=$PWD pipenv run cdk synth
1071 |  
1072 | [Container] 2020/08/27 01:48:18 Phase complete: BUILD State: SUCCEEDED
1073 | [Container] 2020/08/27 01:48:18 Phase context status code:  Message:
1074 | [Container] 2020/08/27 01:48:18 Entering phase POST_BUILD
1075 | [Container] 2020/08/27 01:48:18 Phase complete: POST_BUILD State: SUCCEEDED
1076 | [Container] 2020/08/27 01:48:18 Phase context status code:  Message:
1077 | [Container] 2020/08/27 01:48:18 Expanding base directory path: cdk.out
1078 | [Container] 2020/08/27 01:48:18 Assembling file list
1079 | [Container] 2020/08/27 01:48:18 Expanding cdk.out
1080 | [Container] 2020/08/27 01:48:18 Skipping invalid file path cdk.out
1081 | [Container] 2020/08/27 01:48:18 Phase complete: UPLOAD_ARTIFACTS State: FAILED
1082 | [Container] 2020/08/27 01:48:18 Phase context status code: CLIENT_ERROR Message: no matching base directory path found for cdk.out

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

12reactions
mikelhamercommented, Oct 22, 2021

@alexandrustf I had the same problem because my cdk project was in a subdirectory. I solved it by setting primaryOutputDirectory: 'cdk/cdk.out'

    const pipeline = new CodePipeline(this, 'Pipeline', {
      synth: new ShellStep('Synth', {
        input: CodePipelineSource.codeCommit(codecommit.Repository.fromRepositoryName(this, 'Repository',
          'myrepo'), 'main'),
        commands: ['cd cdk', 'npm ci', 'npm run build', 'npx cdk synth'],
        primaryOutputDirectory: 'cdk/cdk.out'
      })
    });

Note that if you already have the pipeline deployed you will either have to destroy it and redeploy or manually edit the buildspec of the CodeBuild project to get it to succeed the first time after making this change in the stack. Otherwise it will just keep failing at the Build step and never make it to the UpdatePipeline step to update the actual CodeBuild setting.

0reactions
alexandrustfcommented, Oct 16, 2021

I had also this problem. For me ,the problem was that the cdk.out must be in the root folder of the repository. So, I added a new command: mv cdk.out …/ .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cloud evelopment Kit for CodePipeline fails no matching base ...
I ran into the same error while on CDK v2. In my case, I had to specify the subdirectory where CodePipeline could expect...
Read more >
CDK Pipelines - AWS Documentation - Amazon.com
It takes one argument, a synth step, which is expected to produce the CDK Cloud Assembly as its single output (the contents of...
Read more >
AWS CDK Pipelines: Real-World Tips and Tricks (Part 2)
Build the CDK app and synthesise the CloudFormation templates locally using npx cdk synth. This will create a folder cdk.out/assembly-Personal , which contains ......
Read more >
aws-cdk.pipelines - PyPI
Therefore, these APIs are not subject to Semantic Versioning, ... Assembly in it (the contents of the cdk.out directory created when cdk synth...
Read more >
CDK Pipelines - Go Packages
Check your target environments and make sure they are all bootstrapped. Message: no matching base directory path found for cdk.out. If you see...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found