AWS CDK vs. Nitric

Nitric and AWS Cloud Development Kit (CDK) both provide developer-friendly approaches to cloud resource management, but they operate on different philosophies. Nitric uses an "Infrastructure from Code" approach, focusing on deriving the necessary infrastructure from the application code. This stands in contrast to AWS CDK's "Infrastructure as Code" methodology, which requires explicit definition of cloud resources. These are the main differences between the two:

  1. Cloud Provider Support: Nitric is provider-agnostic, capable of deploying to multiple cloud providers such as AWS, Google Cloud, and Azure. AWS CDK is primarily designed for AWS services.
  2. Abstraction Level: Nitric provides a high level of abstraction, allowing developers to focus more on writing application code. AWS CDK, while also abstracting over raw CloudFormation, requires a more detailed understanding of AWS services and their interactions.
  3. Infrastructure Provisioning: Nitric uses Pulumi by default for provisioning cloud resources, but also allows the use of custom providers. AWS CDK uses AWS CloudFormation for provisioning.
  4. Local Simulation: Nitric provides a local cloud simulation tool, allowing you to test your applications locally before deploying them. This is a feature that AWS CDK does not offer, you are required to deploy your application to the cloud.

Code Comparison

To get a deeper understanding of the differences, let's see the same app built in both Nitric and AWS CDK. This simple cloud app uses a Function to retrieve a hello world message using a path parameter.


import { api } from '@nitric/sdk'

const helloApi = api('main')

helloApi.get('/hello/:name', async (ctx) => {
  const { name } = ctx.req.params

  ctx.res.body = `Hello ${name}`


exports.handler = async function (event = {}) {
  const name =

  return {
    statusCode: 200,
    body: `Hello ${name}`,


import * as cdk from 'aws-cdk-lib'
import { Construct } from 'constructs'
import * as apigateway from 'aws-cdk-lib/aws-apigateway'
import * as lambda from 'aws-cdk-lib/aws-lambda'

export class HelloWorldStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props)

    const handler = new lambda.Function(this, 'HelloworldHandler', {
      runtime: lambda.Runtime.NODEJS_18_X,
      code: lambda.Code.fromAsset('src'),
      handler: 'index.handler',

    const api = new apigateway.RestApi(this, 'hello-world-api', {
      restApiName: 'Hello World Service',
      description: 'A hello world API.',

    const resource = api.root.addResource('hello').addResource('{name}')

    resource.addMethod('GET', new apigateway.LambdaIntegration(handler))

Nitric offers a simplified, user-friendly way to define APIs with the added benefit of being able to use custom providers for greater control and flexibility, while maintaining cloud neutrality. On the other hand, AWS CDK, with its verbose and explicit syntax, provides deep customization and control specifically within the AWS ecosystem, but might be more complex for beginners.


LanguageYour choiceYour choice
Lines of code933
Cloud InfrastructureInferredExplicit
ExtensibilityCustom providers can be createdCustom Constructs / Resource Providers
Local simulationBuilt-in local simulator with instant hot reloadingNo
Cloud providersAWS, Azure, GCP and Custom providersAWS
Provisioning enginePulumi by default, other custom providers can be createdCloudFormation (CDKTF is used for Terraform, but you cannot compile the same code to different engines)