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

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

Open
2 tasks
mariusingjer opened this issue Jan 14, 2022 · 2 comments
Open
2 tasks
Labels
@aws-cdk/pipelines CDK Pipelines library effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1

Comments

@mariusingjer
Copy link

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
@mariusingjer mariusingjer added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jan 14, 2022
@github-actions github-actions bot added the aws-cdk-lib Related to the aws-cdk-lib package label Jan 14, 2022
@njlynch njlynch added @aws-cdk/pipelines CDK Pipelines library and removed aws-cdk-lib Related to the aws-cdk-lib package labels Jan 21, 2022
@njlynch njlynch assigned rix0rrr and unassigned njlynch Jan 21, 2022
@rix0rrr rix0rrr added effort/medium Medium work item – several days of effort p1 and removed needs-triage This issue or PR still needs to be triaged. labels Feb 8, 2022
@rix0rrr rix0rrr removed their assignment Feb 8, 2022
@lukepopp
Copy link

This scope needs to increase a bit. VariablesNamepaces should be able to be added to ShellSteps and other steps like CodePipelineSource.

@aktur
Copy link

aktur commented Jul 29, 2022

In my use case I need this feature to pass outputs of CloudFormation stack to deployment in a different environment (region and account number). At the moment I'm using CustomResource with Lambda to read parameters store from the other environment and import it to target account. This has an disadvantage, that the Lambda stays after the stack creation while it is used only during deployment. Using VariablesNamespaces is more elegant for it. It can be set from the web console however, as soon as the stack is updated this manual configuration is gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/pipelines CDK Pipelines library effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1
Projects
None yet
Development

No branches or pull requests

5 participants