Set of utilities that can be used for nx cdk application development.
To install this package run:
npm i @routineless/cdk
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',
})
}
}
MIT © 2023 Anatoli Kozel