Skip to content

cdk-pipelines: deploy outputs not usable if only referenced from stack step #17272

@bmmin

Description

@bmmin

What is the problem?

When using deploy outputs in a shell script that is a stackStep, then the deploy action does not declare a namespace, as such the pipeline deployment fails with the following error:

2:40:31 PM | CREATE_FAILED        | AWS::CodePipeline::Pipeline | Pipeline9850B417
Valid format for a pipeline execution variable reference is a namespace and a key separated by a period (.). The following pipeline exe
cution variables are referencing a namespace that does not exist.
StageName=[stage], ActionName=[integTest], ActionConfigurationKey=[EnvironmentVariables], VariableReferenceText=[stage-app.out] (Servic
e: AWSCodePipeline; Status Code: 400; Error Code: InvalidActionDeclarationException; Request ID: 60b6cbb3-bf5d-49a9-9a4c-0e55be10397a;
Proxy: null)

Reproduction Steps

import { Repository } from "@aws-cdk/aws-codecommit";
import { CfnOutput, Construct, Stack, Stage } from "@aws-cdk/core";
import { CodePipeline, CodePipelineSource, ShellStep } from "@aws-cdk/pipelines";

export class PipelineStack extends Stack {
    constructor(scope: Construct, id: string) {
        super(scope, id);

        const repository = Repository.fromRepositoryName(this, "Repository", "repo");
        const codeSource = CodePipelineSource.codeCommit(repository, "main");

        const pipeline = new CodePipeline(this, "Pipeline", {
            synth: new ShellStep("Synth", {
                commands: [ "echo hi" ],
                input: codeSource,
            })
        });
        const stage = new AppStage(this, "stage");
        pipeline.addStage(stage, {
            stackSteps: [{
                stack: stage.stack,
                post: [new ShellStep("integTest", {
                    commands: [ "echo hi" ],
                    envFromCfnOutputs: { "INPUT": stage.stack.output },
                })]
            }]
        });
    }
}

class AppStage extends Stage {
    public readonly stack: AppStack;
    constructor(scope: Construct, id: string) {
        super(scope, id);
        this.stack = new AppStack(this, "app"); 
    }
}

class AppStack extends Stack {
    public readonly output: CfnOutput;
    constructor(scope: Construct, id: string) {
        super(scope, id);
        this.output = new CfnOutput(this, "out", { value: "hi" });
    }
}

What did you expect to happen?

no errors on deployment

What actually happened?

deployment fails, since the deploy step does not define a variable namespace for the pipeline

CDK CLI Version

1.130.0

Framework Version

No response

Node.js Version

v12.20.0

OS

Mac 10.15.7

Language

Typescript

Language Version

TS: 4.4.4

Other information

bug is in


it ignores the stackSteps

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/pipelinesCDK Pipelines librarybugThis issue is a bug.effort/smallSmall work item – less than a day of effortp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions