|
1 | 1 | import * as cdk from "aws-cdk-lib";
|
2 | 2 | import { Construct } from "constructs";
|
3 | 3 | import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
4 |
| -import { Code, LayerVersion, Runtime } from "aws-cdk-lib/aws-lambda"; |
| 4 | +import { |
| 5 | + Code, |
| 6 | + LayerVersion, |
| 7 | + Runtime, |
| 8 | + FunctionUrl, |
| 9 | + FunctionUrlAuthType, |
| 10 | +} from "aws-cdk-lib/aws-lambda"; |
5 | 11 | import { LogGroup, RetentionDays } from "aws-cdk-lib/aws-logs";
|
6 | 12 | import { Role } from "aws-cdk-lib/aws-iam";
|
7 | 13 | import { AwsSolutionsChecks } from "cdk-nag";
|
@@ -42,7 +48,7 @@ export class CatFactsMcpServer extends cdk.Stack {
|
42 | 48 | removalPolicy: cdk.RemovalPolicy.DESTROY,
|
43 | 49 | });
|
44 | 50 |
|
45 |
| - new NodejsFunction(this, "function", { |
| 51 | + const lambdaFunction = new NodejsFunction(this, "function", { |
46 | 52 | functionName: "mcp-server-cat-facts" + stackNameSuffix,
|
47 | 53 | role: Role.fromRoleName(this, "role", "mcp-lambda-example-servers"),
|
48 | 54 | logGroup,
|
@@ -70,6 +76,17 @@ export class CatFactsMcpServer extends cdk.Stack {
|
70 | 76 | },
|
71 | 77 | },
|
72 | 78 | });
|
| 79 | + |
| 80 | + // URL with AWS IAM authorization for HTTP transport |
| 81 | + const functionUrl = new FunctionUrl(this, "FunctionUrl", { |
| 82 | + function: lambdaFunction, |
| 83 | + authType: FunctionUrlAuthType.AWS_IAM, |
| 84 | + }); |
| 85 | + |
| 86 | + new cdk.CfnOutput(this, "FunctionUrlOutput", { |
| 87 | + value: functionUrl.url, |
| 88 | + exportName: `CatFactsServerUrl${stackNameSuffix}`, |
| 89 | + }); |
73 | 90 | }
|
74 | 91 | }
|
75 | 92 |
|
|
0 commit comments