@makemydeal/cdk-build-deploy
    TypeScript icon, indicating that this package has built-in type declarations

    1.113.0 • Public • Published

    @makemydeal/cdk-build-deploy

    This package contains the implementation of the Pipeline and PR Stacks. It also contains constructs and interfaces used to setup a SlackBot for notifications. These stacks can be used to setup your PR and Pipelinesm and will be called from your app's CICD Synth script. You will need to manually set up the webhook between GHE and your Codebuild Builds since CDK is not capable of doing that.

    PipelineStack

    PipelineStack is used when you wish to deploy to a single region. This means if you want multi-region support, you will have the pipeline in each region. While this isn't the preferred method, there are some positives. If you wish to deploy a different version of your code to each region for a "canary" like approach via Route 53 weighted routing, this may be for you.

    In order to instantiate a PipelineStack you will need to provide the PipelineStackProps object. This object is documented with the additional properties added by this repo (over StackProps) to support our needs.

    Usage

    import { PRStack, PipelineStack } from '@makemydeal/cdk-build-deploy';
    
    new PRStack(app, `${applicationName}-pr-stack`, {
        applicationName,
        buildSpecFile: './infrastructure/buildspecs/pr.yaml',
        repositoryUrl
    });
    
    // Creates application environment
    new PipelineStack(app, `${applicationName}-pipeline-stack`, {
        applicationName,
        environmentList,
        repositoryUrl,
        buildSpecFile: './infrastructure/buildspecs/build.yaml',
        managers: [restApiLambdaManager, snsLambdaManager],
        infrastructureDistFolder: 'infrastructure/dist'
    });
    
    

    MultiRegionPipelineStack

    MultiRegionPipelineStack is used when you wish to deploy to multiple regions. Multi-Region CodePipelines have a few additional properties to make them work multiple region. One thing they also need is a explicit region property inside the env property of the stack to get the pipeline to work.

    In order to instantiate a MultiRegionPipelineStack you will need to provide the MultiRegionPipelineStackProps object. This interface extends PipelineStackProps adding an additional property for the list of regions you wish to support.

    Usage

    import { PRStack, PipelineStack } from '@makemydeal/cdk-build-deploy';
    
    new PRStack(app, `${applicationName}-pr-stack`, {
        applicationName,
        buildSpecFile: './infrastructure/buildspecs/pr.yaml',
        repositoryUrl
    });
    
    new MultiRegionPipelineStack(app, `${applicationName}-pipeline-stack`, {
        env: {
            // in order for a multi region pipeline to work, you need to be explicit with the version the env (pipeline) is in
            region: 'us-east-1'
        },
        regions: ['us-east-1', 'us-west-2'], // the list of regions you wish to support
        applicationName,
        environmentList,
        notificationsConfig: undefined, // future expansion
        repositoryUrl,
        buildSpecFile: './infrastructure/buildspecs/build.yaml',
        managers: [restApiLambdaManager],
        infrastructureDistFolder: 'infrastructure/dist'
    });
    
    

    Parameter Store Dependencies

    All Deployments using MultiRegionPipelineStack or PipelineStack

    These properties need to be in each region, as they are used during the synth process.

    | Key | Construct | Required | Description | --- | --- | --- | /dr/global/cdk/{environmentName}/account | PipelineJob | Yes | AWS Account used for the environment | /dr/global/cdk/{environmentName}/region | PipelineJob | Yes | AWS Region used for this environment | /dr/global/cdk/{environmentName}/vpc-id | PipelineJob | Yes | VPC ID used for this environment | /dr/global/cdk/{environmentName}/vpce-id | PipelineJob | Yes | VPC Endpoint used for this environment | /dr/global/cdk/{environmentName}/subnet-id | PipelineJob | Yes | Subnet IDs used for this environment | /dr/global/cdk/{environmentName}/security-group-id | PipelineJob | Yes | Security Group Ids used for this environment | /dr/global/cicd/process-code-pipeline-event/arn | PipelineJob | No | ARN to Lambda that can run pre and post actions

    Single Region Deployments using PipelineStack/PipelineJob

    In order to keep backward compatibility, we will use the existing keys below for a single region deployment

    | Key | Construct | Description | /dr/global/cicd/s3/artifact-location | ArtifactStore | The bucket to use for artifacts | /dr/global/integration-tests/lambda-arn | Integration Tests | The ARN to the lambda | /dr/global/integration-tests/invoke/lambda-arn | Integration Tests | The ARN to the lambda to call if we need to invoke in another account | /dr/global/integration-tests/invoke/${environment}/lambda-arn | Integration Tests | ARN in another environment when tests need to be invoked (not called from the pipeline account) | /dr/global/integration-tests/invoke/${environment}/role-arn | Integration Tests | The role needed to invoke

    Multi Region Deployments using MultiRegionPipelineStack/MultiStackPipelineJob

    For multi-region deployments, we will need values in the pipeline (us-east-1) that are references to other regions. We will use these keys

    | Key | Construct | Description | /dr/global/cdk/regions/${region}/s3/artifact-location | ArtifactStore | The bucket to use for artifacts | /dr/global/cdk/regions/${region}/integration-tests/lambda-arn | Integration Tests | The ARN to the lambda | /dr/global/cdk/regions/${region}/integration-tests/invoke/lambda-arn | Integration Tests | The ARN to the lambda to call if we need to invoke in another account | /dr/global/cdk/regions/${region}/integration-tests/invoke/${environment}/lambda-arn | Integration Tests | ARN in another environment when tests need to be invoked (not called from the pipeline account) | /dr/global/cdk/regions/${region}/integration-tests/invoke/${environment}/role-arn | Integration Tests | The role needed to invoke

    Additional Actions

    This package hd 4 actions that you can use in your pipelines as Post Environment Stack actions. They are:

    • ClientUploadAction - Uploads code to an S3 bucket. This is used by the ClientStackManager
    • CloudFrontInvalidationAction - Invalidates Cloudfront on a specific path. This is also used by ClientStackManager
    • RemoveSourceMapAction - This will remove sourcemaps from the S3 bucket. This can be useful for prod deployments, and ClientStackManager uses this for those deployments
    • CopyParameterStoreAction - This will copy values of parameters from one region to another. This is useful when creating resources in one region (HostedZoneId, etc). This is not used by any current stacks, but has been used in projects to copy HostedZoneIds to us-west-2 from us-east-1 to allow the API Gateway being created in us-west-2 to add a custom domain A Record to that hosted zone.

    Keywords

    none

    Install

    npm i @makemydeal/cdk-build-deploy

    DownloadsWeekly Downloads

    1,017

    Version

    1.113.0

    License

    ISC

    Unpacked Size

    2.66 MB

    Total Files

    132

    Last publish

    Collaborators

    • mmd-devops