LayeredCraft.Cdk.Constructs
2.6.0-preview.27
See the version list below for details.
dotnet add package LayeredCraft.Cdk.Constructs --version 2.6.0-preview.27
NuGet\Install-Package LayeredCraft.Cdk.Constructs -Version 2.6.0-preview.27
<PackageReference Include="LayeredCraft.Cdk.Constructs" Version="2.6.0-preview.27" />
<PackageVersion Include="LayeredCraft.Cdk.Constructs" Version="2.6.0-preview.27" />
<PackageReference Include="LayeredCraft.Cdk.Constructs" />
paket add LayeredCraft.Cdk.Constructs --version 2.6.0-preview.27
#r "nuget: LayeredCraft.Cdk.Constructs, 2.6.0-preview.27"
#:package LayeredCraft.Cdk.Constructs@2.6.0-preview.27
#addin nuget:?package=LayeredCraft.Cdk.Constructs&version=2.6.0-preview.27&prerelease
#tool nuget:?package=LayeredCraft.Cdk.Constructs&version=2.6.0-preview.27&prerelease
LayeredCraft CDK Constructs
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.
Features
- π Lambda Functions: Comprehensive Lambda construct with configurable OpenTelemetry support, IAM management, and environment configuration
- πΈοΈ Web Functions: AWS Lambda Web Functions served from an S3 artifact, with IAM or application-managed endpoints, endpoint-scoped grants, and CloudFront OAC origin integration
- π 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
- π Cognito User Pools: Complete Cognito user pool with custom domains, resource servers, OAuth clients, and Managed Login branding
- π§ͺ Testing Helpers: Extensive testing utilities with fluent assertions and builders
- π Type Safety: Full intellisense and compile-time validation
- β‘ Performance: Optimized for cold starts with AWS Lambda SnapStart support
Installation
dotnet add package LayeredCraft.Cdk.Constructs
Quick Start
Basic Lambda Function
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)
{
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 Function URL for HTTP access
IncludeOtelLayer = true, // Enable OpenTelemetry (disabled by default in v2.0+)
Architecture = "arm64", // Optional: specify architecture (default: amd64)
EnvironmentVariables = new Dictionary<string, string>
{
{ "ENVIRONMENT", "production" },
{ "LOG_LEVEL", "info" }
}
});
}
}
Static Website
var website = new StaticSiteConstruct(this, "Website", new StaticSiteConstructProps
{
DomainName = "example.com",
SiteSubDomain = "www",
AssetPath = "./website-build"
});
DynamoDB Table
var table = new DynamoDbTableConstruct(this, "UserTable", new DynamoDbTableConstructProps
{
TableName = "users",
PartitionKey = new AttributeDefinition { AttributeName = "userId", AttributeType = AttributeType.STRING },
GlobalSecondaryIndexes = [
new GlobalSecondaryIndex
{
IndexName = "email-index",
PartitionKey = new AttributeDefinition { AttributeName = "email", AttributeType = AttributeType.STRING },
ProjectionType = ProjectionType.ALL
}
]
});
Web Function
An AWS Lambda Web Function runs an ordinary HTTP server (Next.js, ASP.NET Core, Blazor Static SSR, and so on) from a zip in a versioned S3 bucket. See the Web Function Construct reference for the full configuration surface and the Web Function Workloads page for per-framework recipes.
using Amazon.CDK;
using Amazon.CDK.AWS.S3;
using Constructs;
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)
{
// The bucket must have versioning enabled and already contain the artifact.
var artifacts = Bucket.FromBucketName(this, "artifacts", "acme-artifacts");
var web = new WebFunctionConstruct(this, "Web", new WebFunctionConstructProps
{
FunctionName = "acme-web",
Code = WebFunctionCode.FromBucket(artifacts, "1.2.3/web.zip", new WebFunctionCodeFromBucketOptions
{
BucketPolicy = WebFunctionCodeBucketPolicy.ExternallyManaged,
}),
Endpoint = new WebFunctionEndpointOptions
{
AuthType = WebFunctionAuthType.IamAuth,
},
});
}
}
Compatibility: Lambda Web Functions require
Amazon.CDK.Lib2.274.0 or later and a Region where the feature is available.IamAuthendpoints are invoked by signed (SigV4) callers;ApplicationManagedendpoints are publicly reachable, including behind CloudFront.
Documentation
- Lambda Function Construct - Full-featured Lambda functions with OpenTelemetry, IAM, and more
- Web Function Construct - Lambda Web Functions with S3 artifacts, IAM/application-managed endpoints, and CloudFront OAC
- Static Site Construct - Complete static website hosting with CloudFront and SSL
- DynamoDB Table Construct - Production-ready DynamoDB tables with streams and indexes
- Cognito User Pool Construct - Full-featured Cognito user pool with custom domains, OAuth clients, and branding
- Testing Guide - Comprehensive testing utilities and patterns
- Examples - Real-world usage examples and patterns
- Web Function Workloads - Next.js, ASP.NET Core, and Blazor Static SSR recipes
Requirements
- .NET 8.0 or .NET 9.0
- AWS CDK v2 (Amazon.CDK.Lib 2.274.0+)
- AWS CLI configured with appropriate permissions
- Node.js (for CDK deployment)
Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Development Setup
# Clone the repository
git clone https://github.com/LayeredCraft/cdk-constructs.git
cd cdk-constructs
# Restore dependencies
dotnet restore
# Build the project
dotnet build
# Run tests
dotnet run --project test/LayeredCraft.Cdk.Constructs.Tests/ --framework net8.0
Code Style
- Follow C# coding conventions
- Use meaningful names for variables and methods
- Add XML documentation for public APIs
- Include unit tests for new features
- Run tests before submitting PRs
License
This project is licensed under the MIT License.
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: https://layeredcraft.github.io/cdk-constructs/
Changelog
See CHANGELOG.md for details on releases and changes.
Built with β€οΈ by the LayeredCraft team
Contributors β¨
Thanks goes to these wonderful people (emoji key):
<table> <tbody> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/taylorbobaylor"><img src="https://avatars.githubusercontent.com/u/25238885?v=4?s=100" width="100px;" alt="Taylor Christian"/><br /><sub><b>Taylor Christian</b></sub></a><br /><a href="https://github.com/LayeredCraft/cdk-constructs/commits?author=taylorbobaylor" title="Documentation">π</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/ncipollina"><img src="https://avatars.githubusercontent.com/u/1405469?v=4?s=100" width="100px;" alt="Nick Cipollina"/><br /><sub><b>Nick Cipollina</b></sub></a><br /><a href="https://github.com/LayeredCraft/cdk-constructs/commits?author=ncipollina" title="Code">π»</a> <a href="https://github.com/LayeredCraft/cdk-constructs/commits?author=ncipollina" title="Documentation">π</a> <a href="#infra-ncipollina" title="Infrastructure (Hosting, Build-Tools, etc)">π</a></td> </tr> </tbody> </table>
This project follows the all-contributors specification. Contributions of any kind welcome!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- Amazon.CDK.Lib (>= 2.274.0)
-
net11.0
- Amazon.CDK.Lib (>= 2.274.0)
-
net8.0
- Amazon.CDK.Lib (>= 2.274.0)
-
net9.0
- Amazon.CDK.Lib (>= 2.274.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.6.1-preview.29 | 0 | 10/27/2026 |
| 2.6.0 | 0 | 10/27/2026 |
| 2.6.0-preview.28 | 0 | 10/27/2026 |
| 2.6.0-preview.27 | 52 | 10/26/2026 |
| 2.5.1-preview.26 | 54 | 10/21/2026 |
| 2.5.1-preview.25 | 59 | 10/14/2026 |
| 2.5.0 | 475 | 10/13/2026 |
| 2.5.0-preview.24 | 66 | 10/13/2026 |
| 2.4.6-preview.23 | 56 | 10/13/2026 |
| 2.4.6-preview.22 | 64 | 10/7/2026 |
| 2.4.6-preview.21 | 59 | 9/30/2026 |
| 2.4.6-preview.20 | 66 | 9/23/2026 |
| 2.4.5 | 199 | 9/23/2026 |
| 2.4.5-preview.19 | 70 | 9/23/2026 |
| 2.4.5-preview.18 | 73 | 9/16/2026 |
| 2.4.5-preview.17 | 83 | 9/9/2026 |
| 2.4.5-preview.16 | 81 | 9/2/2026 |
| 2.4.5-preview.15 | 88 | 8/26/2026 |
| 2.4.5-preview.14 | 87 | 8/19/2026 |
| 2.4.4 | 367 | 8/17/2026 |