{"repo": "abdulsamad/polychat", "files": {"apps/serverless/template.example.yaml": {"5dcff834130f8b09f1d1305cfcef3c9c63ca9917": {"t": 1786068219.0134492, "n": 4221, "h": "667c7803a5ce085b", "c": "AWSTemplateFormatVersion: \"2010-09-09\"\nTransform: AWS::Serverless-2016-10-31\nDescription: Serverless Example\n\nResources:\n ApiFunction:\n Type: AWS::Serverless::Function\n Properties:\n FunctionName: ExampleFunction\n Handler: dist/index.handler\n Runtime: nodejs22.x\n Architectures:\n - x86_64\n Timeout: 30\n MemorySize: 128\n EphemeralStorage:\n Size: 512\n Role: !GetAtt LambdaExecutionRole.Arn\n Environment:\n Variables:\n PORT: !Ref PORT\n CLERK_ISSUER_BASE_URL: !Ref ClerkIssuerBaseURL\n GEMINI_API_KEY: !Ref GeminiAPIKey\n OPENAI_API_KEY: !Ref OpenAIAPIKey\n ANTHROPIC_API_KEY: !Ref AnthropicAPIKey\n MISTRAL_API_KEY: !Ref MistralAPIKey\n DEEPSEEK_API_KEY: !Ref DeepSeekAPIKey\n Metadata:\n BuildMethod: esbuild\n\n ApiFunctionUrl:\n Type: AWS::Lambda::Url\n Properties:\n AuthType: NONE\n Cors:\n AllowOrigins:\n - https://example.com\n AllowMethods:\n - POST\n - GET\n AllowHeaders:\n - \"Content-Type\"\n - \"Authorization\"\n MaxAge: 60\n InvokeMode: RESPONSE_STREAM\n TargetFunctionArn: !GetAtt ApiFunction.Arn\n\n ApiFunctionPermission:\n Type: AWS::Lambda::Permission\n Properties:\n FunctionName: !Ref ApiFunction\n Action: lambda:InvokeFunctionUrl\n Principal: \"*\"\n FunctionUrlAuthType: NONE\n\n ExampleLogGroup:\n Type: AWS::Logs::LogGroup\n Properties:\n LogGroupName: /aws/lambda/ExampleFunction\n RetentionInDays: 30\n\n LambdaExecutionRole:\n Type: AWS::IAM::Role\n Properties:\n AssumeRolePolicyDocument:\n Version: \"2012-10-17\"\n Statement:\n - Effect: Allow\n Principal:\n Service: lambda.amazonaws.com\n Action: sts:AssumeRole\n ManagedPolicyArns:\n - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole\n Policies:\n - PolicyName: CloudWatchAlarms\n PolicyDocument:\n Version: \"2012-10-17\"\n Statement:\n - Effect: Allow\n Action:\n - cloudwatch:PutMetricAlarm\n - cloudwatch:DeleteAlarms\n - cloudwatch:DescribeAlarms\n - cloudwatch:ListMetrics\n Resource:\n - !Sub \"arn:aws:cloudwatch:${AWS::Region}:${AWS::AccountId}:alarm/ExampleHighInvocation\"\n - !Sub \"arn:aws:cloudwatch:${AWS::Region}:${AWS::AccountId}:alarm/ExampleHighErrorRate\"\n\n LambdaInvocationAlarm:\n Type: AWS::CloudWatch::Alarm\n Properties:\n AlarmName: LambdaHighInvocation\n AlarmDescription: \"Trigger alarm if the function is invoked more than 1000 times within 5 minutes to prevent abuse.\"\n MetricName: Invocations\n Namespace: AWS/Lambda\n Statistic: Sum\n Period: 300\n EvaluationPeriods: 1\n Threshold: 1000\n ComparisonOperator: GreaterThanOrEqualToThreshold\n AlarmActions:\n - !Sub \"arn:aws:sns:${AWS::Region}:${AWS::AccountId}:LambdaAlertTopic\"\n Dimensions:\n - Name: ExampleFunction\n Value: !Ref ApiFunction\n\n LambdaErrorAlarm:\n Type: AWS::CloudWatch::Alarm\n Properties:\n AlarmName: LambdaHighErrorRate\n AlarmDescription: \"Trigger alarm if error rate exceeds 5% of invocations.\"\n MetricName: Errors\n Namespace: AWS/Lambda\n Statistic: Sum\n Period: 300\n EvaluationPeriods: 1\n Threshold: 50\n ComparisonOperator: GreaterThanOrEqualToThreshold\n AlarmActions:\n - !Sub \"arn:aws:sns:${AWS::Region}:${AWS::AccountId}:LambdaAlertTopic\"\n Dimensions:\n - Name: ExampleFunction\n Value: !Ref ApiFunction\n\n LambdaAlertTopic:\n Type: AWS::SNS::Topic\n Properties:\n TopicName: LambdaAlertTopic\n\nParameters:\n PORT:\n Type: String\n Default: \"3001\"\n ClerkIssuerBaseURL:\n Type: String\n GeminiAPIKey:\n Type: String\n OpenAIAPIKey:\n Type: String\n AnthropicAPIKey:\n Type: String\n MistralAPIKey:\n Type: String\n DeepSeekAPIKey:\n Type: String\n\nOutputs:\n FunctionUrl:\n Description: URL of the Lambda function\n Value: !GetAtt ApiFunctionUrl.FunctionUrl\n"}}}}