Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cdk-standalone-deployer

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cdk-standalone-deployer

This construct enable to easily deploy an AWS CDK app without a local environment. This construct will create a Cloud Formation template starting an AWS Code Build project which will run a `cdk bootstrap` and `cdk deploy` from the given source (being eith

  • 0.0.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

CDK app deployer

This construct enable to easily deploy an AWS CDK app without a local environment. This construct will create a Cloud Formation template starting an AWS Code Build project which will run a cdk bootstrap and cdk deploy from the given source (being either a zip in an S3 bucket or a github repository).

It also come with a command line enabling to create a simple deploy link for your CDK app such as:

click-to-deploy

If you follow this link, it will deploy the example contains in the aws-samples/aws-cdk-examples repo typescript/lambda-layer folder (which consist of a simple Lambda layer CDK app) into your AWS account.

Usage

  • TypeScript example bin/myCdkApp.ts
#!/usr/bin/env node
import 'source-map-support/register';
import * as cdk from 'aws-cdk-lib';
import { MyCdkAppStack } from '../lib/my_cdk_app-stack';
import { CdkStandaloneDeployer } from 'cdk-standalone-deployer';

const app = new cdk.App();
const stackName = 'MyCdkAppStack';
new MyCdkAppStack(app, stackName, {});

new CdkStandaloneDeployer(app, {
  deployBuildSpec: BuildSpec.fromSourceFilename('buildspec-deploy.yml'),
  destroyBuildSpec: BuildSpec.fromSourceFilename('buildspec-destroy.yml'),
  githubRepository: 'aws-samples/aws-cdk-examples',
  cdkAppLocation: 'python/lambda-layer',
  }
);

For more details about the CDKStandaloneDeployer API check API.md

The CLI

It also comes with a command line interface (CLI) that enable you to quickly generate click to deploy link.

The CLI will take your CDK app repository name and public S3 bucket to publish the Deployer stack to. It will then synthesize and publish the template with the right configuration without any modification of your code.

Getting started

Taking any of the aws-samples/aws-cdk-examples, to create a click to deploy link you just have to run the following command:

npx cdk-standalone-deployer -github-repo-name aws-samples/aws-cdk-examples --cdk-project-path typescript/lambda-layer --github-repo-branch master --public-read --install-command "npm install" --build-command "npm run build"

Check access permissions ...
Access granted !
Generating the deployer stack ...
Generating deployer for https://github.com/aws-samples/aws-cdk-examples/tree/master/typescript/lambda-layer CDK app ...
CDK Deployer CloudFormation template generated. Uploading it to S3 ...
Uploading CDK Deployer CloudFormation template to S3 bucket cdk-depl-aws-samples-aws-cdk-examples-master-9xf/cdk-standalone-deployer-cfn-template.json ...
You can now add the following markdown to your README.md : [![click-to-deploy](https://img.shields.io/badge/Click%20to-CDK%20Deploy-blue)](https://console.aws.amazon.com/cloudformation/home#/stacks/new?stackName=cdkDeployer&templateURL=https://cdk-depl-aws-samples-aws-cdk-examples-master-9xf.s3.amazonaws.com/cdk-standalone-deployer-cfn-template.json)

Usage

options
npx cdk-standalone-deployer --help

Usage: cli [options]

A simple tool to make your CDK app deployable through a click to deploy button. 
 
 Prerequisite : Export AWS credentials !

Options:
  --github-repo-name <string>        Name of the repo example: "aws-samples/aws-cdk-examples"
  --s3-bucket-name <string>          S3 bucket to use to upload the CDK Deployer stack and potentially the
                                     zip file
  --s3-key-prefix <string>           S3 key prefix to use to upload the CDK Deployer stack and potentially
                                     the zip file
  --s3-bucket-region <string>        S3 bucket region to use to upload the CDK Deployer stack and
                                     potentially the zip file (default: "us-east-1")
  --public-read                      Make the S3 bucket public read (default: false)
  --github-repo-branch <string>      Branch to use (default: "main")
  --cdk-project-path <string>        Path to the cdk app (default: "./")
  --stack-name <string>              Name of the stack to deploy
  --deploy-buildspec-name <string>   Name of the buildspec available in the cdk app to deploy the stack
  --destroy-buildspec-name <string>  Name of the buildspec available in the cdk app to destroy the stack
  --install-command <string>         Command to run to install dependencies
  --build-command <string>           Command to run to build the cdk app
  --bootstrap-command <string>       Command to run to build the cdk app (default: "npx cdk bootstrap")
  --deploy-command <string>          Command to run to deploy the cdk app (default: "npx cdk deploy --all
                                     --require-approval never")
  --destroy-command <string>         Command to run to destroy the cdk app (default: "npx cdk destroy --all
                                     --force")
  -h, --help                         display help for command
BuildSpec focus

As mentionned before the CDKStandaloneDeployer construct rely on AWS CodeBuild. It provides default install/build/bootstrap/deploy/destroy command but you can as well specify your own.

To do so, you have 2 options:

  • Either you have a deploy and destroy buildspec yaml file in your CDK app repository that you can specify using --deploy-buildspec-name and --destroy-buildspec-name. Both are required then.
  • Or you an specify the install/build/bootstrap/deploy/destroy command using --install-command, --build-command, --bootstrap-command, --deploy-command and --destroy-command. Only --install-command is required then.

TODO

  • Add integ test for S3 source
  • Add integ test for custom buildspec
  • add CLI option for auto publish of s3 source
  • add CLI option for parameters
  • add option (CLI and construct) for custom qualifier

Credits

This package is largely inspired by @pahud work (https://github.com/pahud/lambda-url-demo)

Keywords

FAQs

Package last updated on 23 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc