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

1.4.2 • Public • Published

License: MIT NPM Version codecov Typescript Semantic Release Commitizen friendly

cdk

Set of utilities that can be used for nx cdk application development.

Table of Contents

Install

To install this package run:

npm i @routineless/cdk

Usage

There are some type definitions and utility function that can be used for cdk infrastructure code development.

You can use them to define basic stack props to destinguish envirements.

BaseStackProps type definition, you can extend it to add more props and use accross stacks:

import type { Environment, StackProps } from 'aws-cdk-lib'

export interface CdkEnvironment extends Environment {
  readonly envName: string
}

export interface BaseStackProps extends StackProps {
  readonly env: CdkEnvironment
}

Lambda infrastructure code example:

import { BaseStackProps, capitalize } from '@routineless/cdk'
import { Stack } from 'aws-cdk-lib'
import * as lambda from 'aws-cdk-lib/aws-lambda'
import type { Construct } from 'constructs'
import path from 'path'

export class LambdaStack extends Stack {
  constructor(scope: Construct, id: string, props: BaseStackProps) {
    super(scope, id, props)

    new lambda.Function(this, 'LambdaFunction', {
      functionName: `Lambda${capitalize(props.env.envName)}`,
      runtime: lambda.Runtime.NODEJS_18_X,
      code: lambda.Code.fromAsset(path.join(__dirname, '../runtime')),
      handler: 'main.handler',
    })
  }
}

Maintainers

@KozelAnatoliy

License

MIT © 2023 Anatoli Kozel

Package Sidebar

Install

npm i @routineless/cdk

Weekly Downloads

234

Version

1.4.2

License

MIT

Unpacked Size

13.4 kB

Total Files

26

Last publish

Collaborators

  • tolis_propolis