Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ dotnet add test/LayeredCraft.Cdk.Constructs.Tests/ package PackageName
- Configures Route53 DNS records for primary domain and alternates
- Supports optional API proxying via CloudFront behaviors for `/api/*` paths
- Includes automatic asset deployment with cache invalidation
- Exposes `SiteDomain` property containing the fully qualified domain name

**DynamoDbTableConstruct** (`src/LayeredCraft.Cdk.Constructs/DynamoDbTableConstruct.cs`)
- Comprehensive CDK construct for DynamoDB table creation and configuration
Expand Down Expand Up @@ -88,7 +89,7 @@ dotnet add test/LayeredCraft.Cdk.Constructs.Tests/ package PackageName

### Target Frameworks
- .NET 8.0 and .NET 9.0
- Uses AWS CDK v2 (Amazon.CDK.Lib 2.203.1)
- Uses AWS CDK v2 (Amazon.CDK.Lib 2.213.0)

### OpenTelemetry Configuration (v2.0.0+)
Starting with version 2.0.0, the OpenTelemetry layer configuration has been updated:
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionPrefix>2.0.1</VersionPrefix>
<!-- SPDX license identifier for MIT -->
<PackageLicenseExpression>MIT</PackageLicenseExpression>

Expand Down
23 changes: 23 additions & 0 deletions docs/constructs/static-site.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,29 @@ public class MyStack : Stack
| `ApiDomain` | `string?` | `null` | API domain for proxy behavior |
| `AlternateDomains` | `string[]` | `[]` | Additional domains to include in certificate |

## Construct Properties

The `StaticSiteConstruct` exposes the following properties after instantiation:

| Property | Type | Description |
|----------|------|-------------|
| `SiteDomain` | `string` | Fully qualified domain name of the site (e.g., "www.example.com") |

### Accessing Site Domain

```csharp
var site = new StaticSiteConstruct(this, "MySite", new StaticSiteConstructProps
{
SiteBucketName = "my-website-bucket",
DomainName = "example.com",
SiteSubDomain = "www",
AssetPath = "./website-build"
});

// Access the computed site domain
var domain = site.SiteDomain; // "www.example.com"
```

## Advanced Examples

### Website with Subdomain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Amazon.CDK.Lib" Version="2.209.1" />
<PackageReference Include="Amazon.CDK.Lib" Version="2.213.0" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\docs\assets\icon.png" Pack="true" PackagePath="" Visible="False" />
Expand Down
15 changes: 10 additions & 5 deletions src/LayeredCraft.Cdk.Constructs/StaticSiteConstruct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ namespace LayeredCraft.Cdk.Constructs;
/// </summary>
public class StaticSiteConstruct : Construct
{
/// <summary>
/// Gets the fully qualified domain name of the static site (e.g., "www.example.com").
/// This property is set during construct initialization and combines the site subdomain with the domain name.
/// </summary>
public string SiteDomain { get; private set; }
/// <summary>
/// Initializes a new instance of the StaticSiteConstruct class.
/// </summary>
Expand All @@ -33,12 +38,12 @@ public StaticSiteConstruct(Construct scope, string id, IStaticSiteConstructProps
DomainName = props.DomainName
});

var siteDomain = $"{props.SiteSubDomain}.{props.DomainName}";
SiteDomain = $"{props.SiteSubDomain}.{props.DomainName}";

// Create S3 bucket for static website hosting
var siteBucket = new Bucket(this, $"{id}-bucket", new BucketProps
{
BucketName = siteDomain,
BucketName = SiteDomain,
WebsiteIndexDocument = "index.html",
WebsiteErrorDocument = "index.html",
PublicReadAccess = true,
Expand All @@ -62,15 +67,15 @@ public StaticSiteConstruct(Construct scope, string id, IStaticSiteConstructProps
// Create SSL certificate for HTTPS with DNS validation
var certificate = new Certificate(this, $"{id}-certificate", new CertificateProps
{
DomainName = siteDomain,
DomainName = SiteDomain,
Validation = CertificateValidation.FromDns(zone),
SubjectAlternativeNames = props.AlternateDomains,
});

// Create CloudFront distribution for global content delivery
var distribution = new Distribution(this, $"{id}-cdn", new DistributionProps
{
DomainNames = [siteDomain, ..props.AlternateDomains],
DomainNames = [SiteDomain, ..props.AlternateDomains],
DefaultBehavior = new BehaviorOptions
{
Origin = new S3StaticWebsiteOrigin(siteBucket, new S3StaticWebsiteOriginProps
Expand Down Expand Up @@ -112,7 +117,7 @@ public StaticSiteConstruct(Construct scope, string id, IStaticSiteConstructProps
_ = new ARecord(this, $"{id}-alias-record", new ARecordProps
{
Zone = zone,
RecordName = siteDomain,
RecordName = SiteDomain,
Target = RecordTarget.FromAlias(new CloudFrontTarget(distribution)),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
<PackageReference Include="AwesomeAssertions" Version="9.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"/>
<PackageReference Include="NSubstitute" Version="5.3.0"/>
<PackageReference Include="xunit.v3" Version="3.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.3">
<PackageReference Include="xunit.v3" Version="3.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down