Skip to content

Home

Build Status NuGet Downloads

A comprehensive library of reusable AWS CDK constructs for .NET projects, designed for serverless applications and static websites. Built with best practices, observability, and cost efficiency in mind.

Key Features

  • ๐Ÿš€ Lambda Functions: Comprehensive Lambda construct with OpenTelemetry support, IAM management, and environment configuration
  • ๐ŸŒ Static Sites: Complete static website hosting with S3, CloudFront, SSL certificates, and Route53 DNS management
  • ๐Ÿ“Š DynamoDB Tables: Full-featured DynamoDB construct with streams, TTL, and global secondary indexes
  • ๐Ÿงช Testing Helpers: Extensive testing utilities with fluent assertions and builders
  • ๐Ÿ“ Type Safety: Full TypeScript-style intellisense and compile-time validation
  • โšก Performance: Optimized for cold starts with AWS Lambda SnapStart support

Installation

dotnet add package LayeredCraft.Cdk.Constructs

Quick Start

using Amazon.CDK;
using LayeredCraft.Cdk.Constructs;
using LayeredCraft.Cdk.Constructs.Models;

public class MyStack : Stack
{
    public MyStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
    {
        // Create a Lambda function
        var lambda = new LambdaFunctionConstruct(this, "MyLambda", new LambdaFunctionConstructProps
        {
            FunctionName = "my-api",
            FunctionSuffix = "prod",
            AssetPath = "./lambda-deployment.zip",
            RoleName = "my-api-role",
            PolicyName = "my-api-policy",
            GenerateUrl = true // Creates a Function URL for HTTP access
        });

        // Create a static website
        var site = new StaticSiteConstruct(this, "MySite", new StaticSiteConstructProps
        {
            SiteBucketName = "my-website-bucket",
            DomainName = "example.com",
            AssetPath = "./website-build"
        });
    }
}

Available Constructs

Lambda Function Construct

Full-featured Lambda functions with:

  • OpenTelemetry integration
  • IAM roles and policies
  • Environment variables
  • Function URLs
  • SnapStart support
  • Versioning and aliases

Static Site Construct

Complete static website hosting with:

  • S3 website hosting
  • CloudFront CDN
  • SSL certificates
  • Route53 DNS
  • API proxy support

DynamoDB Table Construct

Production-ready DynamoDB tables with:

  • Global secondary indexes
  • DynamoDB streams
  • TTL configuration
  • Lambda stream integration

Documentation

  • Testing Guide - Comprehensive testing utilities and patterns
  • Examples - Real-world usage examples and patterns

Requirements

  • .NET 8.0 or .NET 9.0
  • AWS CDK v2 (Amazon.CDK.Lib 2.203.1+)
  • AWS CLI configured with appropriate permissions
  • Node.js (for CDK deployment)

Contributing

See the main README for contribution guidelines.

License

This project is licensed under the MIT License.