Skip to content

Commit 48b0bc5

Browse files
author
Jon Slominski
committed
feat(cdk): add automatic Route 53 DNS record creation for custom domains
- Add Route 53 A record creation when custom domain is provided - Update Python client setup to use --reinstall flag - Remove CDK context file from version control - Clean up gitignore formatting
1 parent 0a96c57 commit 48b0bc5

File tree

4 files changed

+26
-31
lines changed

4 files changed

+26
-31
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ cdk.out
2727
.env
2828
**/.venv
2929
**/agentcore-gateway-and-runtime
30-
**/__pycache__
30+
**/__pycache__
31+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ The included Python client (`source/sample-clients/simple-auth-client-python/`)
196196

197197
```bash
198198
pip install uv
199-
uv sync
199+
uv sync --reinstall
200200
```
201201

202202
3. Set environment variables:

source/cdk/ecs-and-lambda/cdk.context.json

Lines changed: 0 additions & 28 deletions
This file was deleted.

source/cdk/ecs-and-lambda/lib/stacks/mcp-server-stack.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import * as elbv2 from "aws-cdk-lib/aws-elasticloadbalancingv2";
66
import * as ecs from "aws-cdk-lib/aws-ecs";
77
import * as acm from "aws-cdk-lib/aws-certificatemanager";
88
import * as cloudfront from "aws-cdk-lib/aws-cloudfront";
9+
import * as route53 from "aws-cdk-lib/aws-route53";
10+
import * as route53targets from "aws-cdk-lib/aws-route53-targets";
911
import * as ssm from "aws-cdk-lib/aws-ssm";
1012
import * as lambda from "aws-cdk-lib/aws-lambda";
1113
import * as origins from "aws-cdk-lib/aws-cloudfront-origins";
@@ -395,8 +397,28 @@ export class MCPServerStack extends cdk.Stack {
395397
},
396398
]);
397399

400+
// Create Route 53 records if custom domain is provided
401+
if (customDomain && certificateArn) {
402+
// Look up the hosted zone
403+
const hostedZone = route53.HostedZone.fromLookup(this, "HostedZone", {
404+
domainName: customDomain,
405+
});
406+
407+
// Create A record for the custom domain
408+
new route53.ARecord(this, "McpServerARecord", {
409+
zone: hostedZone,
410+
recordName: customDomain,
411+
target: route53.RecordTarget.fromAlias(
412+
new route53targets.CloudFrontTarget(this.distribution)
413+
),
414+
});
415+
}
416+
398417
// Set the HTTPS URL
399-
const httpsUrl = `https://${this.distribution.distributionDomainName}`;
418+
const httpsUrl =
419+
customDomain && certificateArn
420+
? `https://${customDomain}`
421+
: `https://${this.distribution.distributionDomainName}`;
400422

401423
// Output CloudFront distribution details
402424
new cdk.CfnOutput(this, "CloudFrontDistributions", {

0 commit comments

Comments
 (0)