diff --git a/cli/magic-config.ts b/cli/magic-config.ts index b3a30dbd3..4abcfdbe4 100644 --- a/cli/magic-config.ts +++ b/cli/magic-config.ts @@ -831,7 +831,8 @@ async function processCreateOptions(options: any): Promise { { type: "confirm", name: "advancedMonitoring", - message: "Do you want to enable custom metrics and advanced monitoring?", + message: + "Do you want to use Amazon CloudWatch custom metrics, alarms and AWS X-Ray?", initial: options.advancedMonitoring || false, }, { diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index c36796d4a..bbd650b53 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -51,8 +51,8 @@ export default defineConfig({ { text: 'Documentation', items: [ - { text: 'Custom Public Domain', link: '/documentation/custom-public-domain' }, - { text: 'Private Chatbot', link: '/documentation/private-chatbot' }, + { text: 'AppSync', link: '/documentation/appsync' }, + { text: 'CloudFront Geo Restriction', link: '/documentation/cf-geo-restriction' }, { text: 'Cognito Federation', items: [ { text: 'Cognito Overview', link: '/documentation/cognito/overview' }, @@ -60,15 +60,15 @@ export default defineConfig({ { text: 'Keycloak OIDC example', link: '/documentation/cognito/keycloak-oidc' }, ] }, - { text: 'Model Requirements', link: '/documentation/model-requirements' }, - { text: 'Self-hosted models', link: '/documentation/self-hosted-models' }, - { text: 'Inference Script', link: '/documentation/inference-script' }, + { text: 'Custom Public Domain', link: '/documentation/custom-public-domain' }, { text: 'Document Retrieval', link: '/documentation/retriever' }, - { text: 'AppSync', link: '/documentation/appsync' }, + { text: 'Inference Script', link: '/documentation/inference-script' }, + { text: 'Model Requirements', link: '/documentation/model-requirements' }, + { text: 'Precautions', link: '/documentation/precautions' }, + { text: 'Private Chatbot', link: '/documentation/private-chatbot' }, { text: 'SageMaker Schedule', link: '/documentation/sagemaker-schedule' }, - { text: 'CloudFront Geo Restriction', link: '/documentation/cf-geo-restriction' }, { text: 'Security', link: '/documentation/vulnerability-scanning' }, - { text: 'Precautions', link: '/documentation/precautions' } + { text: 'Self-hosted models', link: '/documentation/self-hosted-models' }, ] } ], diff --git a/docs/documentation/monitoring.md b/docs/documentation/monitoring.md new file mode 100644 index 000000000..2bb835dfc --- /dev/null +++ b/docs/documentation/monitoring.md @@ -0,0 +1,27 @@ +# Monitoring +By default, the project will create a [Amazon CloudWatch Dashboard](https://console.aws.amazon.com/cloudwatch). This Dashboard is created using the library [cdk-monitoring-constructs](https://github.com/cdklabs/cdk-monitoring-constructs) and it is recommended to update the metrics you tracks based on your project needs. + +The dashboard is created in `lib/monitoring/index.ts` + +During the configuration set, the advanced settings allows you to enable advance monitoring which will do the following: +* [Enable AWS X-Ray](https://docs.aws.amazon.com/xray/latest/devguide/aws-xray.html) which will collect traces availbale by opening the [Trace Map](https://docs.aws.amazon.com/xray/latest/devguide/xray-console-servicemap.html) from the CloudWatch console. +* Generate a custom metric per LLM model used using Amazon Bedrock allowing you to track token usage. This metrics are available in the dashboard. These metrics are created using [Cloudwatch filters](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/MonitoringLogData.html). +* Create sample CloudWatch Alarms. + +***Cost***: Be mindful of the costs associated with AWS resources, enabling advance motoring is [adding custom metrics, alarms](https://aws.amazon.com/cloudwatch/pricing/) and [AWS X-Ray traces](https://aws.amazon.com/xray/pricing/). + +## Recommended changes (Advanced monitoring) + +### Recevie alerts +The default setup is monitoring key resources such as the error rates of the APIs or the dead letter queues (if not empty, the processing of LLM requests failed). All these alarms can be viewed from the Amazon CloudWatch console. + +The alarms state is monitoring by a [composite alarm](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Create_Composite_Alarm.html) which will send an event to an SNS Topic if any alarm is active. + +To receive notifications, add a [subscription](https://docs.aws.amazon.com/sns/latest/dg/sns-create-subscribe-endpoint-to-topic.html) (manually or in `lib/monitoring/index.ts`) to the topic listed in the Cloudformation output `CompositeAlarmTopicOutput`. + +### Update alarms and their thresholds +The alarms listed in `lib/monitoring/index.ts` are example and they should be updated to match your project needs. Please refer to the following [project describing](https://github.com/cdklabs/cdk-monitoring-constructs) how to add/update the alarms. + +### Review AWS X-Ray sampling +Consider updating the default [AWS X-Ray sampling rules](https://docs.aws.amazon.com/xray/latest/devguide/xray-console-sampling.html) to define the amount of data recorded + diff --git a/docs/guide/deploy.md b/docs/guide/deploy.md index 3c3e118b0..ee83b4e98 100644 --- a/docs/guide/deploy.md +++ b/docs/guide/deploy.md @@ -83,6 +83,8 @@ You have: ## Deployment +Before you start, please read the [precautions](../documentation/precautions.md) and [security](../documentation/vulnerability-scanning.md) pages. + **Step 1.** Clone the repository. ```bash @@ -178,7 +180,9 @@ REACT_APP_URL=https://dxxxxxxxxxxxxx.cloudfront.net pytest integtests/user_inter ## Monitoring -Once the deployment is complete, a [CloudWatch Dashboard](https://console.aws.amazon.com/cloudwatch) will be available in the selected region to monitor the usage of the resources. +Once the deployment is complete, a [Amazon CloudWatch Dashboard](https://console.aws.amazon.com/cloudwatch) will be available in the selected region to monitor the usage of the resources. + +For more information, please refer to [the monitoring page](../documentation/monitoring.md) ## Run user interface locally diff --git a/integtests/chatbot-api/embedding_test.py b/integtests/chatbot-api/embedding_test.py index 87941ad11..7c0501518 100644 --- a/integtests/chatbot-api/embedding_test.py +++ b/integtests/chatbot-api/embedding_test.py @@ -13,4 +13,3 @@ def test_calculate(client: AppSyncClient, default_embed_model, default_provider) assert len(result) == 1 assert len(result[0].get("vector")) == 1536 - assert result[0].get("vector")[0] == 0.03729608149230709 diff --git a/lib/aws-genai-llm-chatbot-stack.ts b/lib/aws-genai-llm-chatbot-stack.ts index 12691fdeb..34ad9d5eb 100644 --- a/lib/aws-genai-llm-chatbot-stack.ts +++ b/lib/aws-genai-llm-chatbot-stack.ts @@ -220,7 +220,7 @@ export class AwsGenAILLMChatbotStack extends cdk.Stack { } const monitoringStack = new cdk.NestedStack(this, "MonitoringStack"); - new Monitoring(monitoringStack, "Monitoring", { + const monitoringConstruct = new Monitoring(monitoringStack, "Monitoring", { prefix: props.config.prefix, advancedMonitoring: props.config.advancedMonitoring === true, appsycnApi: chatBotApi.graphqlApi, @@ -243,6 +243,7 @@ export class AwsGenAILLMChatbotStack extends cdk.Stack { "/aws/lambda/" + (r as lambda.Function).functionName ); }), + cloudFrontDistribution: userInterface.cloudFrontDistribution, cognito: { userPoolId: authentication.userPool.userPoolId, clientId: authentication.userPoolClient.userPoolClientId, @@ -265,11 +266,20 @@ export class AwsGenAILLMChatbotStack extends cdk.Stack { ragFunctionProcessing: [ ...(ragEngines ? [ragEngines.dataImport.rssIngestorFunction] : []), ], - ragStateMachineProcessing: [ + ragImportStateMachineProcessing: [ ...(ragEngines ? [ ragEngines.dataImport.fileImportWorkflow, ragEngines.dataImport.websiteCrawlingWorkflow, + ] + : []), + ], + ragEngineStateMachineProcessing: [ + ...(ragEngines + ? [ + ragEngines.auroraPgVector?.createAuroraWorkspaceWorkflow, + ragEngines.openSearchVector?.createOpenSearchWorkspaceWorkflow, + ragEngines.kendraRetrieval?.createKendraWorkspaceWorkflow, ragEngines.deleteDocumentWorkflow, ragEngines.deleteWorkspaceWorkflow, ] @@ -277,6 +287,13 @@ export class AwsGenAILLMChatbotStack extends cdk.Stack { ], }); + if (monitoringConstruct.compositeAlarmTopic) { + new cdk.CfnOutput(this, "CompositeAlarmTopicOutput", { + key: "CompositeAlarmTopicOutput", + value: monitoringConstruct.compositeAlarmTopic.topicName, + }); + } + /** * CDK NAG suppression */ @@ -306,6 +323,7 @@ export class AwsGenAILLMChatbotStack extends cdk.Stack { `/${this.stackName}/ChatBotApi/RestApi/GraphQLApiHandler/ServiceRole/Resource`, `/${this.stackName}/ChatBotApi/RestApi/GraphQLApiHandler/ServiceRole/DefaultPolicy/Resource`, `/${this.stackName}/ChatBotApi/Realtime/Resolvers/lambda-resolver/ServiceRole/Resource`, + `/${this.stackName}/ChatBotApi/Realtime/Resolvers/lambda-resolver/ServiceRole/DefaultPolicy/Resource`, `/${this.stackName}/ChatBotApi/Realtime/Resolvers/outgoing-message-handler/ServiceRole/Resource`, `/${this.stackName}/ChatBotApi/Realtime/Resolvers/outgoing-message-handler/ServiceRole/DefaultPolicy/Resource`, `/${this.stackName}/IdeficsInterface/MultiModalInterfaceRequestHandler/ServiceRole/DefaultPolicy/Resource`, diff --git a/lib/chatbot-api/appsync-ws.ts b/lib/chatbot-api/appsync-ws.ts index a41d9d8f0..1183a5503 100644 --- a/lib/chatbot-api/appsync-ws.ts +++ b/lib/chatbot-api/appsync-ws.ts @@ -5,6 +5,7 @@ import { Function as LambdaFunction, LayerVersion, LoggingFormat, + Tracing, Runtime, } from "aws-cdk-lib/aws-lambda"; import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources"; @@ -23,6 +24,7 @@ interface RealtimeResolversProps { readonly shared: Shared; readonly api: appsync.GraphqlApi; readonly logRetention?: number; + readonly advancedMonitoring?: boolean; } export class RealtimeResolvers extends Construct { @@ -47,7 +49,9 @@ export class RealtimeResolvers extends Construct { handler: "index.handler", description: "Appsync resolver handling LLM Queries", runtime: Runtime.PYTHON_3_11, + tracing: props.advancedMonitoring ? Tracing.ACTIVE : Tracing.DISABLED, environment: { + ...props.shared.defaultEnvironmentVariables, SNS_TOPIC_ARN: props.topic.topicArn, }, logRetention: props.logRetention, @@ -64,11 +68,18 @@ export class RealtimeResolvers extends Construct { __dirname, "functions/outgoing-message-appsync/index.ts" ), + bundling: { + externalModules: ["aws-xray-sdk-core", "@aws-sdk"], + }, layers: [powertoolsLayerJS], handler: "index.handler", + description: "Sends LLM Responses to Appsync", runtime: Runtime.NODEJS_18_X, loggingFormat: LoggingFormat.JSON, + tracing: props.advancedMonitoring ? Tracing.ACTIVE : Tracing.DISABLED, + logRetention: props.logRetention, environment: { + ...props.shared.defaultEnvironmentVariables, GRAPHQL_ENDPOINT: props.api.graphqlUrl, }, vpc: props.shared.vpc, diff --git a/lib/chatbot-api/functions/outgoing-message-appsync/index.ts b/lib/chatbot-api/functions/outgoing-message-appsync/index.ts index 30f732d10..c51d9d2e8 100644 --- a/lib/chatbot-api/functions/outgoing-message-appsync/index.ts +++ b/lib/chatbot-api/functions/outgoing-message-appsync/index.ts @@ -11,11 +11,16 @@ import type { SQSBatchResponse, } from "aws-lambda"; import { graphQlQuery } from "./graphql"; +import * as AWSXRay from "aws-xray-sdk-core"; + +// Configure the context missing strategy to do nothing +AWSXRay.setContextMissingStrategy(() => {}); const processor = new BatchProcessor(EventType.SQS); const logger = new Logger(); const recordHandler = async (record: SQSRecord): Promise => { + const segment = AWSXRay.getSegment(); //returns the facade segment const payload = record.body; if (payload) { const item = JSON.parse(payload); @@ -44,7 +49,11 @@ const recordHandler = async (record: SQSRecord): Promise => { } `; //logger.info(query); + const subsegment = segment?.addNewSubsegment("AppSync - Publish Response"); + subsegment?.addMetadata("sessionId", req.data.sessionId); await graphQlQuery(query); + subsegment?.close(); + //logger.info(resp); } }; diff --git a/lib/chatbot-api/functions/resolvers/send-query-lambda-resolver/requirements.txt b/lib/chatbot-api/functions/resolvers/send-query-lambda-resolver/requirements.txt index ac3c8104c..f66948ea5 100644 --- a/lib/chatbot-api/functions/resolvers/send-query-lambda-resolver/requirements.txt +++ b/lib/chatbot-api/functions/resolvers/send-query-lambda-resolver/requirements.txt @@ -1 +1,2 @@ pydantic==2.4.0 +aws_xray_sdk==2.14.0 \ No newline at end of file diff --git a/lib/chatbot-api/index.ts b/lib/chatbot-api/index.ts index 5e890906c..32dc4d647 100644 --- a/lib/chatbot-api/index.ts +++ b/lib/chatbot-api/index.ts @@ -79,11 +79,11 @@ export class ChatBotApi extends Construct { ], }, logConfig: { - fieldLogLevel: appsync.FieldLogLevel.ALL, - retention: RetentionDays.ONE_WEEK, + fieldLogLevel: appsync.FieldLogLevel.INFO, + retention: props.config.logRetention ?? RetentionDays.ONE_WEEK, role: loggingRole, }, - xrayEnabled: true, + xrayEnabled: props.config.advancedMonitoring === true, visibility: props.config.privateWebsite ? appsync.Visibility.PRIVATE : appsync.Visibility.GLOBAL, @@ -104,6 +104,7 @@ export class ChatBotApi extends Construct { ...props, api, logRetention: props.config.logRetention, + advancedMonitoring: props.config.advancedMonitoring, }); this.resolvers.push(realtimeBackend.resolvers.sendQueryHandler); diff --git a/lib/chatbot-api/rest-api.ts b/lib/chatbot-api/rest-api.ts index 901212b56..1d257d545 100644 --- a/lib/chatbot-api/rest-api.ts +++ b/lib/chatbot-api/rest-api.ts @@ -52,7 +52,9 @@ export class ApiResolvers extends Construct { architecture: props.shared.lambdaArchitecture, timeout: cdk.Duration.minutes(10), memorySize: 512, - tracing: lambda.Tracing.ACTIVE, + tracing: props.config.advancedMonitoring + ? lambda.Tracing.ACTIVE + : lambda.Tracing.DISABLED, logRetention: props.config.logRetention ?? logs.RetentionDays.ONE_WEEK, loggingFormat: lambda.LoggingFormat.JSON, layers: [props.shared.powerToolsLayer, props.shared.commonLayer], diff --git a/lib/chatbot-api/websocket-api.ts b/lib/chatbot-api/websocket-api.ts index bbd1809c4..0e000d100 100644 --- a/lib/chatbot-api/websocket-api.ts +++ b/lib/chatbot-api/websocket-api.ts @@ -4,6 +4,7 @@ import * as iam from "aws-cdk-lib/aws-iam"; import * as sns from "aws-cdk-lib/aws-sns"; import * as subscriptions from "aws-cdk-lib/aws-sns-subscriptions"; import * as sqs from "aws-cdk-lib/aws-sqs"; +import * as xray from "aws-cdk-lib/aws-xray"; import { Construct } from "constructs"; import { Shared } from "../shared"; @@ -18,6 +19,7 @@ interface RealtimeGraphqlApiBackendProps { readonly userPool: UserPool; readonly api: appsync.GraphqlApi; readonly logRetention?: number; + readonly advancedMonitoring?: boolean; } export class RealtimeGraphqlApiBackend extends Construct { @@ -32,7 +34,43 @@ export class RealtimeGraphqlApiBackend extends Construct { ) { super(scope, id); // Create the main Message Topic acting as a message bus - const messagesTopic = new sns.Topic(this, "MessagesTopic"); + const messagesTopic = new sns.Topic(this, "MessagesTopic", { + tracingConfig: props.advancedMonitoring + ? sns.TracingConfig.ACTIVE + : sns.TracingConfig.PASS_THROUGH, + }); + + if (props.advancedMonitoring) { + // https://docs.aws.amazon.com/xray/latest/devguide/xray-services-sns.html#xray-services-sns-configuration + const stack = cdk.Stack.of(scope); + new xray.CfnResourcePolicy(this, "SNSResourcePolicy", { + policyName: "SNSResourcePolicy", + policyDocument: JSON.stringify( + new iam.PolicyDocument({ + statements: [ + new iam.PolicyStatement({ + effect: iam.Effect.ALLOW, + principals: [new iam.ServicePrincipal("sns.amazonaws.com")], + actions: [ + "xray:PutTraceSegments", + "xray:GetSamplingRules", + "xray:GetSamplingTargets", + ], + resources: ["*"], + conditions: { + StringEquals: { + "aws:SourceAccount": stack.account, + }, + StringLike: { + "aws:SourceArn": `arn:${stack.partition}:sns:${stack.region}:${stack.account}:*`, + }, + }, + }), + ], + }) + ), + }); + } const deadLetterQueue = new sqs.Queue(this, "OutgoingMessagesDLQ", { enforceSSL: true, @@ -66,6 +104,7 @@ export class RealtimeGraphqlApiBackend extends Construct { shared: props.shared, api: props.api, logRetention: props.logRetention, + advancedMonitoring: props.advancedMonitoring, }); // Route all outgoing messages to the websocket interface queue diff --git a/lib/model-interfaces/idefics/index.ts b/lib/model-interfaces/idefics/index.ts index 5714f58e2..d34e995e0 100644 --- a/lib/model-interfaces/idefics/index.ts +++ b/lib/model-interfaces/idefics/index.ts @@ -58,7 +58,9 @@ export class IdeficsInterface extends Construct { handler: "index.handler", layers: [props.shared.powerToolsLayer, props.shared.commonLayer], architecture: props.shared.lambdaArchitecture, - tracing: lambda.Tracing.ACTIVE, + tracing: props.config.advancedMonitoring + ? lambda.Tracing.ACTIVE + : lambda.Tracing.DISABLED, timeout: cdk.Duration.minutes(lambdaDurationInMinutes), memorySize: 1024, logRetention: props.config.logRetention ?? logs.RetentionDays.ONE_WEEK, diff --git a/lib/model-interfaces/langchain/index.ts b/lib/model-interfaces/langchain/index.ts index 9c08f3855..ce8e2d420 100644 --- a/lib/model-interfaces/langchain/index.ts +++ b/lib/model-interfaces/langchain/index.ts @@ -38,7 +38,9 @@ export class LangChainInterface extends Construct { description: "Langchain request handler", runtime: props.shared.pythonRuntime, architecture: props.shared.lambdaArchitecture, - tracing: lambda.Tracing.ACTIVE, + tracing: props.config.advancedMonitoring + ? lambda.Tracing.ACTIVE + : lambda.Tracing.DISABLED, timeout: cdk.Duration.minutes(15), memorySize: 1024, logRetention: props.config.logRetention ?? logs.RetentionDays.ONE_WEEK, diff --git a/lib/monitoring/index.ts b/lib/monitoring/index.ts index bf957bb6b..7bfdf78b9 100644 --- a/lib/monitoring/index.ts +++ b/lib/monitoring/index.ts @@ -1,4 +1,4 @@ -import { Stack } from "aws-cdk-lib"; +import { Duration, Stack } from "aws-cdk-lib"; import { IGraphqlApi } from "aws-cdk-lib/aws-appsync"; import { LogQueryWidget, @@ -14,12 +14,16 @@ import { AxisPosition, MonitoringFacade, SingleWidgetDashboardSegment, + SnsAlarmActionStrategy, } from "cdk-monitoring-constructs"; import { Construct } from "constructs"; import { CfnIndex } from "aws-cdk-lib/aws-kendra"; import { IDatabaseCluster } from "aws-cdk-lib/aws-rds"; import { Queue } from "aws-cdk-lib/aws-sqs"; import { FilterPattern, ILogGroup, MetricFilter } from "aws-cdk-lib/aws-logs"; +import { IDistribution } from "aws-cdk-lib/aws-cloudfront"; +import { ITopic, Topic } from "aws-cdk-lib/aws-sns"; +import { NagSuppressions } from "cdk-nag"; export interface MonitoringProps { prefix: string; @@ -32,13 +36,17 @@ export interface MonitoringProps { buckets: Bucket[]; sqs: Queue[]; ragFunctionProcessing: ILambdaFunction[]; - ragStateMachineProcessing: IStateMachine[]; + ragImportStateMachineProcessing: IStateMachine[]; + ragEngineStateMachineProcessing: (IStateMachine | undefined)[]; aurora?: IDatabaseCluster; opensearch?: CfnCollection; kendra?: CfnIndex; + cloudFrontDistribution?: IDistribution; } export class Monitoring extends Construct { + public readonly compositeAlarmTopic?: ITopic; + constructor( private scope: Construct, id: string, @@ -49,7 +57,11 @@ export class Monitoring extends Construct { const monitoring = new MonitoringFacade( this, props.prefix + "GenAI-Chatbot-Dashboard", - {} + { + metricFactoryDefaults: { + period: Duration.minutes(5), + }, + } ); const region = Stack.of(scope).region; @@ -57,6 +69,21 @@ export class Monitoring extends Construct { monitoring.addLargeHeader("APIs").monitorAppSyncApi({ api: props.appsycnApi, alarmFriendlyName: "AppSync", + ...(props.advancedMonitoring + ? { + add5XXFaultCountAlarm: { + Critical: { + // 5 error during the default period + maxErrorCount: 5, + }, + }, + addLatencyP90Alarm: { + Critical: { + maxLatency: Duration.seconds(3), + }, + }, + } + : {}), }); monitoring.addSegment( @@ -93,6 +120,23 @@ export class Monitoring extends Construct { props.cognito.clientId, title ); + + if (props.cloudFrontDistribution) { + monitoring.addLargeHeader("Front End").monitorCloudFrontDistribution({ + distribution: props.cloudFrontDistribution, + alarmFriendlyName: "CloudFront", + ...(props.advancedMonitoring + ? { + addFault5xxRate: { + Critical: { + maxErrorRate: 0.1, + }, + }, + } + : {}), + }); + } + monitoring.addLargeHeader("Storage"); for (const table of props.tables) { @@ -141,22 +185,98 @@ export class Monitoring extends Construct { deadLetterQueue: queue.deadLetterQueue.queue, alarmFriendlyName: queue.node.id, humanReadableName: queue.node.id, + ...(props.advancedMonitoring + ? { + addDeadLetterQueueMaxSizeAlarm: { + Critical: { + // If 5 messages are in the dead letter queue + // if means 5 requests where not processed after retries. + maxMessageCount: 5, + }, + }, + } + : {}), }); } - monitoring.addLargeHeader("RAG Processing"); - for (const fct of props.ragStateMachineProcessing) { + monitoring.addLargeHeader("RAG processing (File or website import)"); + for (const fct of props.ragImportStateMachineProcessing) { monitoring.monitorStepFunction({ stateMachine: fct, humanReadableName: fct.node.id, alarmFriendlyName: fct.node.id, + ...(props.advancedMonitoring + ? { + addFailedExecutionRateAlarm: { + Critical: { + // If 10% of the imports are failing + maxErrorRate: 0.1, + }, + }, + } + : {}), }); } + monitoring.addLargeHeader( + "RAG engines management (Create table/index and cleanup)" + ); + for (const fct of props.ragEngineStateMachineProcessing) { + if (fct) { + monitoring.monitorStepFunction({ + stateMachine: fct, + humanReadableName: fct.node.id, + alarmFriendlyName: fct.node.id, + ...(props.advancedMonitoring + ? { + addFailedExecutionCountAlarm: { + Critical: { + // If any process fail, cause an alarm (create an OpenSearch index for example) + maxErrorCount: 0, + datapointsToAlarm: 1, + }, + }, + } + : {}), + }); + } + } for (const fct of props.ragFunctionProcessing) { monitoring.monitorLambdaFunction({ lambdaFunction: fct, humanReadableName: fct.node.id, alarmFriendlyName: fct.node.id, + ...(props.advancedMonitoring + ? { + addFaultRateAlarm: { + Critical: { + // If 10% of the imports are failing + maxErrorRate: 0.1, + }, + }, + } + : {}), + }); + } + + if (props.advancedMonitoring) { + const onAlarmTopic = new Topic(this, "CompositeAlarmTopic", { + displayName: props.prefix + "CompositeAlarmTopic", + enforceSSL: true, }); + + /** + * CDK NAG suppression + */ + NagSuppressions.addResourceSuppressions(onAlarmTopic, [ + { id: "AwsSolutions-SNS2", reason: "No sensitive data in topic." }, + { id: "AwsSolutions-SNS3", reason: "No sensitive data in topic." }, + ]); + + monitoring.createCompositeAlarmUsingDisambiguator("Critical", { + disambiguator: "Critical", + actionOverride: new SnsAlarmActionStrategy({ onAlarmTopic }), + }); + + this.compositeAlarmTopic = onAlarmTopic; } } diff --git a/lib/rag-engines/data-import/index.ts b/lib/rag-engines/data-import/index.ts index 0c18e1215..3d3747455 100644 --- a/lib/rag-engines/data-import/index.ts +++ b/lib/rag-engines/data-import/index.ts @@ -192,7 +192,9 @@ export class DataImport extends Construct { architecture: props.shared.lambdaArchitecture, timeout: cdk.Duration.minutes(15), memorySize: 512, - tracing: lambda.Tracing.ACTIVE, + tracing: props.config.advancedMonitoring + ? lambda.Tracing.ACTIVE + : lambda.Tracing.DISABLED, logRetention: props.config.logRetention ?? logs.RetentionDays.ONE_WEEK, loggingFormat: lambda.LoggingFormat.JSON, layers: [props.shared.powerToolsLayer, props.shared.commonLayer], diff --git a/lib/rag-engines/data-import/rss-subscription.ts b/lib/rag-engines/data-import/rss-subscription.ts index ebbcff9c5..99253889a 100644 --- a/lib/rag-engines/data-import/rss-subscription.ts +++ b/lib/rag-engines/data-import/rss-subscription.ts @@ -32,7 +32,9 @@ export class RssSubscription extends Construct { "Retrieves the latest data from the RSS Feed and adds any newly found posts to be queued for Website Crawling", architecture: props.shared.lambdaArchitecture, runtime: props.shared.pythonRuntime, - tracing: lambda.Tracing.ACTIVE, + tracing: props.config.advancedMonitoring + ? lambda.Tracing.ACTIVE + : lambda.Tracing.DISABLED, memorySize: 1024, handler: "index.lambda_handler", layers: [props.shared.powerToolsLayer, props.shared.commonLayer], @@ -73,7 +75,9 @@ export class RssSubscription extends Construct { description: "Invokes RSS Feed Ingestors for each Subscribed RSS Feed", architecture: props.shared.lambdaArchitecture, runtime: props.shared.pythonRuntime, - tracing: lambda.Tracing.ACTIVE, + tracing: props.config.advancedMonitoring + ? lambda.Tracing.ACTIVE + : lambda.Tracing.DISABLED, memorySize: 1024, handler: "index.lambda_handler", layers: [props.shared.powerToolsLayer, props.shared.commonLayer], @@ -124,7 +128,9 @@ export class RssSubscription extends Construct { ), architecture: props.shared.lambdaArchitecture, runtime: props.shared.pythonRuntime, - tracing: lambda.Tracing.ACTIVE, + tracing: props.config.advancedMonitoring + ? lambda.Tracing.ACTIVE + : lambda.Tracing.DISABLED, memorySize: 1024, handler: "index.lambda_handler", layers: [props.shared.powerToolsLayer, props.shared.commonLayer], diff --git a/lib/shared/index.ts b/lib/shared/index.ts index ff420f594..5cd510ff1 100644 --- a/lib/shared/index.ts +++ b/lib/shared/index.ts @@ -40,8 +40,13 @@ export class Shared extends Construct { this.defaultEnvironmentVariables = { POWERTOOLS_DEV: "false", LOG_LEVEL: "INFO", - POWERTOOLS_LOGGER_LOG_EVENT: "true", + // Event might contain end user information and should not be logged by default + POWERTOOLS_LOGGER_LOG_EVENT: "false", POWERTOOLS_SERVICE_NAME: "chatbot", + AWS_XRAY_SDK_ENABLED: props.config.advancedMonitoring ? "true" : "false", + POWERTOOLS_TRACE_DISABLED: props.config.advancedMonitoring + ? "false" + : "true", }; let vpc: ec2.Vpc; diff --git a/lib/shared/layers/common/requirements.txt b/lib/shared/layers/common/requirements.txt index 0ce373a24..d9ab3f4a9 100644 --- a/lib/shared/layers/common/requirements.txt +++ b/lib/shared/layers/common/requirements.txt @@ -1,4 +1,4 @@ -aws_xray_sdk==2.12.1 +aws_xray_sdk==2.14.0 numpy==1.26.0 cfnresponse==1.1.2 aws_requests_auth==0.4.3 diff --git a/lib/shared/web-crawler-batch-job/requirements.txt b/lib/shared/web-crawler-batch-job/requirements.txt index f62a9a574..5b0d69233 100644 --- a/lib/shared/web-crawler-batch-job/requirements.txt +++ b/lib/shared/web-crawler-batch-job/requirements.txt @@ -15,6 +15,6 @@ beautifulsoup4==4.12.2 requests==2.32.0 attrs==23.1.0 feedparser==6.0.11 -aws_xray_sdk==2.12.1 +aws_xray_sdk==2.14.0 defusedxml==0.7.1 pdfplumber==0.11.0 \ No newline at end of file diff --git a/lib/user-interface/index.ts b/lib/user-interface/index.ts index 17b1e4b9f..60495665c 100644 --- a/lib/user-interface/index.ts +++ b/lib/user-interface/index.ts @@ -1,4 +1,5 @@ import * as cdk from "aws-cdk-lib"; +import * as cf from "aws-cdk-lib/aws-cloudfront"; import * as s3 from "aws-cdk-lib/aws-s3"; import * as cognito from "aws-cdk-lib/aws-cognito"; import * as s3deploy from "aws-cdk-lib/aws-s3-deployment"; @@ -30,6 +31,7 @@ export interface UserInterfaceProps { export class UserInterface extends Construct { public readonly publishedDomain: string; + public readonly cloudFrontDistribution?: cf.IDistribution; constructor(scope: Construct, id: string, props: UserInterfaceProps) { super(scope, id); @@ -56,7 +58,6 @@ export class UserInterface extends Construct { }); // Deploy either Private (only accessible within VPC) or Public facing website - let distribution; let redirectSignIn: string; if (props.config.privateWebsite) { @@ -71,7 +72,7 @@ export class UserInterface extends Construct { ...props, websiteBucket: websiteBucket, }); - distribution = publicWebsite.distribution; + this.cloudFrontDistribution = publicWebsite.distribution; this.publishedDomain = props.config.domain ? props.config.domain : publicWebsite.distribution.distributionDomainName; @@ -182,7 +183,9 @@ export class UserInterface extends Construct { prune: false, sources: [asset, exportsAsset], destinationBucket: websiteBucket, - distribution: props.config.privateWebsite ? undefined : distribution, + distribution: props.config.privateWebsite + ? undefined + : this.cloudFrontDistribution, }); /** diff --git a/lib/user-interface/react-app/package-lock.json b/lib/user-interface/react-app/package-lock.json index b0589058e..4f7fb8768 100644 --- a/lib/user-interface/react-app/package-lock.json +++ b/lib/user-interface/react-app/package-lock.json @@ -17785,9 +17785,9 @@ } }, "node_modules/rollup": { - "version": "3.29.4", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.4.tgz", - "integrity": "sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==", + "version": "3.29.5", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.5.tgz", + "integrity": "sha512-GVsDdsbJzzy4S/v3dqWPJ7EfvZJfCHiDqe80IyrF59LYuP+e6U1LJoUqeuqRbwAWoMNoXivMNeNAOf5E22VA1w==", "dev": true, "bin": { "rollup": "dist/bin/rollup" diff --git a/package-lock.json b/package-lock.json index 499d04252..63adf2b93 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@aws-cdk/aws-apigatewayv2-integrations-alpha": "^2.114.1-alpha.0", "@aws-cdk/aws-cognito-identitypool-alpha": "^2.114.1-alpha.0", "@cdklabs/generative-ai-cdk-constructs": "^0.1.122", - "aws-cdk-lib": "2.145.0", + "aws-cdk-lib": "2.159.1", "cdk-monitoring-constructs": "8.1.0", "cdk-nag": "2.28.139", "commander": "^11.0.0", @@ -43,7 +43,8 @@ "@types/node": "20.1.7", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", - "aws-cdk": "2.148.1", + "aws-cdk": "2.159.1", + "aws-xray-sdk-core": "3.10.1", "eslint": "^8.45.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.2.1", @@ -302,9 +303,9 @@ "integrity": "sha512-3M2tELJOxQv0apCIiuKQ4pAbncz9GuLwnKFqxifWfe77wuMxyTRPmxssYHs42ePqzap1LT6GDcPygGs+hHstLg==" }, "node_modules/@aws-cdk/asset-node-proxy-agent-v6": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@aws-cdk/asset-node-proxy-agent-v6/-/asset-node-proxy-agent-v6-2.0.3.tgz", - "integrity": "sha512-twhuEG+JPOYCYPx/xy5uH2+VUsIEhPTzDY0F1KuB+ocjWWB/KEDiOVL19nHvbPCB6fhWnkykXEMJ4HHcKvjtvg==" + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@aws-cdk/asset-node-proxy-agent-v6/-/asset-node-proxy-agent-v6-2.1.0.tgz", + "integrity": "sha512-7bY3J8GCVxLupn/kNmpPc5VJz8grx+4RKfnnJiO1LG+uxkZfANZG3RMHhE+qQxxwkyQ9/MfPtTpf748UhR425A==" }, "node_modules/@aws-cdk/aws-apigatewayv2-alpha": { "version": "2.114.1-alpha.0", @@ -356,6 +357,41 @@ "constructs": "^10.0.0" } }, + "node_modules/@aws-cdk/cloud-assembly-schema": { + "version": "36.3.0", + "resolved": "https://registry.npmjs.org/@aws-cdk/cloud-assembly-schema/-/cloud-assembly-schema-36.3.0.tgz", + "integrity": "sha512-mLSYgcMFTNCXrGAD7xob95p9s47/7WwEWUJiexxM46H2GxiijhlhLQJs31AS5uRRP6Cx1DLEu4qayKAUOOVGrw==", + "bundleDependencies": [ + "jsonschema", + "semver" + ], + "dependencies": { + "jsonschema": "^1.4.1", + "semver": "^7.6.3" + }, + "engines": { + "node": ">= 18.18.0" + } + }, + "node_modules/@aws-cdk/cloud-assembly-schema/node_modules/jsonschema": { + "version": "1.4.1", + "inBundle": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/@aws-cdk/cloud-assembly-schema/node_modules/semver": { + "version": "7.6.3", + "inBundle": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@aws-crypto/crc32": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@aws-crypto/crc32/-/crc32-3.0.0.tgz", @@ -2787,9 +2823,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.21.3.tgz", - "integrity": "sha512-MmKSfaB9GX+zXl6E8z4koOr/xU63AMVleLEa64v7R0QF/ZloMs5vcD1sHgM64GXXS1csaJutG+ddtzcueI/BLg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.4.tgz", + "integrity": "sha512-Fxamp4aEZnfPOcGA8KSNEohV8hX7zVHOemC8jVBoBUHu5zpJK/Eu3uJwt6BMgy9fkvzxDaurgj96F/NiLukF2w==", "cpu": [ "arm" ], @@ -2800,9 +2836,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.21.3.tgz", - "integrity": "sha512-zrt8ecH07PE3sB4jPOggweBjJMzI1JG5xI2DIsUbkA+7K+Gkjys6eV7i9pOenNSDJH3eOr/jLb/PzqtmdwDq5g==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.4.tgz", + "integrity": "sha512-VXoK5UMrgECLYaMuGuVTOx5kcuap1Jm8g/M83RnCHBKOqvPPmROFJGQaZhGccnsFtfXQ3XYa4/jMCJvZnbJBdA==", "cpu": [ "arm64" ], @@ -2813,9 +2849,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.21.3.tgz", - "integrity": "sha512-P0UxIOrKNBFTQaXTxOH4RxuEBVCgEA5UTNV6Yz7z9QHnUJ7eLX9reOd/NYMO3+XZO2cco19mXTxDMXxit4R/eQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.4.tgz", + "integrity": "sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q==", "cpu": [ "arm64" ], @@ -2826,9 +2862,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.21.3.tgz", - "integrity": "sha512-L1M0vKGO5ASKntqtsFEjTq/fD91vAqnzeaF6sfNAy55aD+Hi2pBI5DKwCO+UNDQHWsDViJLqshxOahXyLSh3EA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.4.tgz", + "integrity": "sha512-aJJyYKQwbHuhTUrjWjxEvGnNNBCnmpHDvrb8JFDbeSH3m2XdHcxDd3jthAzvmoI8w/kSjd2y0udT+4okADsZIw==", "cpu": [ "x64" ], @@ -2839,9 +2875,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.21.3.tgz", - "integrity": "sha512-btVgIsCjuYFKUjopPoWiDqmoUXQDiW2A4C3Mtmp5vACm7/GnyuprqIDPNczeyR5W8rTXEbkmrJux7cJmD99D2g==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.4.tgz", + "integrity": "sha512-j63YtCIRAzbO+gC2L9dWXRh5BFetsv0j0va0Wi9epXDgU/XUi5dJKo4USTttVyK7fGw2nPWK0PbAvyliz50SCQ==", "cpu": [ "arm" ], @@ -2852,9 +2888,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.21.3.tgz", - "integrity": "sha512-zmjbSphplZlau6ZTkxd3+NMtE4UKVy7U4aVFMmHcgO5CUbw17ZP6QCgyxhzGaU/wFFdTfiojjbLG3/0p9HhAqA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.4.tgz", + "integrity": "sha512-dJnWUgwWBX1YBRsuKKMOlXCzh2Wu1mlHzv20TpqEsfdZLb3WoJW2kIEsGwLkroYf24IrPAvOT/ZQ2OYMV6vlrg==", "cpu": [ "arm" ], @@ -2865,9 +2901,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.21.3.tgz", - "integrity": "sha512-nSZfcZtAnQPRZmUkUQwZq2OjQciR6tEoJaZVFvLHsj0MF6QhNMg0fQ6mUOsiCUpTqxTx0/O6gX0V/nYc7LrgPw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.4.tgz", + "integrity": "sha512-AdPRoNi3NKVLolCN/Sp4F4N1d98c4SBnHMKoLuiG6RXgoZ4sllseuGioszumnPGmPM2O7qaAX/IJdeDU8f26Aw==", "cpu": [ "arm64" ], @@ -2878,9 +2914,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.21.3.tgz", - "integrity": "sha512-MnvSPGO8KJXIMGlQDYfvYS3IosFN2rKsvxRpPO2l2cum+Z3exiExLwVU+GExL96pn8IP+GdH8Tz70EpBhO0sIQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.4.tgz", + "integrity": "sha512-Gl0AxBtDg8uoAn5CCqQDMqAx22Wx22pjDOjBdmG0VIWX3qUBHzYmOKh8KXHL4UpogfJ14G4wk16EQogF+v8hmA==", "cpu": [ "arm64" ], @@ -2891,9 +2927,9 @@ ] }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.21.3.tgz", - "integrity": "sha512-+W+p/9QNDr2vE2AXU0qIy0qQE75E8RTwTwgqS2G5CRQ11vzq0tbnfBd6brWhS9bCRjAjepJe2fvvkvS3dno+iw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.4.tgz", + "integrity": "sha512-3aVCK9xfWW1oGQpTsYJJPF6bfpWfhbRnhdlyhak2ZiyFLDaayz0EP5j9V1RVLAAxlmWKTDfS9wyRyY3hvhPoOg==", "cpu": [ "ppc64" ], @@ -2904,9 +2940,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.21.3.tgz", - "integrity": "sha512-yXH6K6KfqGXaxHrtr+Uoy+JpNlUlI46BKVyonGiaD74ravdnF9BUNC+vV+SIuB96hUMGShhKV693rF9QDfO6nQ==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.4.tgz", + "integrity": "sha512-ePYIir6VYnhgv2C5Xe9u+ico4t8sZWXschR6fMgoPUK31yQu7hTEJb7bCqivHECwIClJfKgE7zYsh1qTP3WHUA==", "cpu": [ "riscv64" ], @@ -2917,9 +2953,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.21.3.tgz", - "integrity": "sha512-R8cwY9wcnApN/KDYWTH4gV/ypvy9yZUHlbJvfaiXSB48JO3KpwSpjOGqO4jnGkLDSk1hgjYkTbTt6Q7uvPf8eg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.4.tgz", + "integrity": "sha512-GqFJ9wLlbB9daxhVlrTe61vJtEY99/xB3C8e4ULVsVfflcpmR6c8UZXjtkMA6FhNONhj2eA5Tk9uAVw5orEs4Q==", "cpu": [ "s390x" ], @@ -2942,9 +2978,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.21.3.tgz", - "integrity": "sha512-S0Yq+xA1VEH66uiMNhijsWAafffydd2X5b77eLHfRmfLsRSpbiAWiRHV6DEpz6aOToPsgid7TI9rGd6zB1rhbg==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.4.tgz", + "integrity": "sha512-UV6FZMUgePDZrFjrNGIWzDo/vABebuXBhJEqrHxrGiU6HikPy0Z3LfdtciIttEUQfuDdCn8fqh7wiFJjCNwO+g==", "cpu": [ "x64" ], @@ -2955,9 +2991,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.21.3.tgz", - "integrity": "sha512-9isNzeL34yquCPyerog+IMCNxKR8XYmGd0tHSV+OVx0TmE0aJOo9uw4fZfUuk2qxobP5sug6vNdZR6u7Mw7Q+Q==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.4.tgz", + "integrity": "sha512-BjI+NVVEGAXjGWYHz/vv0pBqfGoUH0IGZ0cICTn7kB9PyjrATSkX+8WkguNjWoj2qSr1im/+tTGRaY+4/PdcQw==", "cpu": [ "arm64" ], @@ -2968,9 +3004,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.21.3.tgz", - "integrity": "sha512-nMIdKnfZfzn1Vsk+RuOvl43ONTZXoAPUUxgcU0tXooqg4YrAqzfKzVenqqk2g5efWh46/D28cKFrOzDSW28gTA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.4.tgz", + "integrity": "sha512-SiWG/1TuUdPvYmzmYnmd3IEifzR61Tragkbx9D3+R8mzQqDBz8v+BvZNDlkiTtI9T15KYZhP0ehn3Dld4n9J5g==", "cpu": [ "ia32" ], @@ -2981,9 +3017,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.21.3.tgz", - "integrity": "sha512-fOvu7PCQjAj4eWDEuD8Xz5gpzFqXzGlxHZozHP4b9Jxv9APtdxL6STqztDzMLuRXEc4UpXGGhx029Xgm91QBeA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.4.tgz", + "integrity": "sha512-j8pPKp53/lq9lMXN57S8cFz0MynJk8OWNuUnXct/9KCpKU7DgU3bYMJhwWmcqC0UU29p8Lr0/7KEVcaM6bf47Q==", "cpu": [ "x64" ], @@ -3749,6 +3785,15 @@ "@babel/types": "^7.20.7" } }, + "node_modules/@types/cls-hooked": { + "version": "4.3.8", + "resolved": "https://registry.npmjs.org/@types/cls-hooked/-/cls-hooked-4.3.8.tgz", + "integrity": "sha512-tf/7H883gFA6MPlWI15EQtfNZ+oPL0gLKkOlx9UHFrun1fC/FkuyNBpTKq1B5E3T4fbvjId6WifHUdSGsMMuPg==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/country-list": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/@types/country-list/-/country-list-2.1.4.tgz", @@ -4549,16 +4594,34 @@ "integrity": "sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==", "dev": true }, + "node_modules/async-hook-jl": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/async-hook-jl/-/async-hook-jl-1.7.6.tgz", + "integrity": "sha512-gFaHkFfSxTjvoxDMYqDuGHlcRyUuamF8s+ZTtJdDzqjws4mCt7v0vuV79/E2Wr2/riMQgtG4/yUtXWs1gZ7JMg==", + "dev": true, + "dependencies": { + "stack-chain": "^1.3.7" + }, + "engines": { + "node": "^4.7 || >=6.9 || >=7.3" + } + }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", "dev": true }, + "node_modules/atomic-batcher": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/atomic-batcher/-/atomic-batcher-1.0.2.tgz", + "integrity": "sha512-EFGCRj4kLX1dHv1cDzTk+xbjBFj1GnJDpui52YmEcxxHHEWjYyT6l51U7n6WQ28osZH4S9gSybxe56Vm7vB61Q==", + "dev": true + }, "node_modules/aws-cdk": { - "version": "2.148.1", - "resolved": "https://registry.npmjs.org/aws-cdk/-/aws-cdk-2.148.1.tgz", - "integrity": "sha512-wiAi4vFJ52A42PpU3zRi2gVDqbTXSBVFrqKRqEd8wYL1mqa0qMv9FR35NsgbM1RL9s7g5ZljYvl+G2tXpcp5Eg==", + "version": "2.159.1", + "resolved": "https://registry.npmjs.org/aws-cdk/-/aws-cdk-2.159.1.tgz", + "integrity": "sha512-bkJOxic/NpJYQCF3MQhfyJVlFtIzMJeVGZp9jZa7TczxJp79Q/TNKzVJYv6GFabNS1wglGPfWkFB/rIJlRhJkg==", "dev": true, "bin": { "cdk": "bin/cdk" @@ -4571,9 +4634,9 @@ } }, "node_modules/aws-cdk-lib": { - "version": "2.145.0", - "resolved": "https://registry.npmjs.org/aws-cdk-lib/-/aws-cdk-lib-2.145.0.tgz", - "integrity": "sha512-0RCKdojCtF74rI2gGi9KUFVUKykTIMEs3ANjruIjxEz6d2cAsy9c2k+nCCSMdqhKZ9aPJgmBFewiw03Z8NtPig==", + "version": "2.159.1", + "resolved": "https://registry.npmjs.org/aws-cdk-lib/-/aws-cdk-lib-2.159.1.tgz", + "integrity": "sha512-zcOyAs3+DTu+CtLehdOgvyosZ7nbLZ+OfBE6uVNMshXm957oXJrLsu6hehLt81TDxfItWYNluFcXkwepZDm6Ng==", "bundleDependencies": [ "@balena/dockerignore", "case", @@ -4590,16 +4653,17 @@ "dependencies": { "@aws-cdk/asset-awscli-v1": "^2.2.202", "@aws-cdk/asset-kubectl-v20": "^2.1.2", - "@aws-cdk/asset-node-proxy-agent-v6": "^2.0.3", + "@aws-cdk/asset-node-proxy-agent-v6": "^2.1.0", + "@aws-cdk/cloud-assembly-schema": "^36.0.24", "@balena/dockerignore": "^1.0.2", "case": "1.6.3", "fs-extra": "^11.2.0", - "ignore": "^5.3.1", + "ignore": "^5.3.2", "jsonschema": "^1.4.1", "mime-types": "^2.1.35", "minimatch": "^3.1.2", "punycode": "^2.3.1", - "semver": "^7.6.0", + "semver": "^7.6.3", "table": "^6.8.2", "yaml": "1.10.2" }, @@ -4616,14 +4680,14 @@ "license": "Apache-2.0" }, "node_modules/aws-cdk-lib/node_modules/ajv": { - "version": "8.13.0", + "version": "8.17.1", "inBundle": true, "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.4.1" + "require-from-string": "^2.0.2" }, "funding": { "type": "github", @@ -4713,6 +4777,11 @@ "inBundle": true, "license": "MIT" }, + "node_modules/aws-cdk-lib/node_modules/fast-uri": { + "version": "3.0.1", + "inBundle": true, + "license": "MIT" + }, "node_modules/aws-cdk-lib/node_modules/fs-extra": { "version": "11.2.0", "inBundle": true, @@ -4732,7 +4801,7 @@ "license": "ISC" }, "node_modules/aws-cdk-lib/node_modules/ignore": { - "version": "5.3.1", + "version": "5.3.2", "inBundle": true, "license": "MIT", "engines": { @@ -4776,17 +4845,6 @@ "inBundle": true, "license": "MIT" }, - "node_modules/aws-cdk-lib/node_modules/lru-cache": { - "version": "6.0.0", - "inBundle": true, - "license": "ISC", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/aws-cdk-lib/node_modules/mime-db": { "version": "1.52.0", "inBundle": true, @@ -4834,12 +4892,9 @@ } }, "node_modules/aws-cdk-lib/node_modules/semver": { - "version": "7.6.0", + "version": "7.6.3", "inBundle": true, "license": "ISC", - "dependencies": { - "lru-cache": "^6.0.0" - }, "bin": { "semver": "bin/semver.js" }, @@ -4910,19 +4965,6 @@ "node": ">= 10.0.0" } }, - "node_modules/aws-cdk-lib/node_modules/uri-js": { - "version": "4.4.1", - "inBundle": true, - "license": "BSD-2-Clause", - "dependencies": { - "punycode": "^2.1.0" - } - }, - "node_modules/aws-cdk-lib/node_modules/yallist": { - "version": "4.0.0", - "inBundle": true, - "license": "ISC" - }, "node_modules/aws-cdk-lib/node_modules/yaml": { "version": "1.10.2", "inBundle": true, @@ -4931,6 +4973,23 @@ "node": ">= 6" } }, + "node_modules/aws-xray-sdk-core": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/aws-xray-sdk-core/-/aws-xray-sdk-core-3.10.1.tgz", + "integrity": "sha512-Eb1Iy5WEjRqRi8G+gi32QjR7t/9xTDore8EKasXsPMXCLMlYunslxJAvT2PDLXQ7ohEC/mKT9+7tUyUt6CGruw==", + "dev": true, + "dependencies": { + "@aws-sdk/types": "^3.4.1", + "@smithy/service-error-classification": "^2.0.4", + "@types/cls-hooked": "^4.3.3", + "atomic-batcher": "^1.0.2", + "cls-hooked": "^4.2.2", + "semver": "^7.5.3" + }, + "engines": { + "node": ">= 14.x" + } + }, "node_modules/axios": { "version": "1.7.4", "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz", @@ -5321,6 +5380,29 @@ "node": ">=12" } }, + "node_modules/cls-hooked": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/cls-hooked/-/cls-hooked-4.2.2.tgz", + "integrity": "sha512-J4Xj5f5wq/4jAvcdgoGsL3G103BtWpZrMo8NEinRltN+xpTZdI+M38pyQqhuFU/P792xkMFvnKSf+Lm81U1bxw==", + "dev": true, + "dependencies": { + "async-hook-jl": "^1.7.6", + "emitter-listener": "^1.0.1", + "semver": "^5.4.1" + }, + "engines": { + "node": "^4.7 || >=6.9 || >=7.3 || >=8.2.1" + } + }, + "node_modules/cls-hooked/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, "node_modules/co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -5574,6 +5656,15 @@ "integrity": "sha512-kc4r3U3V3WLaaZqThjYz/Y6z8tJe+7K0bbjUVo3i+LWIypVdMx5nXCkwRe6SWbY6ILqLdc1rKcKmr3HoH7wjSQ==", "dev": true }, + "node_modules/emitter-listener": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/emitter-listener/-/emitter-listener-1.1.2.tgz", + "integrity": "sha512-Bt1sBAGFHY9DKY+4/2cV6izcKJUf5T7/gkdmkxzX/qv9CcGH8xSwVRW5mtX03SWJtRTWSOpzCuWN9rBFYZepZQ==", + "dev": true, + "dependencies": { + "shimmer": "^1.2.0" + } + }, "node_modules/emittery": { "version": "0.13.1", "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz", @@ -8069,9 +8160,9 @@ } }, "node_modules/rollup": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.21.3.tgz", - "integrity": "sha512-7sqRtBNnEbcBtMeRVc6VRsJMmpI+JU1z9VTvW8D4gXIYQFz0aLcsE6rRkyghZkLfEgUZgVvOG7A5CVz/VW5GIA==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.4.tgz", + "integrity": "sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A==", "dev": true, "dependencies": { "@types/estree": "1.0.5" @@ -8084,29 +8175,29 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.21.3", - "@rollup/rollup-android-arm64": "4.21.3", - "@rollup/rollup-darwin-arm64": "4.21.3", - "@rollup/rollup-darwin-x64": "4.21.3", - "@rollup/rollup-linux-arm-gnueabihf": "4.21.3", - "@rollup/rollup-linux-arm-musleabihf": "4.21.3", - "@rollup/rollup-linux-arm64-gnu": "4.21.3", - "@rollup/rollup-linux-arm64-musl": "4.21.3", - "@rollup/rollup-linux-powerpc64le-gnu": "4.21.3", - "@rollup/rollup-linux-riscv64-gnu": "4.21.3", - "@rollup/rollup-linux-s390x-gnu": "4.21.3", - "@rollup/rollup-linux-x64-gnu": "4.21.3", - "@rollup/rollup-linux-x64-musl": "4.21.3", - "@rollup/rollup-win32-arm64-msvc": "4.21.3", - "@rollup/rollup-win32-ia32-msvc": "4.21.3", - "@rollup/rollup-win32-x64-msvc": "4.21.3", + "@rollup/rollup-android-arm-eabi": "4.22.4", + "@rollup/rollup-android-arm64": "4.22.4", + "@rollup/rollup-darwin-arm64": "4.22.4", + "@rollup/rollup-darwin-x64": "4.22.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.22.4", + "@rollup/rollup-linux-arm-musleabihf": "4.22.4", + "@rollup/rollup-linux-arm64-gnu": "4.22.4", + "@rollup/rollup-linux-arm64-musl": "4.22.4", + "@rollup/rollup-linux-powerpc64le-gnu": "4.22.4", + "@rollup/rollup-linux-riscv64-gnu": "4.22.4", + "@rollup/rollup-linux-s390x-gnu": "4.22.4", + "@rollup/rollup-linux-x64-gnu": "4.22.4", + "@rollup/rollup-linux-x64-musl": "4.22.4", + "@rollup/rollup-win32-arm64-msvc": "4.22.4", + "@rollup/rollup-win32-ia32-msvc": "4.22.4", + "@rollup/rollup-win32-x64-msvc": "4.22.4", "fsevents": "~2.3.2" } }, "node_modules/rollup/node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.21.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.21.3.tgz", - "integrity": "sha512-kZPbX/NOPh0vhS5sI+dR8L1bU2cSO9FgxwM8r7wHzGydzfSjLRCFAT87GR5U9scj2rhzN3JPYVC7NoBbl4FZ0g==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.4.tgz", + "integrity": "sha512-87v0ol2sH9GE3cLQLNEy0K/R0pz1nvg76o8M5nhMR0+Q+BBGLnb35P0fVz4CQxHYXaAOhE8HhlkaZfsdUOlHwg==", "cpu": [ "x64" ], @@ -8214,6 +8305,12 @@ "vscode-textmate": "^8.0.0" } }, + "node_modules/shimmer": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.1.tgz", + "integrity": "sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw==", + "dev": true + }, "node_modules/signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", @@ -8267,6 +8364,12 @@ "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, + "node_modules/stack-chain": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/stack-chain/-/stack-chain-1.3.7.tgz", + "integrity": "sha512-D8cWtWVdIe/jBA7v5p5Hwl5yOSOrmZPWDPe2KxQ5UAGD+nxbxU0lKXA4h85Ta6+qgdKVL3vUxsbIZjc1kBG7ug==", + "dev": true + }, "node_modules/stack-utils": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", diff --git a/package.json b/package.json index 7733cfef8..058a09dd8 100644 --- a/package.json +++ b/package.json @@ -43,9 +43,10 @@ "@types/node": "20.1.7", "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", + "aws-xray-sdk-core": "3.10.1", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.2.1", - "aws-cdk": "2.148.1", + "aws-cdk": "2.159.1", "eslint": "^8.45.0", "eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-react-refresh": "^0.4.9", @@ -63,7 +64,7 @@ "@aws-cdk/aws-apigatewayv2-integrations-alpha": "^2.114.1-alpha.0", "@aws-cdk/aws-cognito-identitypool-alpha": "^2.114.1-alpha.0", "@cdklabs/generative-ai-cdk-constructs": "^0.1.122", - "aws-cdk-lib": "2.145.0", + "aws-cdk-lib": "2.159.1", "cdk-monitoring-constructs": "8.1.0", "cdk-nag": "2.28.139", "commander": "^11.0.0", diff --git a/tests/chatbot-api/__snapshots__/chatbot-api-construct.test.ts.snap b/tests/chatbot-api/__snapshots__/chatbot-api-construct.test.ts.snap index f629865c9..6d02ed3f5 100644 --- a/tests/chatbot-api/__snapshots__/chatbot-api-construct.test.ts.snap +++ b/tests/chatbot-api/__snapshots__/chatbot-api-construct.test.ts.snap @@ -87,212 +87,227 @@ exports[`snapshot test 1`] = ` "value": "763104351884", }, }, - "RagEnginesSageMakerModelImageRepositoryCfnMappingF3891114": { + "LatestNodeRuntimeMap": { "af-south-1": { - "account": "626614931356", + "value": "nodejs20.x", }, "ap-east-1": { - "account": "871362719292", + "value": "nodejs20.x", }, "ap-northeast-1": { - "account": "763104351884", + "value": "nodejs20.x", }, "ap-northeast-2": { - "account": "763104351884", + "value": "nodejs20.x", }, "ap-northeast-3": { - "account": "364406365360", + "value": "nodejs20.x", }, "ap-south-1": { - "account": "763104351884", + "value": "nodejs20.x", }, "ap-south-2": { - "account": "772153158452", + "value": "nodejs20.x", }, "ap-southeast-1": { - "account": "763104351884", + "value": "nodejs20.x", }, "ap-southeast-2": { - "account": "763104351884", + "value": "nodejs20.x", }, "ap-southeast-3": { - "account": "907027046896", + "value": "nodejs20.x", }, "ap-southeast-4": { - "account": "457447274322", + "value": "nodejs20.x", + }, + "ap-southeast-5": { + "value": "nodejs20.x", + }, + "ap-southeast-7": { + "value": "nodejs20.x", }, "ca-central-1": { - "account": "763104351884", + "value": "nodejs20.x", + }, + "ca-west-1": { + "value": "nodejs20.x", }, "cn-north-1": { - "account": "727897471807", + "value": "nodejs18.x", }, "cn-northwest-1": { - "account": "727897471807", + "value": "nodejs18.x", }, "eu-central-1": { - "account": "763104351884", + "value": "nodejs20.x", }, "eu-central-2": { - "account": "380420809688", + "value": "nodejs20.x", + }, + "eu-isoe-west-1": { + "value": "nodejs18.x", }, "eu-north-1": { - "account": "763104351884", + "value": "nodejs20.x", }, "eu-south-1": { - "account": "692866216735", + "value": "nodejs20.x", }, "eu-south-2": { - "account": "503227376785", + "value": "nodejs20.x", }, "eu-west-1": { - "account": "763104351884", + "value": "nodejs20.x", }, "eu-west-2": { - "account": "763104351884", + "value": "nodejs20.x", }, "eu-west-3": { - "account": "763104351884", + "value": "nodejs20.x", + }, + "il-central-1": { + "value": "nodejs20.x", }, "me-central-1": { - "account": "914824155844", + "value": "nodejs20.x", }, "me-south-1": { - "account": "217643126080", + "value": "nodejs20.x", + }, + "mx-central-1": { + "value": "nodejs20.x", }, "sa-east-1": { - "account": "763104351884", + "value": "nodejs20.x", }, "us-east-1": { - "account": "763104351884", + "value": "nodejs20.x", }, "us-east-2": { - "account": "763104351884", + "value": "nodejs20.x", }, "us-gov-east-1": { - "account": "446045086412", + "value": "nodejs18.x", }, "us-gov-west-1": { - "account": "442386744353", + "value": "nodejs18.x", }, "us-iso-east-1": { - "account": "886529160074", + "value": "nodejs18.x", + }, + "us-iso-west-1": { + "value": "nodejs18.x", }, "us-isob-east-1": { - "account": "094389454867", + "value": "nodejs18.x", }, "us-west-1": { - "account": "763104351884", + "value": "nodejs20.x", }, "us-west-2": { - "account": "763104351884", + "value": "nodejs20.x", }, }, - "ServiceprincipalMap": { + "RagEnginesSageMakerModelImageRepositoryCfnMappingF3891114": { "af-south-1": { - "states": "states.af-south-1.amazonaws.com", + "account": "626614931356", }, "ap-east-1": { - "states": "states.ap-east-1.amazonaws.com", + "account": "871362719292", }, "ap-northeast-1": { - "states": "states.ap-northeast-1.amazonaws.com", + "account": "763104351884", }, "ap-northeast-2": { - "states": "states.ap-northeast-2.amazonaws.com", + "account": "763104351884", }, "ap-northeast-3": { - "states": "states.ap-northeast-3.amazonaws.com", + "account": "364406365360", }, "ap-south-1": { - "states": "states.ap-south-1.amazonaws.com", + "account": "763104351884", }, "ap-south-2": { - "states": "states.ap-south-2.amazonaws.com", + "account": "772153158452", }, "ap-southeast-1": { - "states": "states.ap-southeast-1.amazonaws.com", + "account": "763104351884", }, "ap-southeast-2": { - "states": "states.ap-southeast-2.amazonaws.com", + "account": "763104351884", }, "ap-southeast-3": { - "states": "states.ap-southeast-3.amazonaws.com", + "account": "907027046896", }, "ap-southeast-4": { - "states": "states.ap-southeast-4.amazonaws.com", + "account": "457447274322", }, "ca-central-1": { - "states": "states.ca-central-1.amazonaws.com", + "account": "763104351884", }, "cn-north-1": { - "states": "states.cn-north-1.amazonaws.com", + "account": "727897471807", }, "cn-northwest-1": { - "states": "states.cn-northwest-1.amazonaws.com", + "account": "727897471807", }, "eu-central-1": { - "states": "states.eu-central-1.amazonaws.com", + "account": "763104351884", }, "eu-central-2": { - "states": "states.eu-central-2.amazonaws.com", + "account": "380420809688", }, "eu-north-1": { - "states": "states.eu-north-1.amazonaws.com", + "account": "763104351884", }, "eu-south-1": { - "states": "states.eu-south-1.amazonaws.com", + "account": "692866216735", }, "eu-south-2": { - "states": "states.eu-south-2.amazonaws.com", + "account": "503227376785", }, "eu-west-1": { - "states": "states.eu-west-1.amazonaws.com", + "account": "763104351884", }, "eu-west-2": { - "states": "states.eu-west-2.amazonaws.com", + "account": "763104351884", }, "eu-west-3": { - "states": "states.eu-west-3.amazonaws.com", - }, - "il-central-1": { - "states": "states.il-central-1.amazonaws.com", + "account": "763104351884", }, "me-central-1": { - "states": "states.me-central-1.amazonaws.com", + "account": "914824155844", }, "me-south-1": { - "states": "states.me-south-1.amazonaws.com", + "account": "217643126080", }, "sa-east-1": { - "states": "states.sa-east-1.amazonaws.com", + "account": "763104351884", }, "us-east-1": { - "states": "states.us-east-1.amazonaws.com", + "account": "763104351884", }, "us-east-2": { - "states": "states.us-east-2.amazonaws.com", + "account": "763104351884", }, "us-gov-east-1": { - "states": "states.us-gov-east-1.amazonaws.com", + "account": "446045086412", }, "us-gov-west-1": { - "states": "states.us-gov-west-1.amazonaws.com", + "account": "442386744353", }, "us-iso-east-1": { - "states": "states.amazonaws.com", - }, - "us-iso-west-1": { - "states": "states.amazonaws.com", + "account": "886529160074", }, "us-isob-east-1": { - "states": "states.amazonaws.com", + "account": "094389454867", }, "us-west-1": { - "states": "states.us-west-1.amazonaws.com", + "account": "763104351884", }, "us-west-2": { - "states": "states.us-west-2.amazonaws.com", + "account": "763104351884", }, }, }, @@ -570,13 +585,14 @@ def handler(event: dict, context): props = event["ResourceProperties"] notification_configuration = props["NotificationConfiguration"] managed = props.get('Managed', 'true').lower() == 'true' + skipDestinationValidation = props.get('SkipDestinationValidation', 'false').lower() == 'true' stack_id = event['StackId'] old = event.get("OldResourceProperties", {}).get("NotificationConfiguration", {}) if managed: config = handle_managed(event["RequestType"], notification_configuration) else: config = handle_unmanaged(props["BucketName"], stack_id, event["RequestType"], notification_configuration, old) - s3.put_bucket_notification_configuration(Bucket=props["BucketName"], NotificationConfiguration=config) + s3.put_bucket_notification_configuration(Bucket=props["BucketName"], NotificationConfiguration=config, SkipDestinationValidation=skipDestinationValidation) except Exception as e: logging.exception("Failed to put bucket notification configuration") response_status = "FAILED" @@ -590,17 +606,20 @@ def handle_managed(request_type, notification_configuration): return notification_configuration def handle_unmanaged(bucket, stack_id, request_type, notification_configuration, old): + def get_id(n): + n['Id'] = '' + strToHash=json.dumps(n, sort_keys=True).replace('"Name": "prefix"', '"Name": "Prefix"').replace('"Name": "suffix"', '"Name": "Suffix"') + return f"{stack_id}-{hash(strToHash)}" def with_id(n): - n['Id'] = f"{stack_id}-{hash(json.dumps(n, sort_keys=True))}" + n['Id'] = get_id(n) return n external_notifications = {} existing_notifications = s3.get_bucket_notification_configuration(Bucket=bucket) for t in CONFIGURATION_TYPES: if request_type == 'Update': - ids = [with_id(n) for n in old.get(t, [])] - old_incoming_ids = [n['Id'] for n in ids] - external_notifications[t] = [n for n in existing_notifications.get(t, []) if not n['Id'] in old_incoming_ids] + old_incoming_ids = [get_id(n) for n in old.get(t, [])] + external_notifications[t] = [n for n in existing_notifications.get(t, []) if not get_id(n) in old_incoming_ids] elif request_type == 'Delete': external_notifications[t] = [n for n in existing_notifications.get(t, []) if not n['Id'].startswith(f"{stack_id}-")] elif request_type == 'Create': @@ -643,8 +662,7 @@ def submit_response(event: dict, context, response_status: str, error_message: s print(response.read().decode("utf-8")) print("Status code: " + response.reason) except Exception as e: - print("send(..) failed executing request.urlopen(..): " + str(e)) -", + print("send(..) failed executing request.urlopen(..): " + str(e))", }, "Description": "AWS CloudFormation handler for "Custom::S3BucketNotifications" resources (@aws-cdk/aws-s3)", "Handler": "index.handler", @@ -1199,7 +1217,7 @@ def submit_response(event: dict, context, response_status: str, error_message: s "Arn", ], }, - "FieldLogLevel": "ALL", + "FieldLogLevel": "INFO", }, "Name": "ChatbotGraphqlApi", "UserPoolConfig": { @@ -1212,7 +1230,7 @@ def submit_response(event: dict, context, response_status: str, error_message: s }, }, "Visibility": "PRIVATE", - "XrayEnabled": true, + "XrayEnabled": false, }, "Type": "AWS::AppSync::GraphQLApi", }, @@ -2610,6 +2628,9 @@ schema { ], }, }, + "Properties": { + "TracingConfig": "PassThrough", + }, "Type": "AWS::SNS::Topic", }, "ChatBotApiConstructRealtimeOutgoingMessagesDLQA7E125CC": { @@ -2778,6 +2799,12 @@ schema { "Description": "Appsync resolver handling LLM Queries", "Environment": { "Variables": { + "AWS_XRAY_SDK_ENABLED": "false", + "LOG_LEVEL": "INFO", + "POWERTOOLS_DEV": "false", + "POWERTOOLS_LOGGER_LOG_EVENT": "false", + "POWERTOOLS_SERVICE_NAME": "chatbot", + "POWERTOOLS_TRACE_DISABLED": "true", "SNS_TOPIC_ARN": { "Ref": "ChatBotApiConstructRealtimeMessagesTopic85DE37B6", }, @@ -2949,14 +2976,21 @@ schema { }, "S3Key": "Dummy", }, + "Description": "Sends LLM Responses to Appsync", "Environment": { "Variables": { + "AWS_XRAY_SDK_ENABLED": "false", "GRAPHQL_ENDPOINT": { "Fn::GetAtt": [ "ChatBotApiConstructChatbotApi21E23C68", "GraphQLUrl", ], }, + "LOG_LEVEL": "INFO", + "POWERTOOLS_DEV": "false", + "POWERTOOLS_LOGGER_LOG_EVENT": "false", + "POWERTOOLS_SERVICE_NAME": "chatbot", + "POWERTOOLS_TRACE_DISABLED": "true", }, }, "Handler": "index.handler", @@ -3209,6 +3243,7 @@ schema { "AURORA_DB_SECRET_ID": { "Ref": "RagEnginesAuroraPgVectorAuroraDatabaseSecretAttachmentA167E2A9", }, + "AWS_XRAY_SDK_ENABLED": "false", "CHATBOT_FILES_BUCKET_NAME": { "Ref": "ChatBotApiConstructChatBucketsFilesBucket66FE32D5", }, @@ -3265,8 +3300,9 @@ schema { ], }, "POWERTOOLS_DEV": "false", - "POWERTOOLS_LOGGER_LOG_EVENT": "true", + "POWERTOOLS_LOGGER_LOG_EVENT": "false", "POWERTOOLS_SERVICE_NAME": "chatbot", + "POWERTOOLS_TRACE_DISABLED": "true", "PROCESSING_BUCKET_NAME": { "Ref": "RagEnginesDataImportProcessingBucketA7BE9701", }, @@ -3338,9 +3374,6 @@ schema { }, "Runtime": "python3.11", "Timeout": 600, - "TracingConfig": { - "Mode": "Active", - }, "VpcConfig": { "SecurityGroupIds": [ { @@ -3450,14 +3483,6 @@ schema { "Properties": { "PolicyDocument": { "Statement": [ - { - "Action": [ - "xray:PutTraceSegments", - "xray:PutTelemetryRecords", - ], - "Effect": "Allow", - "Resource": "*", - }, { "Action": [ "dynamodb:BatchGetItem", @@ -4098,7 +4123,7 @@ schema { "Arn", ], }, - "Runtime": "python3.9", + "Runtime": "python3.11", "Timeout": 900, }, "Type": "AWS::Lambda::Function", @@ -4259,7 +4284,15 @@ schema { "Arn", ], }, - "Runtime": "nodejs18.x", + "Runtime": { + "Fn::FindInMap": [ + "LatestNodeRuntimeMap", + { + "Ref": "AWS::Region", + }, + "value", + ], + }, "Timeout": 900, }, "Type": "AWS::Lambda::Function", @@ -4305,7 +4338,15 @@ schema { "Arn", ], }, - "Runtime": "nodejs18.x", + "Runtime": { + "Fn::FindInMap": [ + "LatestNodeRuntimeMap", + { + "Ref": "AWS::Region", + }, + "value", + ], + }, "Timeout": 900, }, "Type": "AWS::Lambda::Function", @@ -5313,10 +5354,12 @@ schema { "AURORA_DB_SECRET_ID": { "Ref": "RagEnginesAuroraPgVectorAuroraDatabaseSecretAttachmentA167E2A9", }, + "AWS_XRAY_SDK_ENABLED": "false", "LOG_LEVEL": "INFO", "POWERTOOLS_DEV": "false", - "POWERTOOLS_LOGGER_LOG_EVENT": "true", + "POWERTOOLS_LOGGER_LOG_EVENT": "false", "POWERTOOLS_SERVICE_NAME": "chatbot", + "POWERTOOLS_TRACE_DISABLED": "true", "WORKSPACES_BY_OBJECT_TYPE_INDEX_NAME": "by_object_type_idx", "WORKSPACES_TABLE_NAME": { "Ref": "RagEnginesRagDynamoDBTablesWorkspacesD2D3C0C4", @@ -5564,15 +5607,7 @@ schema { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { - "Service": { - "Fn::FindInMap": [ - "ServiceprincipalMap", - { - "Ref": "AWS::Region", - }, - "states", - ], - }, + "Service": "states.amazonaws.com", }, }, ], @@ -5696,10 +5731,12 @@ schema { "Description": "PGVector setup", "Environment": { "Variables": { + "AWS_XRAY_SDK_ENABLED": "false", "LOG_LEVEL": "INFO", "POWERTOOLS_DEV": "false", - "POWERTOOLS_LOGGER_LOG_EVENT": "true", + "POWERTOOLS_LOGGER_LOG_EVENT": "false", "POWERTOOLS_SERVICE_NAME": "chatbot", + "POWERTOOLS_TRACE_DISABLED": "true", }, }, "Handler": "index.lambda_handler", @@ -5922,7 +5959,15 @@ schema { "Arn", ], }, - "Runtime": "nodejs18.x", + "Runtime": { + "Fn::FindInMap": [ + "LatestNodeRuntimeMap", + { + "Ref": "AWS::Region", + }, + "value", + ], + }, "Timeout": 900, "VpcConfig": { "SecurityGroupIds": [ @@ -6779,15 +6824,7 @@ schema { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { - "Service": { - "Fn::FindInMap": [ - "ServiceprincipalMap", - { - "Ref": "AWS::Region", - }, - "states", - ], - }, + "Service": "states.amazonaws.com", }, }, ], @@ -7331,6 +7368,7 @@ schema { "Description": "Retrieves the latest data from the RSS Feed and adds any newly found posts to be queued for Website Crawling", "Environment": { "Variables": { + "AWS_XRAY_SDK_ENABLED": "false", "CONFIG_PARAMETER_NAME": { "Ref": "SharedConfig358B4A20", }, @@ -7341,8 +7379,9 @@ schema { }, "LOG_LEVEL": "INFO", "POWERTOOLS_DEV": "false", - "POWERTOOLS_LOGGER_LOG_EVENT": "true", + "POWERTOOLS_LOGGER_LOG_EVENT": "false", "POWERTOOLS_SERVICE_NAME": "chatbot", + "POWERTOOLS_TRACE_DISABLED": "true", "WORKSPACES_BY_OBJECT_TYPE_INDEX_NAME": "by_object_type_idx", "WORKSPACES_TABLE_NAME": { "Ref": "RagEnginesRagDynamoDBTablesWorkspacesD2D3C0C4", @@ -7383,9 +7422,6 @@ schema { }, "Runtime": "python3.11", "Timeout": 900, - "TracingConfig": { - "Mode": "Active", - }, }, "Type": "AWS::Lambda::Function", }, @@ -7447,14 +7483,6 @@ schema { "Properties": { "PolicyDocument": { "Statement": [ - { - "Action": [ - "xray:PutTraceSegments", - "xray:PutTelemetryRecords", - ], - "Effect": "Allow", - "Resource": "*", - }, { "Action": [ "ssm:DescribeParameters", @@ -7595,6 +7623,7 @@ schema { "Description": "Functions polls the RSS items for pending urls and invokes Website crawler inference. Max of 10 URLs per invoke.", "Environment": { "Variables": { + "AWS_XRAY_SDK_ENABLED": "false", "CONFIG_PARAMETER_NAME": { "Ref": "SharedConfig358B4A20", }, @@ -7605,8 +7634,9 @@ schema { }, "LOG_LEVEL": "INFO", "POWERTOOLS_DEV": "false", - "POWERTOOLS_LOGGER_LOG_EVENT": "true", + "POWERTOOLS_LOGGER_LOG_EVENT": "false", "POWERTOOLS_SERVICE_NAME": "chatbot", + "POWERTOOLS_TRACE_DISABLED": "true", "PROCESSING_BUCKET_NAME": { "Ref": "RagEnginesDataImportProcessingBucketA7BE9701", }, @@ -7653,9 +7683,6 @@ schema { }, "Runtime": "python3.11", "Timeout": 300, - "TracingConfig": { - "Mode": "Active", - }, "VpcConfig": { "SecurityGroupIds": [ { @@ -7787,14 +7814,6 @@ schema { "Properties": { "PolicyDocument": { "Statement": [ - { - "Action": [ - "xray:PutTraceSegments", - "xray:PutTelemetryRecords", - ], - "Effect": "Allow", - "Resource": "*", - }, { "Action": [ "s3:GetObject*", @@ -7979,6 +7998,7 @@ schema { "Description": "Invokes RSS Feed Ingestors for each Subscribed RSS Feed", "Environment": { "Variables": { + "AWS_XRAY_SDK_ENABLED": "false", "CONFIG_PARAMETER_NAME": { "Ref": "SharedConfig358B4A20", }, @@ -7989,8 +8009,9 @@ schema { }, "LOG_LEVEL": "INFO", "POWERTOOLS_DEV": "false", - "POWERTOOLS_LOGGER_LOG_EVENT": "true", + "POWERTOOLS_LOGGER_LOG_EVENT": "false", "POWERTOOLS_SERVICE_NAME": "chatbot", + "POWERTOOLS_TRACE_DISABLED": "true", "PROCESSING_BUCKET_NAME": { "Ref": "RagEnginesDataImportProcessingBucketA7BE9701", }, @@ -8037,9 +8058,6 @@ schema { }, "Runtime": "python3.11", "Timeout": 15, - "TracingConfig": { - "Mode": "Active", - }, }, "Type": "AWS::Lambda::Function", }, @@ -8138,14 +8156,6 @@ schema { "Properties": { "PolicyDocument": { "Statement": [ - { - "Action": [ - "xray:PutTraceSegments", - "xray:PutTelemetryRecords", - ], - "Effect": "Allow", - "Resource": "*", - }, { "Action": "lambda:InvokeFunction", "Effect": "Allow", @@ -8362,6 +8372,7 @@ schema { "Arn", ], }, + "SkipDestinationValidation": false, }, "Type": "Custom::S3BucketNotifications", }, @@ -8476,6 +8487,7 @@ schema { "API_KEYS_SECRETS_ARN": { "Ref": "SharedApiKeysSecret9EA666ED", }, + "AWS_XRAY_SDK_ENABLED": "false", "CONFIG_PARAMETER_NAME": { "Ref": "SharedConfig358B4A20", }, @@ -8491,8 +8503,9 @@ schema { }, "LOG_LEVEL": "INFO", "POWERTOOLS_DEV": "false", - "POWERTOOLS_LOGGER_LOG_EVENT": "true", + "POWERTOOLS_LOGGER_LOG_EVENT": "false", "POWERTOOLS_SERVICE_NAME": "chatbot", + "POWERTOOLS_TRACE_DISABLED": "true", "PROCESSING_BUCKET_NAME": { "Ref": "RagEnginesDataImportProcessingBucketA7BE9701", }, @@ -8545,9 +8558,6 @@ schema { }, "Runtime": "python3.11", "Timeout": 900, - "TracingConfig": { - "Mode": "Active", - }, "VpcConfig": { "SecurityGroupIds": [ { @@ -8679,14 +8689,6 @@ schema { "Properties": { "PolicyDocument": { "Statement": [ - { - "Action": [ - "xray:PutTraceSegments", - "xray:PutTelemetryRecords", - ], - "Effect": "Allow", - "Resource": "*", - }, { "Action": [ "s3:GetObject*", @@ -9794,15 +9796,7 @@ schema { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { - "Service": { - "Fn::FindInMap": [ - "ServiceprincipalMap", - { - "Ref": "AWS::Region", - }, - "states", - ], - }, + "Service": "states.amazonaws.com", }, }, ], @@ -9985,15 +9979,7 @@ schema { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { - "Service": { - "Fn::FindInMap": [ - "ServiceprincipalMap", - { - "Ref": "AWS::Region", - }, - "states", - ], - }, + "Service": "states.amazonaws.com", }, }, ], @@ -10714,6 +10700,7 @@ schema { "Description": "Creates the Open Search workspace", "Environment": { "Variables": { + "AWS_XRAY_SDK_ENABLED": "false", "LOG_LEVEL": "INFO", "OPEN_SEARCH_COLLECTION_ENDPOINT": { "Fn::GetAtt": [ @@ -10724,8 +10711,9 @@ schema { "OPEN_SEARCH_COLLECTION_ENDPOINT_PORT": "443", "OPEN_SEARCH_COLLECTION_NAME": "prefix-genaichatbot-workspac", "POWERTOOLS_DEV": "false", - "POWERTOOLS_LOGGER_LOG_EVENT": "true", + "POWERTOOLS_LOGGER_LOG_EVENT": "false", "POWERTOOLS_SERVICE_NAME": "chatbot", + "POWERTOOLS_TRACE_DISABLED": "true", "WORKSPACES_BY_OBJECT_TYPE_INDEX_NAME": "by_object_type_idx", "WORKSPACES_TABLE_NAME": { "Ref": "RagEnginesRagDynamoDBTablesWorkspacesD2D3C0C4", @@ -10977,15 +10965,7 @@ schema { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { - "Service": { - "Fn::FindInMap": [ - "ServiceprincipalMap", - { - "Ref": "AWS::Region", - }, - "states", - ], - }, + "Service": "states.amazonaws.com", }, }, ], @@ -12324,7 +12304,15 @@ schema { "Arn", ], }, - "Runtime": "nodejs18.x", + "Runtime": { + "Fn::FindInMap": [ + "LatestNodeRuntimeMap", + { + "Ref": "AWS::Region", + }, + "value", + ], + }, "Timeout": 900, }, "Type": "AWS::Lambda::Function", @@ -12474,7 +12462,15 @@ schema { "Arn", ], }, - "Runtime": "nodejs18.x", + "Runtime": { + "Fn::FindInMap": [ + "LatestNodeRuntimeMap", + { + "Ref": "AWS::Region", + }, + "value", + ], + }, "Timeout": 900, }, "Type": "AWS::Lambda::Function", @@ -12628,7 +12624,15 @@ schema { "Arn", ], }, - "Runtime": "nodejs18.x", + "Runtime": { + "Fn::FindInMap": [ + "LatestNodeRuntimeMap", + { + "Ref": "AWS::Region", + }, + "value", + ], + }, "Timeout": 900, }, "Type": "AWS::Lambda::Function", @@ -12826,15 +12830,7 @@ schema { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { - "Service": { - "Fn::FindInMap": [ - "ServiceprincipalMap", - { - "Ref": "AWS::Region", - }, - "states", - ], - }, + "Service": "states.amazonaws.com", }, }, ], @@ -13155,6 +13151,7 @@ schema { "AURORA_DB_SECRET_ID": { "Ref": "RagEnginesAuroraPgVectorAuroraDatabaseSecretAttachmentA167E2A9", }, + "AWS_XRAY_SDK_ENABLED": "false", "DEFAULT_KENDRA_S3_DATA_SOURCE_BUCKET_NAME": { "Ref": "RagEnginesKendraRetrievalKendraDataBucket1627A447", }, @@ -13170,8 +13167,9 @@ schema { ], }, "POWERTOOLS_DEV": "false", - "POWERTOOLS_LOGGER_LOG_EVENT": "true", + "POWERTOOLS_LOGGER_LOG_EVENT": "false", "POWERTOOLS_SERVICE_NAME": "chatbot", + "POWERTOOLS_TRACE_DISABLED": "true", "PROCESSING_BUCKET_NAME": { "Ref": "RagEnginesDataImportProcessingBucketA7BE9701", }, @@ -13682,15 +13680,7 @@ schema { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { - "Service": { - "Fn::FindInMap": [ - "ServiceprincipalMap", - { - "Ref": "AWS::Region", - }, - "states", - ], - }, + "Service": "states.amazonaws.com", }, }, ], @@ -13794,6 +13784,7 @@ schema { "AURORA_DB_SECRET_ID": { "Ref": "RagEnginesAuroraPgVectorAuroraDatabaseSecretAttachmentA167E2A9", }, + "AWS_XRAY_SDK_ENABLED": "false", "DEFAULT_KENDRA_S3_DATA_SOURCE_BUCKET_NAME": { "Ref": "RagEnginesKendraRetrievalKendraDataBucket1627A447", }, @@ -13810,8 +13801,9 @@ schema { ], }, "POWERTOOLS_DEV": "false", - "POWERTOOLS_LOGGER_LOG_EVENT": "true", + "POWERTOOLS_LOGGER_LOG_EVENT": "false", "POWERTOOLS_SERVICE_NAME": "chatbot", + "POWERTOOLS_TRACE_DISABLED": "true", "PROCESSING_BUCKET_NAME": { "Ref": "RagEnginesDataImportProcessingBucketA7BE9701", }, @@ -14229,15 +14221,7 @@ schema { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { - "Service": { - "Fn::FindInMap": [ - "ServiceprincipalMap", - { - "Ref": "AWS::Region", - }, - "states", - ], - }, + "Service": "states.amazonaws.com", }, }, ], diff --git a/tests/monitoring/__snapshots__/monitoring-contruct.test.ts.snap b/tests/monitoring/__snapshots__/monitoring-contruct.test.ts.snap index 2882bc92c..ed1c4812c 100644 --- a/tests/monitoring/__snapshots__/monitoring-contruct.test.ts.snap +++ b/tests/monitoring/__snapshots__/monitoring-contruct.test.ts.snap @@ -42,6 +42,150 @@ exports[`snapshot test 1`] = ` }, "Type": "AWS::Kendra::Index", }, + "MonitoringCompositeAlarmTopicA8B720C7": { + "Metadata": { + "cdk_nag": { + "rules_to_suppress": [ + { + "id": "AwsSolutions-SNS2", + "reason": "No sensitive data in topic.", + }, + { + "id": "AwsSolutions-SNS3", + "reason": "No sensitive data in topic.", + }, + ], + }, + }, + "Properties": { + "DisplayName": "CompositeAlarmTopic", + }, + "Type": "AWS::SNS::Topic", + }, + "MonitoringGenAIChatbotDashboardGenAIChatbotDashboardAppSyncFaultCountCritical74762E0C": { + "Properties": { + "ActionsEnabled": true, + "AlarmDescription": "Fault count is too high.", + "AlarmName": "GenAI-Chatbot-Dashboard-AppSync-Fault-Count-Critical", + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 3, + "EvaluationPeriods": 3, + "Metrics": [ + { + "Id": "m1", + "Label": "5XX Fault", + "MetricStat": { + "Metric": { + "Dimensions": [ + { + "Name": "GraphQLAPIId", + "Value": "graphqlApiId", + }, + ], + "MetricName": "5XXError", + "Namespace": "AWS/AppSync", + }, + "Period": 300, + "Stat": "Sum", + }, + "ReturnData": true, + }, + ], + "Threshold": 5, + "TreatMissingData": "notBreaching", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "MonitoringGenAIChatbotDashboardGenAIChatbotDashboardAppSyncLatencyP90Critical08C30F3D": { + "Properties": { + "ActionsEnabled": true, + "AlarmDescription": "P90 latency is too high.", + "AlarmName": "GenAI-Chatbot-Dashboard-AppSync-Latency-P90-Critical", + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 3, + "EvaluationPeriods": 3, + "Metrics": [ + { + "Id": "m1", + "Label": "P90", + "MetricStat": { + "Metric": { + "Dimensions": [ + { + "Name": "GraphQLAPIId", + "Value": "graphqlApiId", + }, + ], + "MetricName": "Latency", + "Namespace": "AWS/AppSync", + }, + "Period": 300, + "Stat": "p90", + }, + "ReturnData": true, + }, + ], + "Threshold": 3000, + "TreatMissingData": "notBreaching", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "MonitoringGenAIChatbotDashboardGenAIChatbotDashboardCompositeCritical8A060EEA": { + "Properties": { + "ActionsEnabled": true, + "AlarmActions": [ + { + "Ref": "MonitoringCompositeAlarmTopicA8B720C7", + }, + ], + "AlarmDescription": "Composite alarm", + "AlarmName": "GenAI-Chatbot-Dashboard-Composite-Critical", + "AlarmRule": { + "Fn::Join": [ + "", + [ + "(ALARM("", + { + "Fn::GetAtt": [ + "MonitoringGenAIChatbotDashboardGenAIChatbotDashboardAppSyncLatencyP90Critical08C30F3D", + "Arn", + ], + }, + "") OR ALARM("", + { + "Fn::GetAtt": [ + "MonitoringGenAIChatbotDashboardGenAIChatbotDashboardAppSyncFaultCountCritical74762E0C", + "Arn", + ], + }, + "") OR ALARM("", + { + "Fn::GetAtt": [ + "MonitoringGenAIChatbotDashboardGenAIChatbotDashboardStateMachine2FailureRateCritical80A9196E", + "Arn", + ], + }, + "") OR ALARM("", + { + "Fn::GetAtt": [ + "MonitoringGenAIChatbotDashboardGenAIChatbotDashboardStateMachine1FailureCountCriticalE67CE559", + "Arn", + ], + }, + "") OR ALARM("", + { + "Fn::GetAtt": [ + "MonitoringGenAIChatbotDashboardGenAIChatbotDashboardFunctionFaultRateCritical49A299E7", + "Arn", + ], + }, + ""))", + ], + ], + }, + }, + "Type": "AWS::CloudWatch::CompositeAlarm", + }, "MonitoringGenAIChatbotDashboardGenAIChatbotDashboardDashboardsDashboard32FE3B68": { "Properties": { "DashboardBody": { @@ -56,11 +200,11 @@ exports[`snapshot test 1`] = ` { "Ref": "AWS::Region", }, - "","metrics":[["AWS/AppSync","Latency","GraphQLAPIId","graphqlApiId",{"label":"P50","stat":"p50"}],["AWS/AppSync","Latency","GraphQLAPIId","graphqlApiId",{"label":"P90","stat":"p90"}],["AWS/AppSync","Latency","GraphQLAPIId","graphqlApiId",{"label":"P99","stat":"p99"}]],"yAxis":{"left":{"min":0,"label":"ms","showUnits":false}}}},{"type":"metric","width":6,"height":5,"x":12,"y":2,"properties":{"view":"timeSeries","title":"Errors","region":"", + "","metrics":[["AWS/AppSync","Latency","GraphQLAPIId","graphqlApiId",{"label":"P50","stat":"p50"}],["AWS/AppSync","Latency","GraphQLAPIId","graphqlApiId",{"label":"P90","stat":"p90"}],["AWS/AppSync","Latency","GraphQLAPIId","graphqlApiId",{"label":"P99","stat":"p99"}]],"annotations":{"horizontal":[{"label":"P90 > 3000 for 3 datapoints within 15 minutes","value":3000,"yAxis":"left"}]},"yAxis":{"left":{"min":0,"label":"ms","showUnits":false}}}},{"type":"metric","width":6,"height":5,"x":12,"y":2,"properties":{"view":"timeSeries","title":"Errors","region":"", { "Ref": "AWS::Region", }, - "","metrics":[["AWS/AppSync","4XXError","GraphQLAPIId","graphqlApiId",{"label":"4XX Error","stat":"Sum"}],["AWS/AppSync","5XXError","GraphQLAPIId","graphqlApiId",{"label":"5XX Fault","stat":"Sum"}]],"yAxis":{"left":{"min":0,"label":"Count","showUnits":false}}}},{"type":"metric","width":6,"height":5,"x":18,"y":2,"properties":{"view":"timeSeries","title":"Errors (rate)","region":"", + "","metrics":[["AWS/AppSync","4XXError","GraphQLAPIId","graphqlApiId",{"label":"4XX Error","stat":"Sum"}],["AWS/AppSync","5XXError","GraphQLAPIId","graphqlApiId",{"label":"5XX Fault","stat":"Sum"}]],"annotations":{"horizontal":[{"label":"5XX Fault > 5 for 3 datapoints within 15 minutes","value":5,"yAxis":"left"}]},"yAxis":{"left":{"min":0,"label":"Count","showUnits":false}}}},{"type":"metric","width":6,"height":5,"x":18,"y":2,"properties":{"view":"timeSeries","title":"Errors (rate)","region":"", { "Ref": "AWS::Region", }, @@ -236,7 +380,159 @@ exports[`snapshot test 1`] = ` { "Ref": "Index", }, - "",{"stat":"Sum","yAxis":"right"}]],"yAxis":{}}},{"type":"text","width":24,"height":1,"x":0,"y":66,"properties":{"markdown":"# Requests Processing"}},{"type":"text","width":24,"height":1,"x":0,"y":67,"properties":{"markdown":"# RAG Processing"}},{"type":"text","width":24,"height":1,"x":0,"y":68,"properties":{"markdown":"### State Machine **[StateMachine](https://", + "",{"stat":"Sum","yAxis":"right"}]],"yAxis":{}}},{"type":"text","width":24,"height":1,"x":0,"y":66,"properties":{"markdown":"# Requests Processing"}},{"type":"text","width":24,"height":1,"x":0,"y":67,"properties":{"markdown":"# RAG processing (File or website import)"}},{"type":"text","width":24,"height":1,"x":0,"y":68,"properties":{"markdown":"### State Machine **[StateMachine2](https://", + { + "Ref": "AWS::Region", + }, + ".console.aws.amazon.com/states/home?region=", + { + "Ref": "AWS::Region", + }, + "#/statemachines/view/arn:", + { + "Ref": "AWS::Partition", + }, + ":states:", + { + "Ref": "AWS::Region", + }, + ":", + { + "Ref": "AWS::AccountId", + }, + ":stateMachine:Name2)**"}},{"type":"metric","width":6,"height":5,"x":0,"y":69,"properties":{"view":"timeSeries","title":"Duration","region":"", + { + "Ref": "AWS::Region", + }, + "","metrics":[["AWS/States","ExecutionTime","StateMachineArn","arn:", + { + "Ref": "AWS::Partition", + }, + ":states:", + { + "Ref": "AWS::Region", + }, + ":", + { + "Ref": "AWS::AccountId", + }, + ":stateMachine:Name2",{"label":"P50","stat":"p50"}],["AWS/States","ExecutionTime","StateMachineArn","arn:", + { + "Ref": "AWS::Partition", + }, + ":states:", + { + "Ref": "AWS::Region", + }, + ":", + { + "Ref": "AWS::AccountId", + }, + ":stateMachine:Name2",{"label":"P90","stat":"p90"}],["AWS/States","ExecutionTime","StateMachineArn","arn:", + { + "Ref": "AWS::Partition", + }, + ":states:", + { + "Ref": "AWS::Region", + }, + ":", + { + "Ref": "AWS::AccountId", + }, + ":stateMachine:Name2",{"label":"P99","stat":"p99"}]],"yAxis":{"left":{"min":0,"label":"ms","showUnits":false}}}},{"type":"metric","width":12,"height":5,"x":6,"y":69,"properties":{"view":"timeSeries","title":"Executions","region":"", + { + "Ref": "AWS::Region", + }, + "","metrics":[["AWS/States","ExecutionsStarted","StateMachineArn","arn:", + { + "Ref": "AWS::Partition", + }, + ":states:", + { + "Ref": "AWS::Region", + }, + ":", + { + "Ref": "AWS::AccountId", + }, + ":stateMachine:Name2",{"label":"Started","stat":"Sum"}],["AWS/States","ExecutionsSucceeded","StateMachineArn","arn:", + { + "Ref": "AWS::Partition", + }, + ":states:", + { + "Ref": "AWS::Region", + }, + ":", + { + "Ref": "AWS::AccountId", + }, + ":stateMachine:Name2",{"label":"Succeeded","stat":"Sum"}],["AWS/States","ExecutionsFailed","StateMachineArn","arn:", + { + "Ref": "AWS::Partition", + }, + ":states:", + { + "Ref": "AWS::Region", + }, + ":", + { + "Ref": "AWS::AccountId", + }, + ":stateMachine:Name2",{"label":"Failed","stat":"Sum"}],["AWS/States","ExecutionsAborted","StateMachineArn","arn:", + { + "Ref": "AWS::Partition", + }, + ":states:", + { + "Ref": "AWS::Region", + }, + ":", + { + "Ref": "AWS::AccountId", + }, + ":stateMachine:Name2",{"label":"Aborted","stat":"Sum"}],["AWS/States","ExecutionThrottled","StateMachineArn","arn:", + { + "Ref": "AWS::Partition", + }, + ":states:", + { + "Ref": "AWS::Region", + }, + ":", + { + "Ref": "AWS::AccountId", + }, + ":stateMachine:Name2",{"label":"Throttled","stat":"Sum"}],["AWS/States","ExecutionsTimedOut","StateMachineArn","arn:", + { + "Ref": "AWS::Partition", + }, + ":states:", + { + "Ref": "AWS::Region", + }, + ":", + { + "Ref": "AWS::AccountId", + }, + ":stateMachine:Name2",{"label":"Timeout","stat":"Sum"}]],"yAxis":{"left":{"min":0,"label":"Count","showUnits":false}}}},{"type":"metric","width":6,"height":5,"x":18,"y":69,"properties":{"view":"timeSeries","title":"Errors (rate)","region":"", + { + "Ref": "AWS::Region", + }, + "","metrics":[["AWS/States","ExecutionsFailed","StateMachineArn","arn:", + { + "Ref": "AWS::Partition", + }, + ":states:", + { + "Ref": "AWS::Region", + }, + ":", + { + "Ref": "AWS::AccountId", + }, + ":stateMachine:Name2",{"label":"Failed (avg)"}]],"annotations":{"horizontal":[{"label":"Failed (avg) > 0.1 for 3 datapoints within 15 minutes","value":0.1,"yAxis":"left"}]},"yAxis":{}}},{"type":"text","width":24,"height":1,"x":0,"y":74,"properties":{"markdown":"# RAG engines management (Create table/index and cleanup)"}},{"type":"text","width":24,"height":1,"x":0,"y":75,"properties":{"markdown":"### State Machine **[StateMachine1](https://", { "Ref": "AWS::Region", }, @@ -256,7 +552,7 @@ exports[`snapshot test 1`] = ` { "Ref": "AWS::AccountId", }, - ":stateMachine:Name)**"}},{"type":"metric","width":6,"height":5,"x":0,"y":69,"properties":{"view":"timeSeries","title":"Duration","region":"", + ":stateMachine:Name1)**"}},{"type":"metric","width":6,"height":5,"x":0,"y":76,"properties":{"view":"timeSeries","title":"Duration","region":"", { "Ref": "AWS::Region", }, @@ -272,7 +568,7 @@ exports[`snapshot test 1`] = ` { "Ref": "AWS::AccountId", }, - ":stateMachine:Name",{"label":"P50","stat":"p50"}],["AWS/States","ExecutionTime","StateMachineArn","arn:", + ":stateMachine:Name1",{"label":"P50","stat":"p50"}],["AWS/States","ExecutionTime","StateMachineArn","arn:", { "Ref": "AWS::Partition", }, @@ -284,7 +580,7 @@ exports[`snapshot test 1`] = ` { "Ref": "AWS::AccountId", }, - ":stateMachine:Name",{"label":"P90","stat":"p90"}],["AWS/States","ExecutionTime","StateMachineArn","arn:", + ":stateMachine:Name1",{"label":"P90","stat":"p90"}],["AWS/States","ExecutionTime","StateMachineArn","arn:", { "Ref": "AWS::Partition", }, @@ -296,7 +592,7 @@ exports[`snapshot test 1`] = ` { "Ref": "AWS::AccountId", }, - ":stateMachine:Name",{"label":"P99","stat":"p99"}]],"yAxis":{"left":{"min":0,"label":"ms","showUnits":false}}}},{"type":"metric","width":12,"height":5,"x":6,"y":69,"properties":{"view":"timeSeries","title":"Executions","region":"", + ":stateMachine:Name1",{"label":"P99","stat":"p99"}]],"yAxis":{"left":{"min":0,"label":"ms","showUnits":false}}}},{"type":"metric","width":12,"height":5,"x":6,"y":76,"properties":{"view":"timeSeries","title":"Executions","region":"", { "Ref": "AWS::Region", }, @@ -312,7 +608,7 @@ exports[`snapshot test 1`] = ` { "Ref": "AWS::AccountId", }, - ":stateMachine:Name",{"label":"Started","stat":"Sum"}],["AWS/States","ExecutionsSucceeded","StateMachineArn","arn:", + ":stateMachine:Name1",{"label":"Started","stat":"Sum"}],["AWS/States","ExecutionsSucceeded","StateMachineArn","arn:", { "Ref": "AWS::Partition", }, @@ -324,7 +620,7 @@ exports[`snapshot test 1`] = ` { "Ref": "AWS::AccountId", }, - ":stateMachine:Name",{"label":"Succeeded","stat":"Sum"}],["AWS/States","ExecutionsFailed","StateMachineArn","arn:", + ":stateMachine:Name1",{"label":"Succeeded","stat":"Sum"}],["AWS/States","ExecutionsFailed","StateMachineArn","arn:", { "Ref": "AWS::Partition", }, @@ -336,7 +632,7 @@ exports[`snapshot test 1`] = ` { "Ref": "AWS::AccountId", }, - ":stateMachine:Name",{"label":"Failed","stat":"Sum"}],["AWS/States","ExecutionsAborted","StateMachineArn","arn:", + ":stateMachine:Name1",{"label":"Failed","stat":"Sum"}],["AWS/States","ExecutionsAborted","StateMachineArn","arn:", { "Ref": "AWS::Partition", }, @@ -348,7 +644,7 @@ exports[`snapshot test 1`] = ` { "Ref": "AWS::AccountId", }, - ":stateMachine:Name",{"label":"Aborted","stat":"Sum"}],["AWS/States","ExecutionThrottled","StateMachineArn","arn:", + ":stateMachine:Name1",{"label":"Aborted","stat":"Sum"}],["AWS/States","ExecutionThrottled","StateMachineArn","arn:", { "Ref": "AWS::Partition", }, @@ -360,7 +656,7 @@ exports[`snapshot test 1`] = ` { "Ref": "AWS::AccountId", }, - ":stateMachine:Name",{"label":"Throttled","stat":"Sum"}],["AWS/States","ExecutionsTimedOut","StateMachineArn","arn:", + ":stateMachine:Name1",{"label":"Throttled","stat":"Sum"}],["AWS/States","ExecutionsTimedOut","StateMachineArn","arn:", { "Ref": "AWS::Partition", }, @@ -372,7 +668,7 @@ exports[`snapshot test 1`] = ` { "Ref": "AWS::AccountId", }, - ":stateMachine:Name",{"label":"Timeout","stat":"Sum"}]],"yAxis":{"left":{"min":0,"label":"Count","showUnits":false}}}},{"type":"metric","width":6,"height":5,"x":18,"y":69,"properties":{"view":"timeSeries","title":"Errors (rate)","region":"", + ":stateMachine:Name1",{"label":"Timeout","stat":"Sum"}]],"annotations":{"horizontal":[{"label":"Failed > 0 for 1 datapoints within 5 minutes","value":0,"yAxis":"left"}]},"yAxis":{"left":{"min":0,"label":"Count","showUnits":false}}}},{"type":"metric","width":6,"height":5,"x":18,"y":76,"properties":{"view":"timeSeries","title":"Errors (rate)","region":"", { "Ref": "AWS::Region", }, @@ -388,7 +684,7 @@ exports[`snapshot test 1`] = ` { "Ref": "AWS::AccountId", }, - ":stateMachine:Name",{"label":"Failed (avg)"}]],"yAxis":{}}},{"type":"text","width":24,"height":1,"x":0,"y":74,"properties":{"markdown":"### Lambda Function **[Function](https://", + ":stateMachine:Name1",{"label":"Failed (avg)"}]],"yAxis":{}}},{"type":"text","width":24,"height":1,"x":0,"y":81,"properties":{"markdown":"### Lambda Function **[Function](https://", { "Ref": "AWS::Region", }, @@ -427,7 +723,7 @@ exports[`snapshot test 1`] = ` }, ], }, - ")**"}},{"type":"metric","width":6,"height":5,"x":0,"y":75,"properties":{"view":"timeSeries","title":"TPS","region":"", + ")**"}},{"type":"metric","width":6,"height":5,"x":0,"y":82,"properties":{"view":"timeSeries","title":"TPS","region":"", { "Ref": "AWS::Region", }, @@ -462,7 +758,7 @@ exports[`snapshot test 1`] = ` }, ], }, - "",{"label":"Invocations","stat":"Sum","visible":false,"id":"requests"}]],"yAxis":{"left":{"min":0,"label":"Rate","showUnits":false}}}},{"type":"metric","width":6,"height":5,"x":6,"y":75,"properties":{"view":"timeSeries","title":"Latency","region":"", + "",{"label":"Invocations","stat":"Sum","visible":false,"id":"requests"}]],"yAxis":{"left":{"min":0,"label":"Rate","showUnits":false}}}},{"type":"metric","width":6,"height":5,"x":6,"y":82,"properties":{"view":"timeSeries","title":"Latency","region":"", { "Ref": "AWS::Region", }, @@ -559,7 +855,7 @@ exports[`snapshot test 1`] = ` }, ], }, - "",{"label":"P99 (avg: \${AVG})","stat":"p99"}]],"yAxis":{"left":{"min":0,"label":"ms","showUnits":false}}}},{"type":"metric","width":6,"height":5,"x":12,"y":75,"properties":{"view":"timeSeries","title":"Errors (rate)","region":"", + "",{"label":"P99 (avg: \${AVG})","stat":"p99"}]],"yAxis":{"left":{"min":0,"label":"ms","showUnits":false}}}},{"type":"metric","width":6,"height":5,"x":12,"y":82,"properties":{"view":"timeSeries","title":"Errors (rate)","region":"", { "Ref": "AWS::Region", }, @@ -594,7 +890,7 @@ exports[`snapshot test 1`] = ` }, ], }, - "",{"label":"Faults (avg)"}]],"yAxis":{"left":{"min":0,"label":"Rate","showUnits":false}}}},{"type":"metric","width":6,"height":5,"x":18,"y":75,"properties":{"view":"timeSeries","title":"Rates","region":"", + "",{"label":"Faults (avg)"}]],"annotations":{"horizontal":[{"label":"Faults (avg) > 0.1 for 3 datapoints within 15 minutes","value":0.1,"yAxis":"left"}]},"yAxis":{"left":{"min":0,"label":"Rate","showUnits":false}}}},{"type":"metric","width":6,"height":5,"x":18,"y":82,"properties":{"view":"timeSeries","title":"Rates","region":"", { "Ref": "AWS::Region", }, @@ -660,7 +956,7 @@ exports[`snapshot test 1`] = ` }, ], }, - "",{"label":"Provisioned Concurrency Spillovers (avg)"}]],"yAxis":{"left":{"min":0,"label":"Rate","showUnits":false}}}},{"type":"metric","width":8,"height":5,"x":0,"y":80,"properties":{"view":"timeSeries","title":"Invocations","region":"", + "",{"label":"Provisioned Concurrency Spillovers (avg)"}]],"yAxis":{"left":{"min":0,"label":"Rate","showUnits":false}}}},{"type":"metric","width":8,"height":5,"x":0,"y":87,"properties":{"view":"timeSeries","title":"Invocations","region":"", { "Ref": "AWS::Region", }, @@ -788,7 +1084,7 @@ exports[`snapshot test 1`] = ` }, ], }, - "",{"label":"Provisioned Concurrency Spillovers","stat":"Sum"}]],"yAxis":{"left":{"min":0,"label":"Count","showUnits":false}}}},{"type":"metric","width":8,"height":5,"x":8,"y":80,"properties":{"view":"timeSeries","title":"Iterator","region":"", + "",{"label":"Provisioned Concurrency Spillovers","stat":"Sum"}]],"yAxis":{"left":{"min":0,"label":"Count","showUnits":false}}}},{"type":"metric","width":8,"height":5,"x":8,"y":87,"properties":{"view":"timeSeries","title":"Iterator","region":"", { "Ref": "AWS::Region", }, @@ -823,7 +1119,7 @@ exports[`snapshot test 1`] = ` }, ], }, - "",{"label":"Iterator Age","stat":"Maximum"}]],"yAxis":{"left":{"min":0,"label":"ms","showUnits":false}}}},{"type":"metric","width":8,"height":5,"x":16,"y":80,"properties":{"view":"timeSeries","title":"Errors","region":"", + "",{"label":"Iterator Age","stat":"Maximum"}]],"yAxis":{"left":{"min":0,"label":"ms","showUnits":false}}}},{"type":"metric","width":8,"height":5,"x":16,"y":87,"properties":{"view":"timeSeries","title":"Errors","region":"", { "Ref": "AWS::Region", }, @@ -866,6 +1162,175 @@ exports[`snapshot test 1`] = ` }, "Type": "AWS::CloudWatch::Dashboard", }, + "MonitoringGenAIChatbotDashboardGenAIChatbotDashboardFunctionFaultRateCritical49A299E7": { + "Properties": { + "ActionsEnabled": true, + "AlarmDescription": "Fault rate is too high.", + "AlarmName": "GenAI-Chatbot-Dashboard-Function-Fault-Rate-Critical", + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 3, + "EvaluationPeriods": 3, + "Metrics": [ + { + "Id": "m1", + "Label": "Faults (avg)", + "MetricStat": { + "Metric": { + "Dimensions": [ + { + "Name": "FunctionName", + "Value": { + "Fn::Select": [ + 6, + { + "Fn::Split": [ + ":", + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition", + }, + ":lambda:", + { + "Ref": "AWS::Region", + }, + ":", + { + "Ref": "AWS::AccountId", + }, + ":function:Name", + ], + ], + }, + ], + }, + ], + }, + }, + ], + "MetricName": "Errors", + "Namespace": "AWS/Lambda", + }, + "Period": 300, + "Stat": "Average", + }, + "ReturnData": true, + }, + ], + "Threshold": 0.1, + "TreatMissingData": "notBreaching", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "MonitoringGenAIChatbotDashboardGenAIChatbotDashboardStateMachine1FailureCountCriticalE67CE559": { + "Properties": { + "ActionsEnabled": true, + "AlarmDescription": "Failure count is too high.", + "AlarmName": "GenAI-Chatbot-Dashboard-StateMachine1-Failure-Count-Critical", + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 1, + "EvaluationPeriods": 1, + "Metrics": [ + { + "Id": "m1", + "Label": "Failed", + "MetricStat": { + "Metric": { + "Dimensions": [ + { + "Name": "StateMachineArn", + "Value": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition", + }, + ":states:", + { + "Ref": "AWS::Region", + }, + ":", + { + "Ref": "AWS::AccountId", + }, + ":stateMachine:Name1", + ], + ], + }, + }, + ], + "MetricName": "ExecutionsFailed", + "Namespace": "AWS/States", + }, + "Period": 300, + "Stat": "Sum", + }, + "ReturnData": true, + }, + ], + "Threshold": 0, + "TreatMissingData": "notBreaching", + }, + "Type": "AWS::CloudWatch::Alarm", + }, + "MonitoringGenAIChatbotDashboardGenAIChatbotDashboardStateMachine2FailureRateCritical80A9196E": { + "Properties": { + "ActionsEnabled": true, + "AlarmDescription": "Failure rate is too high.", + "AlarmName": "GenAI-Chatbot-Dashboard-StateMachine2-Failure-Rate-Critical", + "ComparisonOperator": "GreaterThanThreshold", + "DatapointsToAlarm": 3, + "EvaluationPeriods": 3, + "Metrics": [ + { + "Id": "m1", + "Label": "Failed (avg)", + "MetricStat": { + "Metric": { + "Dimensions": [ + { + "Name": "StateMachineArn", + "Value": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition", + }, + ":states:", + { + "Ref": "AWS::Region", + }, + ":", + { + "Ref": "AWS::AccountId", + }, + ":stateMachine:Name2", + ], + ], + }, + }, + ], + "MetricName": "ExecutionsFailed", + "Namespace": "AWS/States", + }, + "Period": 300, + "Stat": "Average", + }, + "ReturnData": true, + }, + ], + "Threshold": 0.1, + "TreatMissingData": "notBreaching", + }, + "Type": "AWS::CloudWatch::Alarm", + }, "MonitoringUsageFilter0A1660EBB": { "Properties": { "FilterPattern": "{ $.metric_type = "token_usage" }", diff --git a/tests/monitoring/monitoring-contruct.test.ts b/tests/monitoring/monitoring-contruct.test.ts index 279c888f0..e258cf9a0 100644 --- a/tests/monitoring/monitoring-contruct.test.ts +++ b/tests/monitoring/monitoring-contruct.test.ts @@ -56,8 +56,11 @@ new Monitoring(stack, "Monitoring", { new Bucket(stack, "Bucket", { publicReadAccess: false, versioned: true }), ], ragFunctionProcessing: [Function.fromFunctionName(stack, "Function", "Name")], - ragStateMachineProcessing: [ - StateMachine.fromStateMachineName(stack, "StateMachine", "Name"), + ragEngineStateMachineProcessing: [ + StateMachine.fromStateMachineName(stack, "StateMachine1", "Name1"), + ], + ragImportStateMachineProcessing: [ + StateMachine.fromStateMachineName(stack, "StateMachine2", "Name2"), ], });