JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q48702F
  • License ISC

Self-mutating pipeline for cdk-based applications

Package Exports

  • @cfedk/cdk-pipeline

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@cfedk/cdk-pipeline) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

What is this thing?

A self-mutating pipeline definition for cdk apps sourced from GitHub repos. On push to master, CodePipelines will build and deploy your cdk application to whatever stages you have defined.

Installation

npm install --save @cfedk/cdk-pipeline

Usage

  • Create Github access token <github-secret>. It should have permissions to read your repo and create/delete hooks.
  • Add access token to SecretsManager aws secretsmanager create-secret --name <github-token-name> --secret-string <github-secret> --region <pipeline-region>
  • Include a pipeline spec from your cdk entry point:
import * as cdk from '@aws-cdk/core';
import { DeploymentPipeline, makeStack } from '@cfedk/cdk-pipeline';

// Make a cdk construct for a particular stage (allows stage-specific) naming of domains, etc.
// Note that return type of `makeStage`: `(scope: cdk.Construct) => cdk.Construct`.
import { makeStage } from './my-app-root';

const app = new cdk.App();

// Not included in pipeline.
const devStack = makeStack(app, 'dev', {}, stage('dev'));

const betaStack = makeStack(app, 'myapp-beta', { env: { region: '<beta-region>' } }, stage('beta'));
const prodStack = makeStage(app, 'myapp-prod', { env: { region: '<prod-region>' } }, stage('prod'));

new DeploymentPipeline(
    app,
    'myapp-pipeline',
    env: { region: '<pipeline-region>' },
    {
        repository: '<this-respository-name>'
        owner: '<my-github-name>',
        oauthTokenName: '<github-oauth-token-name'>,
    }, 
    [
        {
            stageName: 'Beta',
            stack: betaStack,
        }, 
        {
            stageName: 'Prod',
            stack: prodStack,
        },
    ],
);
  • npm run build
  • cdk synth
  • cdk deploy myapp-pipeline

Once that's done deploying, when you push changes to myapp-github, the pipeline will initiate a deployment of itself, betaStack, and prodStack in corresponding regions. Deployment regions can be the same (normal resource naming constraints apply). Cross-account deployment is not explicitly supported.