Aws-cdk: assets: EKS not deployable via CDK Pipelines

Created on 28 Nov 2020  路  10Comments  路  Source: aws/aws-cdk

Hi there!

I am trying to deploy an EKS cluster via CDK Pipelines. This breaks, because the assets for custom resources within EKS are referenced with absolute path in ...assets.json. This happens during cdk synth in the Pipelines build step. Then, in a later pipeline step, cdk-assets is not able to find the assets (because CodeBuild generate random temp dir names for each run) and therefor uploads empty zip files to S3. This breaks the deployment of the application stack (eks) with this error message in CloudFormation:

Uploaded file must be a non-empty zip (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 6443c97c-4806-4f82-8224-5a4e2afc48b2; Proxy: null)

Reproduction Steps

  1. Create a CDK Pipeline according to the dev guide
  2. add an EKS stack application stage via pipeline.addApplicationStage()
  3. deploy the pipeline and wait for it to fail during application stack deployment

What did you expect to happen?

cdk synth should create references with relative paths for the assets.

What actually happened?

cdk synth creates references with absolute paths for the assets.

Environment

  • CDK CLI Version: 1.75
  • Framework Version: 1.75
  • Node.js Version: v12.18.0
  • OS : Ubuntu 18.10
  • Language (Version): TypeScript (3.9.7)

This is :bug: Bug Report

@aws-cdcore bug efforsmall p1

Most helpful comment

@bracki you are gold.

All 10 comments

@tillkahlbrock It's not a general issue with CDK pipelines. I can deploy an EKS cluster with CDK pipelines successfully.
In my asset.json files, I can't see absolute paths.

{
  "version": "7.0.0",
  "files": {
    "50e10880d134a01b440991fc77d217f39f01c2d56945215ee9a3b81187c6f3b1": {
      "source": {
        "path": "asset.50e10880d134a01b440991fc77d217f39f01c2d56945215ee9a3b81187c6f3b1",
        "packaging": "zip"
      },

I only saw absolute paths in the asset.json files if I specified it explicitly, e.g. cdk synth --no-staging.

Can you provide more information about your issue?

  • Do the absolute paths only appear in the Codepipeline build? Or do they appear also if you run 'cdk synth' locally?
  • Which synth action are you using in the pipeline?

@jumi-dev thanks for the quick response. Regarding your questions:

Do the absolute paths only appear in the Codepipeline build? Or do they appear also if you run 'cdk synth' locally?

I have always absolute path, in CodeBuild and locally.

Which synth action are you using in the pipeline?

I copied this synth action from the DevGuide

synthAction: SimpleSynthAction.standardNpmSynth({
        sourceArtifact,
        cloudAssemblyArtifact,

        // Use this if you need a build step (if you're not using ts-node
        // or if you have TypeScript Lambdas that need to be compiled).
        buildCommand: 'npm run build',
      }),

When I understand the code correctly, it is doing npx cdk synth under the hood. This is what I am doing locally as well.

This does not seem to affect the main custom resources like "Custom::AWSCDK-EKS-*".

I can see the assets for OpenID Provider and "Custom::AWSCDKCfnJson" being rendered with absolute paths though.

This seems like a bug in https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/core/lib/custom-resource-provider/custom-resource-provider.ts#L143.
If I replace that line with fileName: staging.relativeStagedPath(stack) it works.

Paging @eladb @rix0rrr @jogold as you seem most familiar with the asset-staging and custom-resource-provider code.

@rix0rrr seems related to some recent change you worked on. What do you think?

I ran into this error as well while deploying an EdgeFunction with a CDK pipeline.

@bracki you are gold.

@rix0rrr you are welcome 馃槉 , thanks for the quick fix!

鈿狅笍COMMENT VISIBILITY WARNING鈿狅笍

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Kent1 picture Kent1  路  3Comments

mirazmamun picture mirazmamun  路  3Comments

kawamoto picture kawamoto  路  3Comments

nzspambot picture nzspambot  路  3Comments

eladb picture eladb  路  3Comments