aws-cdk: [aws-lambda-nodejs] .parcel-cache permission denied in BitBucket Pipelines

Bitbucket Pipeline failed to create NodejsFunction in docker. When I attempt to create a lambda using that construct and synthesize, I get an error [Error: EACCES: permission denied, mkdir ‘/asset-input/.parcel-cache’]

Reproduction Steps

import * as cdk from '@aws-cdk/core';
import * as nodejs from '@aws-cdk/aws-lambda-nodejs';

export class BugStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    new nodejs.NodejsFunction(this, 'handler');
  }
}

The handler a bit complex to show here, but it is irrelevant.

Error Log

> zolar-cdk@1.0.0 deploy /opt/atlassian/pipelines/agent/build/.cdk
> cdk --trace deploy "-a" "projects/sfbridge/create.js"
Bundling asset dev-serg-test-sfbridge/dev-serg-test-sfbridge-sf-zpc-bridge/Code/Stage...
[Error: EACCES: permission denied, mkdir '/asset-input/.parcel-cache'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/asset-input/.parcel-cache'
}
/opt/atlassian/pipelines/agent/build/.cdk/node_modules/@aws-cdk/core/lib/asset-staging.js:123
            throw new Error(`Failed to run bundling Docker image for asset ${this.node.path}: ${err}`);
            ^
Error: Failed to run bundling Docker image for asset dev-serg-test-sfbridge/dev-serg-test-sfbridge-sf-zpc-bridge/Code/Stage: Error: docker exited with status 1
    at AssetStaging.bundle (/opt/atlassian/pipelines/agent/build/.cdk/node_modules/@aws-cdk/core/lib/asset-staging.js:123:19)
    at new AssetStaging (/opt/atlassian/pipelines/agent/build/.cdk/node_modules/@aws-cdk/core/lib/asset-staging.js:38:35)
    at new Asset (/opt/atlassian/pipelines/agent/build/.cdk/node_modules/@aws-cdk/aws-s3-assets/lib/asset.js:21:25)
    at AssetCode.bind (/opt/atlassian/pipelines/agent/build/.cdk/node_modules/@aws-cdk/aws-lambda/lib/code.js:137:26)
    at new Function (/opt/atlassian/pipelines/agent/build/.cdk/node_modules/@aws-cdk/aws-lambda/lib/function.js:80:33)
    at new NodejsFunction (/opt/atlassian/pipelines/agent/build/.cdk/node_modules/@aws-cdk/aws-lambda-nodejs/lib/function.js:30:13)
    at ZolarSFBridge.scheduleLambda (/opt/atlassian/pipelines/agent/build/.cdk/projects/sfbridge/ZolarSFBridge.js:34:24)
    at new ZolarSFBridge (/opt/atlassian/pipelines/agent/build/.cdk/projects/sfbridge/ZolarSFBridge.js:29:14)
    at Object.<anonymous> (/opt/atlassian/pipelines/agent/build/.cdk/projects/sfbridge/create.js:7:19)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
Subprocess exited with error 1

Environment

  • CLI Version : 1.53.0
  • Framework Version: 1.53.0
  • Node.js Version: 12
  • OS : lambci/lambda:build-nodejs12.x
  • Language (Version): TypeScript (3.8.3)

Other

looks related to #8757


This is 🐛 Bug Report

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 18 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Please, let me know if you need anything else.

Are you using the docker executor or machine executor? https://support.circleci.com/hc/en-us/articles/360007324514-How-can-I-use-Docker-volume-mounting-on-CircleCI and https://circleci.com/docs/2.0/executor-types/#using-machine

@jogold — I was using docker executor, I change it to machine executor, and now is working! 🎉 🍻

Working Code

version: 2.1
jobs:
  build_and_deploy:
    machine:
      image: ubuntu-1604:202007-01
    working_directory: ~/repo
    steps:
      - checkout
      - attach_workspace:
          at: .
   
... MORE CODE ...

Not Working Code

version: 2.1
jobs:
  build_and_deploy:
    docker:
      - image: cimg/python:3.8.4
    working_directory: ~/repo
    steps:
      - checkout
      - attach_workspace:
          at: .

      - setup_remote_docker:
          version: 19.03.12
          docker_layer_caching: true

... MORE CODE ...

Thank you for the help!

So, not sure if it helps anyone else, but I found I was having this similar issue. I had a direct “dependency” in my package.json to parcel and parcel-bundler. Removing those (and a rm -rf node_modules && npm i) resolved the issue for me.

Hope that helps someone else.