Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot deploy the stack because it references asset(s) #7233

Closed
seawatts opened this issue Apr 7, 2020 · 3 comments
Closed

Cannot deploy the stack because it references asset(s) #7233

seawatts opened this issue Apr 7, 2020 · 3 comments
Assignees
Labels
@aws-cdk/assets Related to the @aws-cdk/assets package @aws-cdk/aws-codepipeline Related to AWS CodePipeline bug This issue is a bug.

Comments

@seawatts
Copy link

seawatts commented Apr 7, 2020

I am trying to create a Pipeline stack using the following packages @aws-cdk/app-delivery, @aws-cdk/aws-codepipeline, and @aws-cdk/aws-codebuild. In my infrastructure stack that I am trying to deploy with this pipeline I have a lambda function being created using @aws-cdk/aws-lambda-nodejs NodejsFunction which compiles and uploads the local assets in order to deploy them when running cdk deploy. However, it seems as though this feature is not implemented yet in PipelineDeployStackAction

Code where exception is being thrown
https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/app-delivery/lib/pipeline-deploy-stack-action.ts#L106

Reproduction Steps

#!/usr/bin/env node
import { App, Stack, SecretValue, Construct } from '@aws-cdk/core';
import { NodejsFunction } from '@aws-cdk/aws-lambda-nodejs';
import { LinuxBuildImage, PipelineProject, BuildSpec } from '@aws-cdk/aws-codebuild';
import { Artifact, Pipeline } from '@aws-cdk/aws-codepipeline';
import { CodeBuildAction, GitHubSourceAction, GitHubTrigger } from '@aws-cdk/aws-codepipeline-actions';
import { PipelineDeployStackAction } from '@aws-cdk/app-delivery';

class PipelineStack extends Stack {
  constructor(app: App, id: string) {
    super(app, id);

    const cdkBuild = new PipelineProject(this, 'CdkBuild', {
      buildSpec: BuildSpec.fromObject({
        artifacts: {
          'base-directory': 'dist',
          files: ['**/*'],
        },
        phases: {
          build: {
            commands: ['yarn build', 'yarn cdk synth -o dist'],
          },
          install: {
            commands: ['yarn install'],
          },
        },
        version: '0.2',
      }),
      environment: {
        buildImage: LinuxBuildImage.STANDARD_3_0,
      },
    });

    const sourceOutput = new Artifact();
    const cdkBuildOutput = new Artifact('CdkBuildOutput');
    new Pipeline(this, 'Pipeline', {
      restartExecutionOnUpdate: true,
      stages: [
        {
          actions: [
            new GitHubSourceAction({
              actionName: 'Checkout',
              oauthToken: SecretValue.secretsManager('GitHubToken'),
              output: sourceOutput,
              owner: 'owner',
              repo: 'repo',
              trigger: GitHubTrigger.WEBHOOK,
            }),
          ],
          stageName: 'Source',
        },
        {
          actions: [
            new CodeBuildAction({
              actionName: 'CodeBuild',
              input: sourceOutput,
              outputs: [cdkBuildOutput],
              project: cdkBuild,
            }),
          ],
          stageName: 'Build',
        },
        {
          actions: [
            new PipelineDeployStackAction({
              adminPermissions: true,
              input: cdkBuildOutput,
              stack: this,
            }),
          ],
          stageName: 'SelfUpdate',
        },
        {
          actions: [
            new PipelineDeployStackAction({
              adminPermissions: true,
              input: cdkBuildOutput,
              stack: new InfrastructureStack(app, 'InfrastructureStack'),
            }),
          ],
          stageName: 'Deploy',
        },
      ],
    });
  }
}

class InfrastructureStack extends Stack {
  constructor(scope: Construct, id: string) {
    super(scope, id);
    new NodejsFunction(this, 'Function', {
      allowAllOutbound: true,
      entry: 'labmda.ts',
      handler: 'handler',
    }); 
  }
}

const app = new App();

new PipelineStack(app, 'PipelineStack');
new InfrastructureStack(app, `InfrastructureStack`);

Error Log

./node_modules/@aws-cdk/app-delivery/lib/pipeline-deploy-stack-action.ts:107
      throw new Error(`Cannot deploy the stack ${this.stack.stackName} because it references ${assets.length} asset(s)`);
            ^
Error: Cannot deploy the stack InfrastructureStack because it references 1 asset(s)
    at new PipelineDeployStackAction (./node_modules/@aws-cdk/app-delivery/lib/pipeline-deploy-stack-action.ts:107:13)
    at new PipelineStack (./packages/infrastructure/src/stacks/pipeline/index.ts:77:13)
    at Object.<anonymous> (./packages/infrastructure/src/index.ts:9:1)

Environment

  • **CLI Version :1.31.0
  • **Framework Version:1.31.0
  • **OS :MacOS 10.15.4
  • **Language :Typescript

This is 🐛 Bug Report

@seawatts seawatts added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 7, 2020
@SomayaB SomayaB added @aws-cdk/assets Related to the @aws-cdk/assets package @aws-cdk/aws-codepipeline Related to AWS CodePipeline labels Apr 9, 2020
@xycodex
Copy link

xycodex commented Apr 18, 2020

I encountered this too, though it looks like expected behavior for now:

https://docs.aws.amazon.com/cdk/api/latest/docs/app-delivery-readme.html (Limitation #2)

I was searching the roadmap and found this:
aws/aws-cdk-rfcs#92

Will the work on that rfc #92 remove the limitation? If not, is there another issue to track the removal of the limitation?

There are quite a few constructs that create lambdas internally for convenience (which is actually quite nice), but that precludes any cdk stack using them from being deployed via this PipelineDeployStackAction, which is a bummer.

@fsalamida
Copy link

+1

@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label May 19, 2020
@skinny85
Copy link
Contributor

I encountered this too, though it looks like expected behavior for now:

https://docs.aws.amazon.com/cdk/api/latest/docs/app-delivery-readme.html (Limitation #2)

I was searching the roadmap and found this:
aws/aws-cdk-rfcs#92

Will the work on that rfc #92 remove the limitation? If not, is there another issue to track the removal of the limitation?

There are quite a few constructs that create lambdas internally for convenience (which is actually quite nice), but that precludes any cdk stack using them from being deployed via this PipelineDeployStackAction, which is a bummer.

Yes, the work on aws/aws-cdk-rfcs#92 will lift this restriction 🙂

I'm resolving this one, let us know if you need anything else from our side for this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/assets Related to the @aws-cdk/assets package @aws-cdk/aws-codepipeline Related to AWS CodePipeline bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

5 participants