[CDK Pipeline] Best way to share parameters cross-stage (same account)?

0

I have a CDK Pipeline (aws-cdk v2.3.0) where I would like to share parameters across stages.

When I try to pass the resource across stages, I get dependency cannot cross stage boundaries.

Right now, I'm resorting to putting the variables in ssm string parameters. Is there a better way to share parameters across stages?

1 Antwort
1

Another potential way is using variables in CodePipeline. We need to export variables in CodeBuild BuildSpec, then access the variables in later stages. For example, create a CodeBuild project with exported-variables

const codeBuildProject = new codebuild.PipelineProject({
    buildSpec: aws_codebuild.BuildSpec.fromObject({
         ...
         env: {
          // save the imageTag environment variable as a CodePipeline Variable
          'exported-variables': [
            'imageTag',
          ],
     }
   })
})

CodeBuild action

const codeBuildAction = new codepipeline_actions.CodeBuildAction({
      actionName: 'CodeBuildActionName',
      project: codeBuildProject,
      input: sourceOutput,
    });

then access this variable in Deploy stage

codeBuidlAction.variable('imageTag')

I hope this reference can help you

hai
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen