|
| 1 | +{ |
| 2 | + "Resources": { |
| 3 | + "DynamoDBTable": { |
| 4 | + "Properties": { |
| 5 | + "AttributeDefinitions": [ |
| 6 | + { |
| 7 | + "AttributeName": "id", |
| 8 | + "AttributeType": "S" |
| 9 | + } |
| 10 | + ], |
| 11 | + "BillingMode": "PAY_PER_REQUEST", |
| 12 | + "KeySchema": [ |
| 13 | + { |
| 14 | + "AttributeName": "id", |
| 15 | + "KeyType": "HASH" |
| 16 | + } |
| 17 | + ] |
| 18 | + }, |
| 19 | + "Type": "AWS::DynamoDB::Table" |
| 20 | + }, |
| 21 | + "FilteredEventsFunction": { |
| 22 | + "Properties": { |
| 23 | + "Code": { |
| 24 | + "S3Bucket": "sam-demo-bucket", |
| 25 | + "S3Key": "metricsConfig.zip" |
| 26 | + }, |
| 27 | + "Handler": "index.handler", |
| 28 | + "Role": { |
| 29 | + "Fn::GetAtt": [ |
| 30 | + "FilteredEventsFunctionRole", |
| 31 | + "Arn" |
| 32 | + ] |
| 33 | + }, |
| 34 | + "Runtime": "nodejs16.x", |
| 35 | + "Tags": [ |
| 36 | + { |
| 37 | + "Key": "lambda:createdBy", |
| 38 | + "Value": "SAM" |
| 39 | + } |
| 40 | + ] |
| 41 | + }, |
| 42 | + "Type": "AWS::Lambda::Function" |
| 43 | + }, |
| 44 | + "FilteredEventsFunctionDynamoDBStreamEvent": { |
| 45 | + "Properties": { |
| 46 | + "EventSourceArn": { |
| 47 | + "Fn::GetAtt": [ |
| 48 | + "DynamoDBTable", |
| 49 | + "StreamArn" |
| 50 | + ] |
| 51 | + }, |
| 52 | + "FilterCriteria": { |
| 53 | + "Filters": [] |
| 54 | + }, |
| 55 | + "FunctionName": { |
| 56 | + "Ref": "FilteredEventsFunction" |
| 57 | + }, |
| 58 | + "MetricsConfig": { |
| 59 | + "Metrics": [] |
| 60 | + }, |
| 61 | + "StartingPosition": "TRIM_HORIZON" |
| 62 | + }, |
| 63 | + "Type": "AWS::Lambda::EventSourceMapping" |
| 64 | + }, |
| 65 | + "FilteredEventsFunctionKinesisStream": { |
| 66 | + "Properties": { |
| 67 | + "EventSourceArn": { |
| 68 | + "Fn::GetAtt": [ |
| 69 | + "KinesisStream", |
| 70 | + "Arn" |
| 71 | + ] |
| 72 | + }, |
| 73 | + "FilterCriteria": { |
| 74 | + "Filters": [ |
| 75 | + { |
| 76 | + "Pattern": "{\"name\": \"value\"}" |
| 77 | + }, |
| 78 | + { |
| 79 | + "Pattern": "{\"name2\": \"value2\"}" |
| 80 | + } |
| 81 | + ] |
| 82 | + }, |
| 83 | + "FunctionName": { |
| 84 | + "Ref": "FilteredEventsFunction" |
| 85 | + }, |
| 86 | + "MetricsConfig": { |
| 87 | + "Metrics": [ |
| 88 | + "EventCount" |
| 89 | + ] |
| 90 | + }, |
| 91 | + "StartingPosition": "LATEST" |
| 92 | + }, |
| 93 | + "Type": "AWS::Lambda::EventSourceMapping" |
| 94 | + }, |
| 95 | + "FilteredEventsFunctionMySqsQueue": { |
| 96 | + "Properties": { |
| 97 | + "EventSourceArn": { |
| 98 | + "Fn::GetAtt": [ |
| 99 | + "MySqsQueue", |
| 100 | + "Arn" |
| 101 | + ] |
| 102 | + }, |
| 103 | + "FilterCriteria": { |
| 104 | + "Filters": [ |
| 105 | + { |
| 106 | + "Pattern": "{\"name\": \"value\"}" |
| 107 | + } |
| 108 | + ] |
| 109 | + }, |
| 110 | + "FunctionName": { |
| 111 | + "Ref": "FilteredEventsFunction" |
| 112 | + }, |
| 113 | + "MetricsConfig": { |
| 114 | + "Metrics": [ |
| 115 | + "EventCount" |
| 116 | + ] |
| 117 | + } |
| 118 | + }, |
| 119 | + "Type": "AWS::Lambda::EventSourceMapping" |
| 120 | + }, |
| 121 | + "FilteredEventsFunctionRole": { |
| 122 | + "Properties": { |
| 123 | + "AssumeRolePolicyDocument": { |
| 124 | + "Statement": [ |
| 125 | + { |
| 126 | + "Action": [ |
| 127 | + "sts:AssumeRole" |
| 128 | + ], |
| 129 | + "Effect": "Allow", |
| 130 | + "Principal": { |
| 131 | + "Service": [ |
| 132 | + "lambda.amazonaws.com" |
| 133 | + ] |
| 134 | + } |
| 135 | + } |
| 136 | + ], |
| 137 | + "Version": "2012-10-17" |
| 138 | + }, |
| 139 | + "ManagedPolicyArns": [ |
| 140 | + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", |
| 141 | + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaDynamoDBExecutionRole", |
| 142 | + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaKinesisExecutionRole", |
| 143 | + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole" |
| 144 | + ], |
| 145 | + "Tags": [ |
| 146 | + { |
| 147 | + "Key": "lambda:createdBy", |
| 148 | + "Value": "SAM" |
| 149 | + } |
| 150 | + ] |
| 151 | + }, |
| 152 | + "Type": "AWS::IAM::Role" |
| 153 | + }, |
| 154 | + "KinesisStream": { |
| 155 | + "Properties": { |
| 156 | + "ShardCount": 1 |
| 157 | + }, |
| 158 | + "Type": "AWS::Kinesis::Stream" |
| 159 | + }, |
| 160 | + "MySqsQueue": { |
| 161 | + "Type": "AWS::SQS::Queue" |
| 162 | + } |
| 163 | + } |
| 164 | +} |
0 commit comments