Created
June 18, 2020 18:26
-
-
Save bjorg/44b9363cda54e62c0d31e5b5b9b39389 to your computer and use it in GitHub Desktop.
CloudFormation JSON for API Gateway WebSocket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "AWSTemplateFormatVersion": "2010-09-09", | |
| "Parameters": { | |
| "Secrets": { | |
| "Type": "String", | |
| "Description": "Secret Keys (ARNs)", | |
| "Default": "" | |
| }, | |
| "XRayTracing": { | |
| "Type": "String", | |
| "Description": "AWS X-Ray Tracing", | |
| "AllowedValues": [ | |
| "Disabled", | |
| "RootModule", | |
| "AllModules" | |
| ], | |
| "Default": "Disabled" | |
| }, | |
| "LambdaSharpCoreServices": { | |
| "Type": "String", | |
| "Description": "Use LambdaSharp.Core Services", | |
| "AllowedValues": [ | |
| "Disabled", | |
| "Enabled" | |
| ], | |
| "Default": "Disabled" | |
| }, | |
| "LambdaSharpCoreDeadLetterQueue": { | |
| "Type": "String", | |
| "Description": "Cross-module reference for LambdaSharp.Core::DeadLetterQueue", | |
| "AllowedPattern": "^.+$", | |
| "ConstraintDescription": "must either be a cross-module reference or a non-empty value", | |
| "Default": "$LambdaSharp-Core::DeadLetterQueue" | |
| }, | |
| "LambdaSharpCoreLoggingStream": { | |
| "Type": "String", | |
| "Description": "Cross-module reference for LambdaSharp.Core::LoggingStream", | |
| "AllowedPattern": "^.+$", | |
| "ConstraintDescription": "must either be a cross-module reference or a non-empty value", | |
| "Default": "$LambdaSharp-Core::LoggingStream" | |
| }, | |
| "LambdaSharpCoreLoggingStreamRole": { | |
| "Type": "String", | |
| "Description": "Cross-module reference for LambdaSharp.Core::LoggingStreamRole", | |
| "AllowedPattern": "^.+$", | |
| "ConstraintDescription": "must either be a cross-module reference or a non-empty value", | |
| "Default": "$LambdaSharp-Core::LoggingStreamRole" | |
| }, | |
| "DeploymentBucketName": { | |
| "Type": "String", | |
| "Description": "Deployment S3 Bucket Name" | |
| }, | |
| "DeploymentPrefix": { | |
| "Type": "String", | |
| "Description": "Deployment Tier Prefix" | |
| }, | |
| "DeploymentPrefixLowercase": { | |
| "Type": "String", | |
| "Description": "Deployment Tier Prefix (lowercase)" | |
| }, | |
| "DeploymentRoot": { | |
| "Type": "String", | |
| "Description": "Root Stack Name", | |
| "Default": "" | |
| }, | |
| "DeploymentChecksum": { | |
| "Type": "String", | |
| "Description": "Deployment Checksum", | |
| "Default": "8032E7EEF28EC36C56249DAE77C90766" | |
| } | |
| }, | |
| "Resources": { | |
| "ConnectionsTable": { | |
| "Type": "AWS::DynamoDB::Table", | |
| "Properties": { | |
| "BillingMode": "PAY_PER_REQUEST", | |
| "AttributeDefinitions": [ | |
| { | |
| "AttributeName": "ConnectionId", | |
| "AttributeType": "S" | |
| } | |
| ], | |
| "KeySchema": [ | |
| { | |
| "AttributeName": "ConnectionId", | |
| "KeyType": "HASH" | |
| } | |
| ] | |
| } | |
| }, | |
| "ConnectionFunction": { | |
| "Type": "AWS::Lambda::Function", | |
| "Properties": { | |
| "Code": { | |
| "S3Bucket": { | |
| "Ref": "DeploymentBucketName" | |
| }, | |
| "S3Key": "<%MODULE_ORIGIN%>/Sample/WebSockets/.artifacts/ConnectionFunction-DRYRUN.zip" | |
| }, | |
| "DeadLetterConfig": { | |
| "TargetArn": { | |
| "Fn::If": [ | |
| "UseCoreServices", | |
| { | |
| "Fn::If": [ | |
| "LambdaSharpCoreDeadLetterQueueIsImported", | |
| { | |
| "Fn::ImportValue": { | |
| "Fn::Sub": [ | |
| "${DeploymentPrefix}${Import}", | |
| { | |
| "Import": { | |
| "Fn::Select": [ | |
| "1", | |
| { | |
| "Fn::Split": [ | |
| "$", | |
| { | |
| "Ref": "LambdaSharpCoreDeadLetterQueue" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "Ref": "LambdaSharpCoreDeadLetterQueue" | |
| } | |
| ] | |
| }, | |
| { | |
| "Ref": "AWS::NoValue" | |
| } | |
| ] | |
| } | |
| }, | |
| "Environment": { | |
| "Variables": { | |
| "DEBUG_LOGGING_ENABLED": "false", | |
| "MODULE_ID": { | |
| "Ref": "AWS::StackName" | |
| }, | |
| "MODULE_INFO": "Sample.WebSockets:1.0-DEV@<%MODULE_ORIGIN%>", | |
| "LAMBDA_NAME": "ConnectionFunction", | |
| "LAMBDA_RUNTIME": "dotnetcore3.1", | |
| "DEPLOYMENT_TIER": { | |
| "Fn::Select": [ | |
| "0", | |
| { | |
| "Fn::Split": [ | |
| "-", | |
| { | |
| "Ref": "DeploymentPrefix" | |
| } | |
| ] | |
| } | |
| ] | |
| }, | |
| "DEPLOYMENTBUCKETNAME": { | |
| "Ref": "DeploymentBucketName" | |
| }, | |
| "DEADLETTERQUEUE": { | |
| "Fn::If": [ | |
| "UseCoreServices", | |
| { | |
| "Fn::If": [ | |
| "LambdaSharpCoreDeadLetterQueueIsImported", | |
| { | |
| "Fn::ImportValue": { | |
| "Fn::Sub": [ | |
| "${DeploymentPrefix}${Import}", | |
| { | |
| "Import": { | |
| "Fn::Select": [ | |
| "1", | |
| { | |
| "Fn::Split": [ | |
| "$", | |
| { | |
| "Ref": "LambdaSharpCoreDeadLetterQueue" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "Ref": "LambdaSharpCoreDeadLetterQueue" | |
| } | |
| ] | |
| }, | |
| { | |
| "Ref": "AWS::NoValue" | |
| } | |
| ] | |
| }, | |
| "STR_CONNECTIONSTABLE": { | |
| "Fn::GetAtt": [ | |
| "ConnectionsTable", | |
| "Arn" | |
| ] | |
| }, | |
| "STR_MODULE_ROLE_DEADLETTERQUEUEPOLICY": { | |
| "Fn::If": [ | |
| "UseCoreServices", | |
| { | |
| "Ref": "ModuleRoleDeadLetterQueuePolicy" | |
| }, | |
| { | |
| "Ref": "AWS::NoValue" | |
| } | |
| ] | |
| }, | |
| "STR_MODULE_ROLE_SECRETSPOLICY": { | |
| "Fn::If": [ | |
| "ModuleRoleSecretsPolicyCondition", | |
| { | |
| "Ref": "ModuleRoleSecretsPolicy" | |
| }, | |
| { | |
| "Ref": "AWS::NoValue" | |
| } | |
| ] | |
| }, | |
| "STR_MODULE_WEBSOCKET_URL": { | |
| "Fn::Sub": "wss://${ModuleWebSocket}.execute-api.${AWS::Region}.${AWS::URLSuffix}/LATEST" | |
| } | |
| } | |
| }, | |
| "Handler": "ConnectionFunction::WebSocketsSample.ConnectionFunction.Function::FunctionHandlerAsync", | |
| "MemorySize": "256", | |
| "Role": { | |
| "Fn::GetAtt": [ | |
| "ModuleRole", | |
| "Arn" | |
| ] | |
| }, | |
| "Runtime": "dotnetcore3.1", | |
| "Timeout": "30", | |
| "TracingConfig": { | |
| "Mode": { | |
| "Fn::If": [ | |
| "XRayIsEnabled", | |
| "Active", | |
| "PassThrough" | |
| ] | |
| } | |
| } | |
| } | |
| }, | |
| "ConnectionFunctionLogGroup": { | |
| "Type": "AWS::Logs::LogGroup", | |
| "Properties": { | |
| "LogGroupName": { | |
| "Fn::Sub": "/aws/lambda/${ConnectionFunction}" | |
| }, | |
| "RetentionInDays": 30 | |
| } | |
| }, | |
| "MessageFunction": { | |
| "Type": "AWS::Lambda::Function", | |
| "Properties": { | |
| "Code": { | |
| "S3Bucket": { | |
| "Ref": "DeploymentBucketName" | |
| }, | |
| "S3Key": "<%MODULE_ORIGIN%>/Sample/WebSockets/.artifacts/MessageFunction-DRYRUN.zip" | |
| }, | |
| "DeadLetterConfig": { | |
| "TargetArn": { | |
| "Fn::If": [ | |
| "UseCoreServices", | |
| { | |
| "Fn::If": [ | |
| "LambdaSharpCoreDeadLetterQueueIsImported", | |
| { | |
| "Fn::ImportValue": { | |
| "Fn::Sub": [ | |
| "${DeploymentPrefix}${Import}", | |
| { | |
| "Import": { | |
| "Fn::Select": [ | |
| "1", | |
| { | |
| "Fn::Split": [ | |
| "$", | |
| { | |
| "Ref": "LambdaSharpCoreDeadLetterQueue" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "Ref": "LambdaSharpCoreDeadLetterQueue" | |
| } | |
| ] | |
| }, | |
| { | |
| "Ref": "AWS::NoValue" | |
| } | |
| ] | |
| } | |
| }, | |
| "Environment": { | |
| "Variables": { | |
| "DEBUG_LOGGING_ENABLED": "false", | |
| "MODULE_ID": { | |
| "Ref": "AWS::StackName" | |
| }, | |
| "MODULE_INFO": "Sample.WebSockets:1.0-DEV@<%MODULE_ORIGIN%>", | |
| "LAMBDA_NAME": "MessageFunction", | |
| "LAMBDA_RUNTIME": "dotnetcore3.1", | |
| "DEPLOYMENT_TIER": { | |
| "Fn::Select": [ | |
| "0", | |
| { | |
| "Fn::Split": [ | |
| "-", | |
| { | |
| "Ref": "DeploymentPrefix" | |
| } | |
| ] | |
| } | |
| ] | |
| }, | |
| "DEPLOYMENTBUCKETNAME": { | |
| "Ref": "DeploymentBucketName" | |
| }, | |
| "DEADLETTERQUEUE": { | |
| "Fn::If": [ | |
| "UseCoreServices", | |
| { | |
| "Fn::If": [ | |
| "LambdaSharpCoreDeadLetterQueueIsImported", | |
| { | |
| "Fn::ImportValue": { | |
| "Fn::Sub": [ | |
| "${DeploymentPrefix}${Import}", | |
| { | |
| "Import": { | |
| "Fn::Select": [ | |
| "1", | |
| { | |
| "Fn::Split": [ | |
| "$", | |
| { | |
| "Ref": "LambdaSharpCoreDeadLetterQueue" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "Ref": "LambdaSharpCoreDeadLetterQueue" | |
| } | |
| ] | |
| }, | |
| { | |
| "Ref": "AWS::NoValue" | |
| } | |
| ] | |
| }, | |
| "STR_CONNECTIONSTABLE": { | |
| "Fn::GetAtt": [ | |
| "ConnectionsTable", | |
| "Arn" | |
| ] | |
| }, | |
| "STR_MODULE_ROLE_DEADLETTERQUEUEPOLICY": { | |
| "Fn::If": [ | |
| "UseCoreServices", | |
| { | |
| "Ref": "ModuleRoleDeadLetterQueuePolicy" | |
| }, | |
| { | |
| "Ref": "AWS::NoValue" | |
| } | |
| ] | |
| }, | |
| "STR_MODULE_ROLE_SECRETSPOLICY": { | |
| "Fn::If": [ | |
| "ModuleRoleSecretsPolicyCondition", | |
| { | |
| "Ref": "ModuleRoleSecretsPolicy" | |
| }, | |
| { | |
| "Ref": "AWS::NoValue" | |
| } | |
| ] | |
| }, | |
| "STR_MODULE_WEBSOCKET_URL": { | |
| "Fn::Sub": "wss://${ModuleWebSocket}.execute-api.${AWS::Region}.${AWS::URLSuffix}/LATEST" | |
| } | |
| } | |
| }, | |
| "Handler": "MessageFunction::WebSocketsSample.MessageFunction.Function::FunctionHandlerAsync", | |
| "MemorySize": "256", | |
| "Role": { | |
| "Fn::GetAtt": [ | |
| "ModuleRole", | |
| "Arn" | |
| ] | |
| }, | |
| "Runtime": "dotnetcore3.1", | |
| "Timeout": "30", | |
| "TracingConfig": { | |
| "Mode": { | |
| "Fn::If": [ | |
| "XRayIsEnabled", | |
| "Active", | |
| "PassThrough" | |
| ] | |
| } | |
| } | |
| } | |
| }, | |
| "MessageFunctionLogGroup": { | |
| "Type": "AWS::Logs::LogGroup", | |
| "Properties": { | |
| "LogGroupName": { | |
| "Fn::Sub": "/aws/lambda/${MessageFunction}" | |
| }, | |
| "RetentionInDays": 30 | |
| } | |
| }, | |
| "ModuleRole": { | |
| "Type": "AWS::IAM::Role", | |
| "Properties": { | |
| "AssumeRolePolicyDocument": { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Sid": "ModuleLambdaPrincipal", | |
| "Effect": "Allow", | |
| "Principal": { | |
| "Service": "lambda.amazonaws.com" | |
| }, | |
| "Action": "sts:AssumeRole" | |
| } | |
| ] | |
| }, | |
| "Policies": [ | |
| { | |
| "PolicyDocument": { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Sid": "ConnectionsTable", | |
| "Effect": "Allow", | |
| "Action": [ | |
| "dynamodb:BatchGetItem", | |
| "dynamodb:BatchWriteItem", | |
| "dynamodb:DeleteItem", | |
| "dynamodb:DescribeStream", | |
| "dynamodb:DescribeTable", | |
| "dynamodb:GetItem", | |
| "dynamodb:GetRecords", | |
| "dynamodb:GetShardIterator", | |
| "dynamodb:PutItem", | |
| "dynamodb:Query", | |
| "dynamodb:Scan", | |
| "dynamodb:UpdateItem" | |
| ], | |
| "Resource": [ | |
| { | |
| "Fn::GetAtt": [ | |
| "ConnectionsTable", | |
| "Arn" | |
| ] | |
| }, | |
| { | |
| "Fn::Join": [ | |
| "/", | |
| [ | |
| { | |
| "Fn::GetAtt": [ | |
| "ConnectionsTable", | |
| "Arn" | |
| ] | |
| }, | |
| "stream/*" | |
| ] | |
| ] | |
| }, | |
| { | |
| "Fn::Join": [ | |
| "/", | |
| [ | |
| { | |
| "Fn::GetAtt": [ | |
| "ConnectionsTable", | |
| "Arn" | |
| ] | |
| }, | |
| "index/*" | |
| ] | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "Sid": "LogStream", | |
| "Effect": "Allow", | |
| "Action": [ | |
| "logs:CreateLogStream", | |
| "logs:PutLogEvents" | |
| ], | |
| "Resource": "arn:aws:logs:*:*:*" | |
| }, | |
| { | |
| "Sid": "CloudFormation", | |
| "Effect": "Allow", | |
| "Action": [ | |
| "cloudformation:DescribeStacks" | |
| ], | |
| "Resource": { | |
| "Ref": "AWS::StackId" | |
| } | |
| }, | |
| { | |
| "Sid": "AWSXRay", | |
| "Effect": "Allow", | |
| "Action": [ | |
| "xray:GetSamplingRules", | |
| "xray:GetSamplingStatisticSummaries", | |
| "xray:GetSamplingTargets", | |
| "xray:PutTelemetryRecords", | |
| "xray:PutTraceSegments" | |
| ], | |
| "Resource": "*" | |
| }, | |
| { | |
| "Sid": "EventBus", | |
| "Effect": "Allow", | |
| "Action": [ | |
| "events:PutEvents" | |
| ], | |
| "Resource": { | |
| "Fn::Sub": "arn:aws:events:${AWS::Region}:${AWS::AccountId}:event-bus/default" | |
| } | |
| }, | |
| { | |
| "Sid": "DeploymentBucketReadOnly", | |
| "Effect": "Allow", | |
| "Action": [ | |
| "s3:GetObject" | |
| ], | |
| "Resource": { | |
| "Fn::Sub": "arn:aws:s3:::${DeploymentBucketName}/<%MODULE_ORIGIN%>/Sample/WebSockets/.artifacts/*" | |
| } | |
| }, | |
| { | |
| "Sid": "WebSocketConnections", | |
| "Effect": "Allow", | |
| "Action": [ | |
| "execute-api:ManageConnections" | |
| ], | |
| "Resource": { | |
| "Fn::Sub": "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ModuleWebSocket}/LATEST/POST/@connections/*" | |
| } | |
| } | |
| ] | |
| }, | |
| "PolicyName": { | |
| "Fn::Sub": "${AWS::StackName}ModulePolicy" | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| "ModuleRoleDeadLetterQueuePolicy": { | |
| "Type": "AWS::IAM::Policy", | |
| "Condition": "UseCoreServices", | |
| "Properties": { | |
| "PolicyDocument": { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Sid": "DeadLetterQueue", | |
| "Effect": "Allow", | |
| "Action": [ | |
| "sqs:SendMessage" | |
| ], | |
| "Resource": { | |
| "Fn::If": [ | |
| "UseCoreServices", | |
| { | |
| "Fn::If": [ | |
| "LambdaSharpCoreDeadLetterQueueIsImported", | |
| { | |
| "Fn::ImportValue": { | |
| "Fn::Sub": [ | |
| "${DeploymentPrefix}${Import}", | |
| { | |
| "Import": { | |
| "Fn::Select": [ | |
| "1", | |
| { | |
| "Fn::Split": [ | |
| "$", | |
| { | |
| "Ref": "LambdaSharpCoreDeadLetterQueue" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "Ref": "LambdaSharpCoreDeadLetterQueue" | |
| } | |
| ] | |
| }, | |
| { | |
| "Ref": "AWS::NoValue" | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| }, | |
| "PolicyName": { | |
| "Fn::Sub": "${AWS::StackName}ModuleRoleDeadLetterQueue" | |
| }, | |
| "Roles": [ | |
| { | |
| "Ref": "ModuleRole" | |
| } | |
| ] | |
| } | |
| }, | |
| "ModuleRoleSecretsPolicy": { | |
| "Type": "AWS::IAM::Policy", | |
| "Condition": "ModuleRoleSecretsPolicyCondition", | |
| "Properties": { | |
| "PolicyDocument": { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Sid": "Secrets", | |
| "Effect": "Allow", | |
| "Action": [ | |
| "kms:Decrypt", | |
| "kms:Encrypt" | |
| ], | |
| "Resource": { | |
| "Fn::Split": [ | |
| ",", | |
| { | |
| "Ref": "Secrets" | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| }, | |
| "PolicyName": { | |
| "Fn::Sub": "${AWS::StackName}ModuleRoleSecrets" | |
| }, | |
| "Roles": [ | |
| { | |
| "Ref": "ModuleRole" | |
| } | |
| ] | |
| } | |
| }, | |
| "ModuleRegistration": { | |
| "Type": "Custom::LambdaSharpRegistrationModule", | |
| "Condition": "UseCoreServices", | |
| "Properties": { | |
| "ServiceToken": { | |
| "Fn::ImportValue": { | |
| "Fn::Sub": "${DeploymentPrefix}LambdaSharp::Registration::Module" | |
| } | |
| }, | |
| "ResourceType": "LambdaSharp::Registration::Module", | |
| "ModuleInfo": "Sample.WebSockets:1.0-DEV@<%MODULE_ORIGIN%>", | |
| "ModuleId": { | |
| "Ref": "AWS::StackName" | |
| } | |
| } | |
| }, | |
| "ConnectionFunctionRegistration": { | |
| "Type": "Custom::LambdaSharpRegistrationFunction", | |
| "Condition": "UseCoreServices", | |
| "Properties": { | |
| "ServiceToken": { | |
| "Fn::ImportValue": { | |
| "Fn::Sub": "${DeploymentPrefix}LambdaSharp::Registration::Function" | |
| } | |
| }, | |
| "ResourceType": "LambdaSharp::Registration::Function", | |
| "ModuleId": { | |
| "Ref": "AWS::StackName" | |
| }, | |
| "FunctionId": { | |
| "Ref": "ConnectionFunction" | |
| }, | |
| "FunctionName": "ConnectionFunction", | |
| "FunctionLogGroupName": { | |
| "Fn::Sub": "/aws/lambda/${ConnectionFunction}" | |
| }, | |
| "FunctionPlatform": "AWS Lambda", | |
| "FunctionFramework": "dotnetcore3.1", | |
| "FunctionLanguage": "csharp", | |
| "FunctionMaxMemory": "256", | |
| "FunctionMaxDuration": "30" | |
| }, | |
| "DependsOn": [ | |
| "ModuleRegistration" | |
| ] | |
| }, | |
| "ConnectionFunctionLogGroupSubscription": { | |
| "Type": "AWS::Logs::SubscriptionFilter", | |
| "Condition": "UseCoreServices", | |
| "Properties": { | |
| "DestinationArn": { | |
| "Fn::If": [ | |
| "UseCoreServices", | |
| { | |
| "Fn::If": [ | |
| "LambdaSharpCoreLoggingStreamIsImported", | |
| { | |
| "Fn::ImportValue": { | |
| "Fn::Sub": [ | |
| "${DeploymentPrefix}${Import}", | |
| { | |
| "Import": { | |
| "Fn::Select": [ | |
| "1", | |
| { | |
| "Fn::Split": [ | |
| "$", | |
| { | |
| "Ref": "LambdaSharpCoreLoggingStream" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "Ref": "LambdaSharpCoreLoggingStream" | |
| } | |
| ] | |
| }, | |
| { | |
| "Ref": "AWS::NoValue" | |
| } | |
| ] | |
| }, | |
| "FilterPattern": "-\"*** \"", | |
| "LogGroupName": { | |
| "Ref": "ConnectionFunctionLogGroup" | |
| }, | |
| "RoleArn": { | |
| "Fn::If": [ | |
| "UseCoreServices", | |
| { | |
| "Fn::If": [ | |
| "LambdaSharpCoreLoggingStreamRoleIsImported", | |
| { | |
| "Fn::ImportValue": { | |
| "Fn::Sub": [ | |
| "${DeploymentPrefix}${Import}", | |
| { | |
| "Import": { | |
| "Fn::Select": [ | |
| "1", | |
| { | |
| "Fn::Split": [ | |
| "$", | |
| { | |
| "Ref": "LambdaSharpCoreLoggingStreamRole" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "Ref": "LambdaSharpCoreLoggingStreamRole" | |
| } | |
| ] | |
| }, | |
| { | |
| "Ref": "AWS::NoValue" | |
| } | |
| ] | |
| } | |
| } | |
| }, | |
| "MessageFunctionRegistration": { | |
| "Type": "Custom::LambdaSharpRegistrationFunction", | |
| "Condition": "UseCoreServices", | |
| "Properties": { | |
| "ServiceToken": { | |
| "Fn::ImportValue": { | |
| "Fn::Sub": "${DeploymentPrefix}LambdaSharp::Registration::Function" | |
| } | |
| }, | |
| "ResourceType": "LambdaSharp::Registration::Function", | |
| "ModuleId": { | |
| "Ref": "AWS::StackName" | |
| }, | |
| "FunctionId": { | |
| "Ref": "MessageFunction" | |
| }, | |
| "FunctionName": "MessageFunction", | |
| "FunctionLogGroupName": { | |
| "Fn::Sub": "/aws/lambda/${MessageFunction}" | |
| }, | |
| "FunctionPlatform": "AWS Lambda", | |
| "FunctionFramework": "dotnetcore3.1", | |
| "FunctionLanguage": "csharp", | |
| "FunctionMaxMemory": "256", | |
| "FunctionMaxDuration": "30" | |
| }, | |
| "DependsOn": [ | |
| "ModuleRegistration" | |
| ] | |
| }, | |
| "MessageFunctionLogGroupSubscription": { | |
| "Type": "AWS::Logs::SubscriptionFilter", | |
| "Condition": "UseCoreServices", | |
| "Properties": { | |
| "DestinationArn": { | |
| "Fn::If": [ | |
| "UseCoreServices", | |
| { | |
| "Fn::If": [ | |
| "LambdaSharpCoreLoggingStreamIsImported", | |
| { | |
| "Fn::ImportValue": { | |
| "Fn::Sub": [ | |
| "${DeploymentPrefix}${Import}", | |
| { | |
| "Import": { | |
| "Fn::Select": [ | |
| "1", | |
| { | |
| "Fn::Split": [ | |
| "$", | |
| { | |
| "Ref": "LambdaSharpCoreLoggingStream" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "Ref": "LambdaSharpCoreLoggingStream" | |
| } | |
| ] | |
| }, | |
| { | |
| "Ref": "AWS::NoValue" | |
| } | |
| ] | |
| }, | |
| "FilterPattern": "-\"*** \"", | |
| "LogGroupName": { | |
| "Ref": "MessageFunctionLogGroup" | |
| }, | |
| "RoleArn": { | |
| "Fn::If": [ | |
| "UseCoreServices", | |
| { | |
| "Fn::If": [ | |
| "LambdaSharpCoreLoggingStreamRoleIsImported", | |
| { | |
| "Fn::ImportValue": { | |
| "Fn::Sub": [ | |
| "${DeploymentPrefix}${Import}", | |
| { | |
| "Import": { | |
| "Fn::Select": [ | |
| "1", | |
| { | |
| "Fn::Split": [ | |
| "$", | |
| { | |
| "Ref": "LambdaSharpCoreLoggingStreamRole" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "Ref": "LambdaSharpCoreLoggingStreamRole" | |
| } | |
| ] | |
| }, | |
| { | |
| "Ref": "AWS::NoValue" | |
| } | |
| ] | |
| } | |
| } | |
| }, | |
| "ModuleWebSocket": { | |
| "Type": "AWS::ApiGatewayV2::Api", | |
| "Properties": { | |
| "Name": { | |
| "Fn::Sub": "${AWS::StackName} Module WebSocket" | |
| }, | |
| "ProtocolType": "WEBSOCKET", | |
| "Description": "Sample.WebSockets WebSocket (v1.0-DEV)", | |
| "RouteSelectionExpression": "$request.body.action" | |
| } | |
| }, | |
| "ConnectionFunctionWebSocketIntegration": { | |
| "Type": "AWS::ApiGatewayV2::Integration", | |
| "Properties": { | |
| "ApiId": { | |
| "Ref": "ModuleWebSocket" | |
| }, | |
| "Description": "WebSocket Integration for 'ConnectionFunction'", | |
| "IntegrationType": "AWS_PROXY", | |
| "IntegrationUri": { | |
| "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ConnectionFunction.Arn}/invocations" | |
| }, | |
| "PassthroughBehavior": "WHEN_NO_TEMPLATES" | |
| } | |
| }, | |
| "ConnectionFunctionConnectRoute": { | |
| "Type": "AWS::ApiGatewayV2::Route", | |
| "Properties": { | |
| "ApiId": { | |
| "Ref": "ModuleWebSocket" | |
| }, | |
| "RouteKey": "$connect", | |
| "AuthorizationType": "NONE", | |
| "Target": { | |
| "Fn::Sub": "integrations/${ConnectionFunctionWebSocketIntegration}" | |
| } | |
| } | |
| }, | |
| "ConnectionFunctionWebSocketPermission": { | |
| "Type": "AWS::Lambda::Permission", | |
| "Properties": { | |
| "Action": "lambda:InvokeFunction", | |
| "FunctionName": { | |
| "Ref": "ConnectionFunction" | |
| }, | |
| "Principal": "apigateway.amazonaws.com", | |
| "SourceArn": { | |
| "Fn::Sub": "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ModuleWebSocket}/LATEST/*" | |
| } | |
| } | |
| }, | |
| "ConnectionFunctionDisconnectRoute": { | |
| "Type": "AWS::ApiGatewayV2::Route", | |
| "Properties": { | |
| "ApiId": { | |
| "Ref": "ModuleWebSocket" | |
| }, | |
| "RouteKey": "$disconnect", | |
| "AuthorizationType": "NONE", | |
| "Target": { | |
| "Fn::Sub": "integrations/${ConnectionFunctionWebSocketIntegration}" | |
| } | |
| } | |
| }, | |
| "MessageFunctionWebSocketIntegration": { | |
| "Type": "AWS::ApiGatewayV2::Integration", | |
| "Properties": { | |
| "ApiId": { | |
| "Ref": "ModuleWebSocket" | |
| }, | |
| "Description": "WebSocket Integration for 'MessageFunction'", | |
| "IntegrationType": "AWS_PROXY", | |
| "IntegrationUri": { | |
| "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MessageFunction.Arn}/invocations" | |
| }, | |
| "PassthroughBehavior": "WHEN_NO_TEMPLATES" | |
| } | |
| }, | |
| "MessageFunctionDefaultRoute": { | |
| "Type": "AWS::ApiGatewayV2::Route", | |
| "Properties": { | |
| "ApiId": { | |
| "Ref": "ModuleWebSocket" | |
| }, | |
| "RouteKey": "$default", | |
| "AuthorizationType": "NONE", | |
| "Target": { | |
| "Fn::Sub": "integrations/${MessageFunctionWebSocketIntegration}" | |
| } | |
| } | |
| }, | |
| "MessageFunctionWebSocketPermission": { | |
| "Type": "AWS::Lambda::Permission", | |
| "Properties": { | |
| "Action": "lambda:InvokeFunction", | |
| "FunctionName": { | |
| "Ref": "MessageFunction" | |
| }, | |
| "Principal": "apigateway.amazonaws.com", | |
| "SourceArn": { | |
| "Fn::Sub": "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ModuleWebSocket}/LATEST/*" | |
| } | |
| } | |
| }, | |
| "MessageFunctionSendRoute": { | |
| "Type": "AWS::ApiGatewayV2::Route", | |
| "Properties": { | |
| "ApiId": { | |
| "Ref": "ModuleWebSocket" | |
| }, | |
| "RouteKey": "send", | |
| "AuthorizationType": "NONE", | |
| "Target": { | |
| "Fn::Sub": "integrations/${MessageFunctionWebSocketIntegration}" | |
| } | |
| } | |
| }, | |
| "ModuleWebSocketDeployment0AD1D65879DDB5B7294C652C9B4E6C6A": { | |
| "Type": "AWS::ApiGatewayV2::Deployment", | |
| "Properties": { | |
| "ApiId": { | |
| "Ref": "ModuleWebSocket" | |
| }, | |
| "Description": { | |
| "Fn::Sub": "${AWS::StackName} WebSocket [0AD1D65879DDB5B7294C652C9B4E6C6A]" | |
| } | |
| }, | |
| "DependsOn": [ | |
| "ConnectionFunctionConnectRoute", | |
| "ConnectionFunctionDisconnectRoute", | |
| "ConnectionFunctionWebSocketIntegration", | |
| "MessageFunctionDefaultRoute", | |
| "MessageFunctionSendRoute", | |
| "MessageFunctionWebSocketIntegration" | |
| ] | |
| }, | |
| "ModuleWebSocketLogGroup": { | |
| "Type": "AWS::Logs::LogGroup", | |
| "Properties": { | |
| "RetentionInDays": 30 | |
| } | |
| }, | |
| "ModuleWebSocketStage": { | |
| "Type": "AWS::ApiGatewayV2::Stage", | |
| "Properties": { | |
| "AccessLogSettings": { | |
| "DestinationArn": { | |
| "Fn::Sub": "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:${ModuleWebSocketLogGroup}" | |
| }, | |
| "Format": "{\"requestId\":\"$context.requestId\",\"extendedRequestId\":\"$context.extendedRequestId\",\"ip\":\"$context.identity.sourceIp\",\"caller\":\"$context.identity.caller\",\"user\":\"$context.identity.user\",\"apiKeyId\":\"$context.identity.apiKeyId\",\"domainName\":\"$context.domainName\",\"requestTime\":\"$context.requestTime\",\"eventType\":\"$context.eventType\",\"apiId\":\"$context.apiId\",\"stage\":\"$context.stage\",\"connectionId\":\"$context.connectionId\",\"route\":\"$context.routeKey\",\"error\":\"$context.error.message\"}" | |
| }, | |
| "ApiId": { | |
| "Ref": "ModuleWebSocket" | |
| }, | |
| "StageName": "LATEST", | |
| "Description": "Module WebSocket LATEST Stage", | |
| "DeploymentId": { | |
| "Ref": "ModuleWebSocketDeployment0AD1D65879DDB5B7294C652C9B4E6C6A" | |
| } | |
| }, | |
| "DependsOn": [ | |
| "ModuleWebSocketLogGroup" | |
| ] | |
| } | |
| }, | |
| "Outputs": { | |
| "WebSocketUrl": { | |
| "Value": { | |
| "Fn::Sub": "wss://${ModuleWebSocket}.execute-api.${AWS::Region}.${AWS::URLSuffix}/LATEST" | |
| }, | |
| "Export": { | |
| "Name": { | |
| "Fn::Sub": "${AWS::StackName}::WebSocketUrl" | |
| } | |
| }, | |
| "Description": "WebSocket URL" | |
| }, | |
| "ModuleInfo": { | |
| "Value": "Sample.WebSockets:1.0-DEV@<%MODULE_ORIGIN%>" | |
| }, | |
| "ModuleChecksum": { | |
| "Value": { | |
| "Ref": "DeploymentChecksum" | |
| } | |
| }, | |
| "LambdaSharpTool": { | |
| "Value": "0.8.0.2" | |
| }, | |
| "LambdaSharpTier": { | |
| "Value": { | |
| "Fn::Select": [ | |
| "0", | |
| { | |
| "Fn::Split": [ | |
| "-", | |
| { | |
| "Ref": "DeploymentPrefix" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } | |
| }, | |
| "Conditions": { | |
| "XRayIsEnabled": { | |
| "Fn::Not": [ | |
| { | |
| "Fn::Equals": [ | |
| { | |
| "Ref": "XRayTracing" | |
| }, | |
| "Disabled" | |
| ] | |
| } | |
| ] | |
| }, | |
| "UseCoreServices": { | |
| "Fn::Equals": [ | |
| { | |
| "Ref": "LambdaSharpCoreServices" | |
| }, | |
| "Enabled" | |
| ] | |
| }, | |
| "LambdaSharpCoreDeadLetterQueueIsImported": { | |
| "Fn::And": [ | |
| { | |
| "Fn::Not": [ | |
| { | |
| "Fn::Equals": [ | |
| { | |
| "Ref": "LambdaSharpCoreDeadLetterQueue" | |
| }, | |
| "" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "Fn::Equals": [ | |
| { | |
| "Fn::Select": [ | |
| "0", | |
| { | |
| "Fn::Split": [ | |
| "$", | |
| { | |
| "Ref": "LambdaSharpCoreDeadLetterQueue" | |
| } | |
| ] | |
| } | |
| ] | |
| }, | |
| "" | |
| ] | |
| } | |
| ] | |
| }, | |
| "LambdaSharpCoreLoggingStreamIsImported": { | |
| "Fn::And": [ | |
| { | |
| "Fn::Not": [ | |
| { | |
| "Fn::Equals": [ | |
| { | |
| "Ref": "LambdaSharpCoreLoggingStream" | |
| }, | |
| "" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "Fn::Equals": [ | |
| { | |
| "Fn::Select": [ | |
| "0", | |
| { | |
| "Fn::Split": [ | |
| "$", | |
| { | |
| "Ref": "LambdaSharpCoreLoggingStream" | |
| } | |
| ] | |
| } | |
| ] | |
| }, | |
| "" | |
| ] | |
| } | |
| ] | |
| }, | |
| "LambdaSharpCoreLoggingStreamRoleIsImported": { | |
| "Fn::And": [ | |
| { | |
| "Fn::Not": [ | |
| { | |
| "Fn::Equals": [ | |
| { | |
| "Ref": "LambdaSharpCoreLoggingStreamRole" | |
| }, | |
| "" | |
| ] | |
| } | |
| ] | |
| }, | |
| { | |
| "Fn::Equals": [ | |
| { | |
| "Fn::Select": [ | |
| "0", | |
| { | |
| "Fn::Split": [ | |
| "$", | |
| { | |
| "Ref": "LambdaSharpCoreLoggingStreamRole" | |
| } | |
| ] | |
| } | |
| ] | |
| }, | |
| "" | |
| ] | |
| } | |
| ] | |
| }, | |
| "ModuleRoleSecretsPolicyCondition": { | |
| "Fn::Not": [ | |
| { | |
| "Fn::Equals": [ | |
| { | |
| "Ref": "Secrets" | |
| }, | |
| "" | |
| ] | |
| } | |
| ] | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment