简体   繁体   中英

How do i pass parameters from first cdk stack's output to another cdk stack's input, when deploying using jenkins pipeline?

I have one bitbucket repository, in that, I have 4 CDK stacks in a separate folder. Now I want to create a Jenkins pipeline, Like in the first stage the first stack has been built and deployed,

now I want to use the first stack outputs as second stack's inputs and the same for the third and fouth folders.

To use another stack's output, use the Fn.importValue function .

Like this:

imported_output = cdk.Fn.import_value("OUTPUT_NAME")

A good alternative would be to deploy all of your stacks together in a single CDK app and just pass the object references between your stacks.

CDK will figure out the necessary outputs/imports under the hood, and will deploy the stacks in the correct order automatically.

Here's an example from the docs :

prod = cdk.Environment(account="123456789012", region="us-east-1")

stack1 = StackThatProvidesABucket(app, "Stack1", env=prod)

# stack2 will take a property "bucket"
stack2 = StackThatExpectsABucket(app, "Stack2", bucket=stack1.bucket, env=prod)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM