CDK & Cloudformation Cloning tool

Installing the DZ CLI

Requirements: Node v19, AWS CLI with default profile set up

CDK #

access cloudformation utilities

Usage: dz cdk [command]

Available Commands:

delete: delete cdk instance

deploy: deploy cdk

deployCFn: deploy ephemeral stack from CFn template listStacks list ephemeral stacks

Usage: dz cdk deploy [flags]

Flags:

-a, --adtlCDKFlags string Additional flags for CDK build command

-b, --buildCmd string Build cmd for CDK compilation

-f, --filepath string filepath to implementation of stack (required)

-h, --help help for deploy

-n, --namespace string namespace appended to suffix

-s, --suffix string suffix to add to stack (default randomly generated)

--synth synthesize template only, do not deploy

The CDK command is for use with AWS CDK and AWS Cloudformation stack applications. It’s used to create ephemeral stacks from a base deployment.

cdk deploy Example: An organization has a cdk app checked in to github that represents a core service they use. It consists of a dynamo database, lambda function, and API gateway instance. A developer needs to make an adjustment to the behavior of the lambda function. With the base CDK stack deployed in production as org1cdkapp , the developer will check out the repository, make their changes locally, and run dz cdk deploy -f ./path-to-main-stack-class . This command will compile and upload a new cdk app mirroring the production version, containing the developers local changes. The stack name will be similar to org1cdkappfkel . Note the random char string appended to the end of the original stack name. The command will return a link to the application in the AWS Cloudformation account matching the default profile defined in the users settings. It will also return a list of outputs created by the deploy command, which in this example case would be a link to the API gateway URI. Additionally, the ephemeral CDK deployment is cached locally. If the developer were to re-run dz cdk deploy -f ... again, the previous ephemeral CDK stack would be deleted after the new one was successfully deployed.

cdk deployCFn Example: An organization not using AWS CDK has an AWS Cloudformation stack created that represents a core service they use. It contains the same elements in the above example. Since they’re not using CDK, we need to programatically edit their cloudformation template in order to create an ephemeral stack. Treating the template as a manifest file, they have been previously instructed to edit the code such that the lambda resource in the template JSON points to the location of the lambda code in their workspace.

"MyLambdaFunction": {"Type": "AWS::Lambda::Function", "Properties": { "Code": { "S3Bucket": "src", <-- this is the folder location in repo where the lambda is "S3Key": "" <-- this can be anything, it gets overwritten }, }

From the root of the repository containing the lambda code, a developer will run a command similar to cdk deployCFn -f /Org-app/template-manifest.json . This command will bundle, package, and upload the developers local lambda files (ensuring any local changes they have made are included) to an S3 bucket, who’s location will be written into the ephemeral cloudformation stack template which also gets uploaded to AWS. The result of this command is an ephemeral cloudformation stack, similar to the cdk deploy command.

Feature requests #

If there’s anything you wish you could do from your terminal that isn’t in the CLI yet, please drop us a line at support@devzero.io!

PreviousProfile Information
NextUser Onboarding