Skip to content

Commit 06bdc5a

Browse files
ncipollinaclaude
andauthored
feat: add SiteDomain property to StaticSiteConstruct and update dependencies (#31)
- Add public SiteDomain property to expose fully qualified domain name - Update AWS CDK from 2.209.1 to 2.213.0 - Update xUnit dependencies (v3.0.0 -> v3.0.1, runner v3.1.3 -> v3.1.4) - Version bump to 2.0.1 - Add comprehensive XML documentation for new property - Update CLAUDE.md and static-site.md documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 320d85b commit 06bdc5a

File tree

6 files changed

+39
-10
lines changed

6 files changed

+39
-10
lines changed

CLAUDE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ dotnet add test/LayeredCraft.Cdk.Constructs.Tests/ package PackageName
5858
- Configures Route53 DNS records for primary domain and alternates
5959
- Supports optional API proxying via CloudFront behaviors for `/api/*` paths
6060
- Includes automatic asset deployment with cache invalidation
61+
- Exposes `SiteDomain` property containing the fully qualified domain name
6162

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

8990
### Target Frameworks
9091
- .NET 8.0 and .NET 9.0
91-
- Uses AWS CDK v2 (Amazon.CDK.Lib 2.203.1)
92+
- Uses AWS CDK v2 (Amazon.CDK.Lib 2.213.0)
9293

9394
### OpenTelemetry Configuration (v2.0.0+)
9495
Starting with version 2.0.0, the OpenTelemetry layer configuration has been updated:

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<VersionPrefix>2.0.0</VersionPrefix>
3+
<VersionPrefix>2.0.1</VersionPrefix>
44
<!-- SPDX license identifier for MIT -->
55
<PackageLicenseExpression>MIT</PackageLicenseExpression>
66

docs/constructs/static-site.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,29 @@ public class MyStack : Stack
5151
| `ApiDomain` | `string?` | `null` | API domain for proxy behavior |
5252
| `AlternateDomains` | `string[]` | `[]` | Additional domains to include in certificate |
5353

54+
## Construct Properties
55+
56+
The `StaticSiteConstruct` exposes the following properties after instantiation:
57+
58+
| Property | Type | Description |
59+
|----------|------|-------------|
60+
| `SiteDomain` | `string` | Fully qualified domain name of the site (e.g., "www.example.com") |
61+
62+
### Accessing Site Domain
63+
64+
```csharp
65+
var site = new StaticSiteConstruct(this, "MySite", new StaticSiteConstructProps
66+
{
67+
SiteBucketName = "my-website-bucket",
68+
DomainName = "example.com",
69+
SiteSubDomain = "www",
70+
AssetPath = "./website-build"
71+
});
72+
73+
// Access the computed site domain
74+
var domain = site.SiteDomain; // "www.example.com"
75+
```
76+
5477
## Advanced Examples
5578

5679
### Website with Subdomain

src/LayeredCraft.Cdk.Constructs/LayeredCraft.Cdk.Constructs.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</PropertyGroup>
1616

1717
<ItemGroup>
18-
<PackageReference Include="Amazon.CDK.Lib" Version="2.209.1" />
18+
<PackageReference Include="Amazon.CDK.Lib" Version="2.213.0" />
1919
</ItemGroup>
2020
<ItemGroup>
2121
<None Include="..\..\docs\assets\icon.png" Pack="true" PackagePath="" Visible="False" />

src/LayeredCraft.Cdk.Constructs/StaticSiteConstruct.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ namespace LayeredCraft.Cdk.Constructs;
1919
/// </summary>
2020
public class StaticSiteConstruct : Construct
2121
{
22+
/// <summary>
23+
/// Gets the fully qualified domain name of the static site (e.g., "www.example.com").
24+
/// This property is set during construct initialization and combines the site subdomain with the domain name.
25+
/// </summary>
26+
public string SiteDomain { get; private set; }
2227
/// <summary>
2328
/// Initializes a new instance of the StaticSiteConstruct class.
2429
/// </summary>
@@ -33,12 +38,12 @@ public StaticSiteConstruct(Construct scope, string id, IStaticSiteConstructProps
3338
DomainName = props.DomainName
3439
});
3540

36-
var siteDomain = $"{props.SiteSubDomain}.{props.DomainName}";
41+
SiteDomain = $"{props.SiteSubDomain}.{props.DomainName}";
3742

3843
// Create S3 bucket for static website hosting
3944
var siteBucket = new Bucket(this, $"{id}-bucket", new BucketProps
4045
{
41-
BucketName = siteDomain,
46+
BucketName = SiteDomain,
4247
WebsiteIndexDocument = "index.html",
4348
WebsiteErrorDocument = "index.html",
4449
PublicReadAccess = true,
@@ -62,15 +67,15 @@ public StaticSiteConstruct(Construct scope, string id, IStaticSiteConstructProps
6267
// Create SSL certificate for HTTPS with DNS validation
6368
var certificate = new Certificate(this, $"{id}-certificate", new CertificateProps
6469
{
65-
DomainName = siteDomain,
70+
DomainName = SiteDomain,
6671
Validation = CertificateValidation.FromDns(zone),
6772
SubjectAlternativeNames = props.AlternateDomains,
6873
});
6974

7075
// Create CloudFront distribution for global content delivery
7176
var distribution = new Distribution(this, $"{id}-cdn", new DistributionProps
7277
{
73-
DomainNames = [siteDomain, ..props.AlternateDomains],
78+
DomainNames = [SiteDomain, ..props.AlternateDomains],
7479
DefaultBehavior = new BehaviorOptions
7580
{
7681
Origin = new S3StaticWebsiteOrigin(siteBucket, new S3StaticWebsiteOriginProps
@@ -112,7 +117,7 @@ public StaticSiteConstruct(Construct scope, string id, IStaticSiteConstructProps
112117
_ = new ARecord(this, $"{id}-alias-record", new ARecordProps
113118
{
114119
Zone = zone,
115-
RecordName = siteDomain,
120+
RecordName = SiteDomain,
116121
Target = RecordTarget.FromAlias(new CloudFrontTarget(distribution)),
117122
});
118123

test/LayeredCraft.Cdk.Constructs.Tests/LayeredCraft.Cdk.Constructs.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
<PackageReference Include="AwesomeAssertions" Version="9.1.0" />
3737
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"/>
3838
<PackageReference Include="NSubstitute" Version="5.3.0"/>
39-
<PackageReference Include="xunit.v3" Version="3.0.0" />
40-
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.3">
39+
<PackageReference Include="xunit.v3" Version="3.0.1" />
40+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4">
4141
<PrivateAssets>all</PrivateAssets>
4242
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4343
</PackageReference>

0 commit comments

Comments
 (0)