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年前683ビュー
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.

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ