Solve CDK recursing asset staging output ENAMETOOLONG error

0

When deploying an aws CDK project, I am intermittently faced with an error containing the following text: Error: ENAMETOOLONG: name too long, copyfile '/opt/app/deploy-project/cdk/cdk.out/asset.549cca69f33e5b267d9a73aff143ef2ac7d7887e7d6fb24186e7c469b1f491ae/deploy-project/cdk/cdk.out/[repeating] It shows a recursion on one of the asset folders and it finally times out after 20 minutes. I have tried some of the solutions I read about in the aws CDK GitHub issues:

  1. add a .dockerignore file to the root of the project with the contents: cdk*
  2. add an exclude property to the DockerImageAsset method:
image = ecr_assets.DockerImageAsset(self, 'DeployDockerImage',
                                            directory=os.path.abspath('../../'),
                                            file="deploy-project.Dockerfile",
                                            exclude=["cdk"]
                                            )

But none of these things have worked. I also should mention that I am using aws-cdk-lib 2.69.0

profile picture
已提问 1 年前682 查看次数
1 回答
0

Hello

By reviewing the GitHub issue and the code snippet provided, it appears there may be issues in the steps followed for the accepted solutions.

So, can you try the following approach described in the issue:

Excluding cdk.out in asset object instead of cdk


`: image = ecr_assets.DockerImageAsset(self, 'DeployDockerImage',
                                            ..
                                            exclude=['cdk.out']   //  you are excluding cdk
                                            )`

Alternative, the most popular solution suggests:

  1. )added cdk* to .dockerignore to get it working (which you have already done)
  2. ) making sure check cdk.json, it should contain:
{
  "context": {
    "@aws-cdk/aws-ecr-assets:dockerIgnoreSupport": true
  }
}

If not specified as true .dockerignore is ignored

AWS
已回答 1 年前
  • I cannot add { "context": { "@aws-cdk/aws-ecr-assets:dockerIgnoreSupport": true } } to my cdk.json file as it causes the following error:

    Error: Unsupported feature flag '@aws-cdk/aws-ecr-assets:dockerIgnoreSupport'. This flag existed on CDKv1 but has been removed in CDKv2. CDK will now behave as the same as when the flag is enabled.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则