diff --git a/examples/BatchProcessing/README.md b/examples/BatchProcessing/README.md index ebe87591..33844d58 100644 --- a/examples/BatchProcessing/README.md +++ b/examples/BatchProcessing/README.md @@ -33,7 +33,6 @@ You will need the following for local testing. To build and deploy your application for the first time, run the following in your shell. Make sure the `template.yaml` file is in your current directory: ```bash -cd deploy/sqs sam build sam deploy --guided ``` diff --git a/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj b/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj index 4ca084c0..8971ccf4 100644 --- a/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj +++ b/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj @@ -7,10 +7,8 @@ - - - - - + + + \ No newline at end of file diff --git a/examples/BatchProcessing/template-docker.yaml b/examples/BatchProcessing/template-docker.yaml deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/BatchProcessing/template.yaml b/examples/BatchProcessing/template.yaml index dab6dacf..937f1e75 100644 --- a/examples/BatchProcessing/template.yaml +++ b/examples/BatchProcessing/template.yaml @@ -111,6 +111,9 @@ Resources: FunctionResponseTypes: - ReportBatchItemFailures + # -------------- + # Batch Processing for DynamoDb + SampleDynamoDBTable: Type: AWS::DynamoDB::Table Properties: @@ -125,8 +128,41 @@ Resources: StreamSpecification: StreamViewType: NEW_AND_OLD_IMAGES + DemoDynamoDBStreamProcessorFunction: + Type: AWS::Serverless::Function + Properties: + FunctionName: powertools-dotnet-sample-batch-processor-dynamodb + CodeUri: ./src/HelloWorld/ + Handler: HelloWorld::HelloWorld.Function::DynamoDbStreamHandlerUsingAttribute + Policies: AWSLambdaDynamoDBExecutionRole + Events: + Stream: + Type: DynamoDB + Properties: + Stream: !GetAtt SampleDynamoDBTable.StreamArn + BatchSize: 100 + StartingPosition: TRIM_HORIZON + FunctionResponseTypes: + - ReportBatchItemFailures + # -------------- # Batch Processing for Kinesis Data Streams + + DemoKinesisStream: + Type: AWS::Kinesis::Stream + Properties: + ShardCount: 1 + StreamEncryption: + EncryptionType: KMS + KeyId: !Ref CustomerKey + + StreamConsumer: + Type: "AWS::Kinesis::StreamConsumer" + Properties: + StreamARN: !GetAtt DemoKinesisStream.Arn + ConsumerName: KinesisBatchHandlerConsumer + + SampleKinesisEventBatchProcessorFunction: Type: AWS::Serverless::Function Properties: @@ -135,15 +171,13 @@ Resources: CodeUri: ./src/HelloWorld/ Handler: HelloWorld::HelloWorld.Function::KinesisEventHandlerUsingAttribute MemorySize: 256 - # ReservedConcurrentExecutions: 1 - Policies: - - AWSLambdaBasicExecutionRole - - KinesisStreamReadPolicy: - StreamName: !Ref SampleKinesisDataStream - Environment: - Variables: - POWERTOOLS_BATCH_PROCESSING_ERROR_HANDLING_POLICY: DeriveFromEvent - POWERTOOLS_BATCH_PROCESSING_MAX_DEGREE_OF_PARALLELISM: 1 + Events: + Kinesis: + Type: Kinesis + Properties: + Stream: !GetAtt StreamConsumer.ConsumerARN + StartingPosition: LATEST + BatchSize: 2 Outputs: DemoSqsQueue: @@ -155,6 +189,9 @@ Outputs: SampleSqsBatchProcessorFunction: Description: "SQS Batch Handler - Lambda Function ARN" Value: !GetAtt SampleSqsBatchProcessorFunction.Arn - SampleSqsBatchProcessorFunctionRole: - Description: "Implicit IAM Role created for SQS Lambda Function ARN" - Value: !GetAtt SampleSqsBatchProcessorFunctionRole.Arn \ No newline at end of file + DemoKinesisQueue: + Description: "ARN for Kinesis Stream" + Value: !GetAtt DemoKinesisStream.Arn + DemoSQSConsumerFunction: + Description: "SQS Batch Handler - Lambda Function ARN" + Value: !GetAtt SampleKinesisEventBatchProcessorFunction.Arn \ No newline at end of file diff --git a/examples/BatchProcessing/test/HelloWorld.Test/HelloWorld.Tests.csproj b/examples/BatchProcessing/test/HelloWorld.Test/HelloWorld.Tests.csproj index 405dd8b1..6403301a 100644 --- a/examples/BatchProcessing/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ b/examples/BatchProcessing/test/HelloWorld.Test/HelloWorld.Tests.csproj @@ -6,10 +6,9 @@ - - + + - all diff --git a/examples/Logging/src/HelloWorld/HelloWorld.csproj b/examples/Logging/src/HelloWorld/HelloWorld.csproj index b57ab06b..6930178f 100644 --- a/examples/Logging/src/HelloWorld/HelloWorld.csproj +++ b/examples/Logging/src/HelloWorld/HelloWorld.csproj @@ -9,6 +9,6 @@ - + diff --git a/examples/Logging/test/HelloWorld.Test/HelloWorld.Tests.csproj b/examples/Logging/test/HelloWorld.Test/HelloWorld.Tests.csproj index 5c0d4503..31e123cf 100644 --- a/examples/Logging/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ b/examples/Logging/test/HelloWorld.Test/HelloWorld.Tests.csproj @@ -6,7 +6,7 @@ - + diff --git a/examples/Metrics/src/HelloWorld/HelloWorld.csproj b/examples/Metrics/src/HelloWorld/HelloWorld.csproj index 93b2dfc3..0d968bf4 100644 --- a/examples/Metrics/src/HelloWorld/HelloWorld.csproj +++ b/examples/Metrics/src/HelloWorld/HelloWorld.csproj @@ -10,6 +10,6 @@ - + diff --git a/examples/Metrics/test/HelloWorld.Test/HelloWorld.Tests.csproj b/examples/Metrics/test/HelloWorld.Test/HelloWorld.Tests.csproj index 5c0d4503..31e123cf 100644 --- a/examples/Metrics/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ b/examples/Metrics/test/HelloWorld.Test/HelloWorld.Tests.csproj @@ -6,7 +6,7 @@ - + diff --git a/examples/Tracing/src/HelloWorld/HelloWorld.csproj b/examples/Tracing/src/HelloWorld/HelloWorld.csproj index cc4abb91..9ff79ded 100644 --- a/examples/Tracing/src/HelloWorld/HelloWorld.csproj +++ b/examples/Tracing/src/HelloWorld/HelloWorld.csproj @@ -10,6 +10,6 @@ - + diff --git a/examples/Tracing/test/HelloWorld.Test/HelloWorld.Tests.csproj b/examples/Tracing/test/HelloWorld.Test/HelloWorld.Tests.csproj index 5c0d4503..31e123cf 100644 --- a/examples/Tracing/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ b/examples/Tracing/test/HelloWorld.Test/HelloWorld.Tests.csproj @@ -6,7 +6,7 @@ - + diff --git a/examples/examples.sln b/examples/examples.sln index 785094ee..6129546e 100644 --- a/examples/examples.sln +++ b/examples/examples.sln @@ -67,6 +67,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{E25EAD9C-E EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld.Tests", "Tracing\test\HelloWorld.Test\HelloWorld.Tests.csproj", "{A1E1C702-77D3-4279-9E42-2A18783A0586}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BatchProcessing", "BatchProcessing", "{2B5E8DE7-8DA4-47B8-81B7-9E269CC77619}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B95EAACA-FBE4-4CC0-B155-D0AD9BCDEE24}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "BatchProcessing\src\HelloWorld\HelloWorld.csproj", "{F33D0918-452F-4AB0-B842-E43AFE6F948D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{CE5C821F-5610-490F-B096-EE91F0E34C10}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld.Tests", "BatchProcessing\test\HelloWorld.Test\HelloWorld.Tests.csproj", "{AAE50681-1FEF-4D9E-9FEA-5406320BDB88}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -128,6 +138,14 @@ Global {A1E1C702-77D3-4279-9E42-2A18783A0586}.Debug|Any CPU.Build.0 = Debug|Any CPU {A1E1C702-77D3-4279-9E42-2A18783A0586}.Release|Any CPU.ActiveCfg = Release|Any CPU {A1E1C702-77D3-4279-9E42-2A18783A0586}.Release|Any CPU.Build.0 = Release|Any CPU + {F33D0918-452F-4AB0-B842-E43AFE6F948D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F33D0918-452F-4AB0-B842-E43AFE6F948D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F33D0918-452F-4AB0-B842-E43AFE6F948D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F33D0918-452F-4AB0-B842-E43AFE6F948D}.Release|Any CPU.Build.0 = Release|Any CPU + {AAE50681-1FEF-4D9E-9FEA-5406320BDB88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AAE50681-1FEF-4D9E-9FEA-5406320BDB88}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AAE50681-1FEF-4D9E-9FEA-5406320BDB88}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AAE50681-1FEF-4D9E-9FEA-5406320BDB88}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {0CC66DBC-C1DF-4AF6-8EEB-FFED6C578BF4} = {526F1EF7-5A9C-4BFF-ABAE-75992ACD8F78} @@ -156,5 +174,9 @@ Global {E3E9268B-5897-4A7D-BDC0-D5BF78269339} = {A5F586B6-DCE5-47A2-94B2-C8142A79BCF6} {E25EAD9C-E6DB-4F63-B7FA-7FB45AD0B09B} = {F5CAEA70-FF1A-4CCE-8928-D579AA7750BA} {A1E1C702-77D3-4279-9E42-2A18783A0586} = {E25EAD9C-E6DB-4F63-B7FA-7FB45AD0B09B} + {B95EAACA-FBE4-4CC0-B155-D0AD9BCDEE24} = {2B5E8DE7-8DA4-47B8-81B7-9E269CC77619} + {F33D0918-452F-4AB0-B842-E43AFE6F948D} = {B95EAACA-FBE4-4CC0-B155-D0AD9BCDEE24} + {CE5C821F-5610-490F-B096-EE91F0E34C10} = {2B5E8DE7-8DA4-47B8-81B7-9E269CC77619} + {AAE50681-1FEF-4D9E-9FEA-5406320BDB88} = {CE5C821F-5610-490F-B096-EE91F0E34C10} EndGlobalSection EndGlobal