Install the umbrella package which includes all sub-packages:
pnpm add @gradientedge/cdk-utils
Or install only the packages you need:
# AWS CDK utilities
pnpm add @gradientedge/cdk-utils-aws
# Azure Pulumi utilities
pnpm add @gradientedge/cdk-utils-azure
# Cloudflare Pulumi utilities
pnpm add @gradientedge/cdk-utils-cloudflare
# Common utilities (included as a dependency of the above)
pnpm add @gradientedge/cdk-utils-common
Constructs are high-level patterns that combine multiple AWS/Azure/Cloudflare resources into a single reusable unit. Examples include:
Service managers are injected into every construct and provide methods for creating individual resources. Each AWS/Azure/Cloudflare service has its own manager:
lambdaManager — Lambda functions, layers, aliasess3Manager — S3 buckets, policies, notificationsdynamodbManager — DynamoDB tables, indexesecsManager — ECS clusters, services, task definitionsShared across all packages:
isDevStage(), isPrdStage(), isUatStage(), isTestStage()Stage.DEV, Stage.TEST, Stage.UAT, Stage.PRODapplyMixins() for composing multiple classesCreate a custom construct by extending CommonConstruct:
import { CommonConstruct, CommonStackProps } from '@gradientedge/cdk-utils-aws'
import { Construct } from 'constructs'
class MyInfrastructure extends CommonConstruct {
constructor(parent: Construct, id: string, props: CommonStackProps) {
super(parent, id, props)
this.props = props
this.initResources()
}
protected initResources() {
// Create a Lambda function
this.lambdaManager.createLambdaFunction('MyFunction', this, {
name: 'my-function',
handler: 'index.handler',
runtime: 'nodejs22.x',
})
// Create an S3 bucket
this.s3Manager.createBucket('MyBucket', this, {
name: 'my-bucket',
versioned: true,
})
// Create a DynamoDB table
this.dynamodbManager.createTable('MyTable', this, {
name: 'my-table',
partitionKey: { name: 'id', type: 'S' },
})
}
}
Or use a pre-built construct pattern:
import { RestApiLambda, RestApiLambdaProps } from '@gradientedge/cdk-utils-aws'
import { Construct } from 'constructs'
class MyApi extends RestApiLambda {
constructor(parent: Construct, id: string, props: RestApiLambdaProps) {
super(parent, id, props)
this.props = props
this.initResources()
}
}
The Azure package uses the Pulumi Azure Native provider (@pulumi/azure-native), providing full coverage of the Azure Resource Manager API.
import { CommonAzureConstruct } from '@gradientedge/cdk-utils-azure'
import * as pulumi from '@pulumi/pulumi'
class MyAzureInfra extends CommonAzureConstruct {
constructor(name: string, args: any, opts?: pulumi.ComponentResourceOptions) {
super(name, args, opts)
this.initResources()
}
protected initResources() {
// Create a storage account
this.storageManager.createStorageAccount('MyStorage', this, storageProps)
// Create a function app
this.functionManager.createFunctionApp('MyFunction', this, functionProps)
// Create a CosmosDB database
this.cosmosDbManager.createCosmosDbAccount('MyDb', this, cosmosProps)
}
}
import { CommonCloudflareConstruct } from '@gradientedge/cdk-utils-cloudflare'
import * as pulumi from '@pulumi/pulumi'
class MyCloudflareInfra extends CommonCloudflareConstruct {
constructor(name: string, args: any, opts?: pulumi.ComponentResourceOptions) {
super(name, args, opts)
this.initResources()
}
protected initResources() {
// Manage a Cloudflare zone
this.zoneManager.createZone('MyZone', this, zoneProps)
// Deploy a Cloudflare Worker
this.workerManager.createWorker('MyWorker', this, workerProps)
// Configure DNS records
this.recordManager.createRecord('MyRecord', this, recordProps)
}
}
| Package | Description |
|---|---|
@gradientedge/cdk-utils-aws |
AWS CDK constructs and service managers |
@gradientedge/cdk-utils-azure |
Azure Pulumi constructs and service managers |
@gradientedge/cdk-utils-cloudflare |
Cloudflare Pulumi constructs and service managers |
@gradientedge/cdk-utils-common |
Shared utilities, types, and stage helpers |
@gradientedge/cdk-utils |
Umbrella package that re-exports all of the above |