Skip to content

(aws-cdk-lib.pipelines): not able to output variables from cloudformation action #18428

Open
@mariusingjer

Description

@mariusingjer

Description

Cloudformation action supports exposing outputs as variables: https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-variables.html#w2aac51c29b9b7

When adding stages with stacks, like this:

pipeline.addStage( new DeployToStage( this, ...

There is no way of specifying the variable namespace for each stack inside the stage, and therefore not possible to use cloudformation outputs as input to for example a LambdaInvokeStep. Reverting to the low-level aws-cdk-lib/aws-codepipeline is not an option, because there is a lot going on in the pipelines higher level construct which is painful to re-implement (according to this, the low-level supports specifying the variable namespace: #12252).

The only way to get a generated variable namespace is to add a bogus ShellStep with "envFromCfnOutputs", which will cause this code to generate a variable namespace (captureOutputs):

  private addStage(stage: StageDeployment): AGraph {
    const retGraph: AGraph = Graph.of(stage.stageName, { type: 'group' });

    const stackGraphs = new Map<StackDeployment, AGraph>();

    for (const stack of stage.stacks) {
      const stackGraph: AGraph = Graph.of(this.simpleStackName(stack.stackName, stage.stageName), { type: 'stack-group', stack });
      const prepareNode: AGraphNode | undefined = this.prepareStep ? GraphNode.of('Prepare', { type: 'prepare', stack }) : undefined;
      const deployNode: AGraphNode = GraphNode.of('Deploy', {
        type: 'execute',
        stack,
        captureOutputs: this.queries.stackOutputsReferenced(stack).length > 0,
      });

It would be nice if the "addStage" had some fn-param which enabled you to specify variableNameSpace for each stack added in the stage

Use Case

I want to use output variables from cloudformation actions in additional (not ShellSteps) steps added to the pipeline

Proposed Solution

Add the posibility to specify variableNamespace when adding a stage to the pipeline

Other information

No response

Acknowledge

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/pipelinesCDK Pipelines libraryeffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions