Getting Started with Pipelines

Note: This segment of the workshop assumes you have completed the previous sections of the workshop. If you have not, and just want to follow this segment, or you are returning to try this workshop, you can use the code here that represents the last state of the project after adding the tests.

Create Pipeline Stack #

The first step is to create the stack that will contain our pipeline. Since this is separate from our actual “production” application, we want this to be entirely self-contained.

Create a new file under src/main/java/com/myorg called WorkshopPipelineStack.java. Add the following to that file.

package com.myorg;

import software.constructs.Construct;
import software.amazon.awscdk.Stack;
import software.amazon.awscdk.StackProps;

public class WorkshopPipelineStack extends Stack {
    public WorkshopPipelineStack(final Construct parent, final String id) {
        this(parent, id, null);
    }

    public WorkshopPipelineStack(final Construct parent, final String id, final StackProps props) {
        super(parent, id, props);

        // Pipeline code goes here
    }
}

Look familiar? At this point, the pipeline is like any other CDK stack.

Update CDK Deploy Entrypoint #

Next, since the purpose of our pipeline is to deploy our application stack, we no longer want the main CDK application to deploy our original app. Instead, we can change the entry point to deploy our pipeline, which will in turn deploy the application.

To do this, edit the code in src/main/java/com/myorg/CdkWorkshopApp.java as follows:

package com.myorg;

import software.amazon.awscdk.App;

public final class CdkWorkshopApp {
    public static void main(final String[] args) {
        App app = new App();

        new WorkshopPipelineStack(app, "PipelineStack");

        app.synth();
    }
}

And now we’re ready!

Lets build a pipeline! #

We use analytics to make this content better, but only with your permission.

More information