The operator CLI for CDK apps.

Overview

cdk-app

The operator CLI for CDK apps. Experimental.

cdk-app lets you associate commands with CDK constructs so that you can quickly invoke functions, redrive queues, visit resources in the AWS console, and more by just referencing the construct name.

Examples:

  • cdk-app MyLambda tail-logs - stream logs in real time from the Lambda's log group
  • cdk-app TransactionTable visit-console - open the AWS console page for your table
  • cdk-app OrderQueue redrive-queue - retry messages that failed to get processed

🚀 Getting Started

Create a CDK app with a Lambda function, and deploy it to your AWS account.

const fn = new lambda.Function(this, 'MyLambda', {
  code: lambda.Code.fromInline("exports.handler = async (event) => { console.log('event: ', event) };"),
  handler: 'index.handler',
  runtime: lambda.Runtime.NODEJS_14_X,
});

Next, npm install -g cdk-app-cli and view the available commands:

$ cdk-app MyLambda
Commands:
  describe
  invoke
  visit-console
  audit-console

Run a command to instantly access the construct in the AWS console:

$ cdk-app MyLambda visit-console

Or run a command to get information in your command line:

$ cdk-app MyLambda describe
> aws lambda get-function --function-name DemoAppStack-MyLambdaCCE802FB-lELPCJlktCim
{
    "Configuration": {
        "FunctionName": "DemoAppStack-MyLambdaCCE802FB-lELPCJlktCim",
        ...

Any extra arguments you pass will get automatically passed through to the underlying command.

You can add your own commands by defining a JSON or YAML file in your CDK app named construct-commmands. For example, here we define some commands that use the awslogs CLI:

# construct-commands.yml
aws-cdk-lib.aws_lambda.Function:
  logs:
    exec: awslogs get /aws/lambda/${PHYSICAL_RESOURCE_ID} --start='5m ago'
  tail-logs:
    exec: awslogs get /aws/lambda/${PHYSICAL_RESOURCE_ID} ALL --watch

Now these commands will be available to use:

$ cdk-app MyLambda
Commands:
  describe
  invoke
  visit-console
  audit-console
  logs
  tail-logs

Try using cdk-app in scripts as well!

#!/usr/bin/env bash

declare -a arr=("MyLambda" "MyTable" "MyQueue")

for construct in "${arr[@]}"; do
  cdk-app "$construct" visit-console
done

📖 Documentation

Command line options

cdk-app [construct] [subcommand]

Run an operator command on your CDK app's constructs.

Positionals:
  construct                                                  [string] [required]
  subcommand                                                            [string]

Options:
  --version  Show version number                                       [boolean]
  --help     Show help                                                 [boolean]

Extra configuration options available via environment variables:

- CDK_APP_DIR - Path to cdk.out.
- AWS_REGION - AWS region to run commands in.

construct-commands.json

Command types

Type Description
open Specify a URL or file to open.
exec Specify a command to run in your shell.

Command substitutions

Syntax Description
${AWS_REGION} The AWS_REGION of the current shell environment (e.g. us-east-1).
${PHYSICAL_RESOURCE_ID} The physical resource ID of construct's default resource. A construct named "Default" or "Resource" will automatically be assumed to be the default.
${URL_ENCODED_PHYSICAL_RESOURCE_ID} The same as ${PHYSICAL_RESOURCE_ID}, except the value is URL encoded.

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

You might also like...

Example Serverless DynamoDB integration tests using Jest, TypeScript and the AWS CDK

Example Serverless DynamoDB integration tests using Jest, TypeScript and the AWS CDK

serverless dynamodb integration tests 🚀 Example Serverless DynamoDB integration tests using Jest, TypeScript and the AWS CDK Introduction How to inte

Nov 4, 2022

AWS Serverless Event-driven Microservices with using AWS Lambda, AWS DynamoDB, AWS API Gateway, AWS EventBridge, AWS SQS, AWS CDK stands for Cloud Development Kit for IaC — Infrastructure as Code tool and AWS CloudWatch for monitoring.

AWS Serverless Event-driven Microservices with using AWS Lambda, AWS DynamoDB, AWS API Gateway, AWS EventBridge, AWS SQS, AWS CDK stands for Cloud Development Kit for IaC — Infrastructure as Code tool and AWS CloudWatch for monitoring.

Serverless Event-driven E-commerce Microservices UDEMY COURSE WITH DISCOUNTED - Step by Step Development of this Repository - https://www.udemy.com/c

Jan 3, 2023

Easy-to-use CDK constructs for monitoring your AWS infrastructure

CDK Monitoring Constructs Easy-to-use CDK constructs for monitoring your AWS infrastructure. Easily add commonly-used alarms using predefined properti

Jan 6, 2023

AWS CDK compiled for web (and Node!)

cdk-web 🚀 DEMO 💪 AWS CDK compiled for web (and Node!) cdk-web and aws-cdk-web are functionally identical packages on npm. read about the differences

Dec 5, 2022

Pulumi/CDK Interop Library

Pulumi CDK Adapter (preview) The Pulumi CDK Adapter is a library that enables Pulumi programs to use AWS CDK constructs. The adapter allows writing AW

Dec 18, 2022

A sample CICD Deployment Pipeline for your Alexa Skills, using AWS CDK, CodeBuild and CodePipeline

A sample CICD Deployment Pipeline for your Alexa Skills, using AWS CDK, CodeBuild and CodePipeline

Alexa Skils - CI/CD CDK Pipeline This repository will help you setting up a CI/CD pipeline for your Alexa Skills. This pipeline is powered by AWS Clou

Nov 23, 2022

CDK constructs for self-hosted GitHub Actions runners

GitHub Self-Hosted Runners CDK Constructs Use this CDK construct to create ephemeral self-hosted GitHub runners on-demand inside your AWS account. Eas

Dec 20, 2022

Learn Web 2.0 and Web 3.0 Development using Next.js, Typescript, AWS CDK, AWS Serverless, Ethereum and AWS Aurora Serverless

Learn Web 2.0 Cloud and Web 3.0 Development in Baby Steps In this course repo we will learn Web 2.0 cloud development using the latest state of the ar

Jan 3, 2023

Sample code for resizing Images with Lambda@Edge using the Custom Origin. You can deploy using AWS CDK.

Sample code for resizing Images with Lambda@Edge using the Custom Origin. You can deploy using AWS CDK.

Resizing Images with Lambda@Edge using the Custom Origin You can resize the images and convert the image format by query parameters. This Lambda@Edge

Dec 11, 2022
Comments
  • NodejsFunction lambdas don't match the command store

    NodejsFunction lambdas don't match the command store

    NodejsFunctions end up with the fqn of aws-cdk-lib.aws_lambda_nodejs.NodejsFunction which don't match what's stored in the default command-store.json file, but they would inherently have the same commands.

    I propose storing a list of aliases in the library and then the command-store.ts could normalize them before retrieving the commands. Alternately... use the CloudFormation resource type instead, which would be consistent "aws:cdk:cloudformation:type": "AWS::Lambda::Function",

    I'd be happy to contribute to the project.

    stale 
    opened by martzcodes 2
Releases(v0.0.215)
Owner
CDK Labs at AWS
CDK Labs at AWS
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A very simple tool that generates multiple spellings of a phone number (to effectively search for it using the OR operator and quotes)

phonenumberqueryconstructor A very simple tool that generates multiple writings of a phone number (to effectively search for it using the OR operator

Cyb_detective 10 Dec 7, 2022
Dark theme for VSCode with italics support (good for Dank Mono, Operator Mono)

Omni Owl for Visual Studio Code Dark theme for Visual Studio Code (with Italics) Install • Team • Imitate Preview • License Install All instructions c

Guilherme Rodz 59 Dec 23, 2022
A Kubernates Cloud-Shell (Web Terminal) Operator

A Kubernates Cloud-Shell (Web Terminal) Operator. English | Simplified_Chinese Why cloudtty ? Existing project ttyd already provides great feature to

cloudtty-io 307 Dec 27, 2022
Trivy-Operator Lens Extension

Trivy-Operator Lens Extension This is a Lens extension for trivy-operator which provides visibility into vulnerability,misconfiguration and secrets as

Aqua Security 18 Dec 5, 2022
🦕 An opposite function of nullish coalescing operator

unnullish unnullish returns undefined if value is nullish, otherwise it executes callback and returns the result. It is an opposite function of the nu

Alisue 15 Dec 15, 2022
ESLint plugin to disallow the optional-call operator

ESLint Plugin: no-optional-call Overview The no-optional-call ESLint plugin provides a single rule (non-configurable) that disallows any usage of the

Kyle Simpson 15 Sep 24, 2022
This project provides a CDK construct creating AWS organizations.

AWS Organizations This project provides a CDK construct creating AWS organizations. Currently, there is no @aws-cdk/aws-organizations available. See t

Pepperize 107 Dec 29, 2022
Sample AWS microservices app with service discovery defined using the CDK. Uses Docker + Fargate & ELB.

AWS Microservices Demo with CDK and Fargate About Simple AWS microservice-based app. Consists of two Spring Boot based services: Name Service GET /nam

Nick Klaene 7 Nov 23, 2022