Skip to content

Commit 0e9887e

Browse files
committed
feat: updated Pipes implementation
1 parent fe1af6f commit 0e9887e

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

unicorn_contracts/template.yaml

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: MIT-0
3-
AWSTemplateFormatVersion: 2010-09-09
3+
AWSTemplateFormatVersion: "2010-09-09"
44
Transform:
55
- AWS::LanguageExtensions
66
- AWS::Serverless-2016-10-31
@@ -15,7 +15,7 @@ Metadata:
1515
- ES6000 # Rule disabled because SQS DLQs don't need a RedrivePolicy
1616
- WS2001 # Rule disabled because check does not support !ToJsonString transform
1717
- ES1001 # Rule disabled because our Lambda functions don't need DestinationConfig.OnFailure
18-
- W3002 # Rule disabled as nested templates are being packaged
18+
- W3002 # Rule disabled as nested templates are being packaged
1919

2020
Parameters:
2121
Stage:
@@ -360,29 +360,37 @@ Resources:
360360
SourceParameters:
361361
DynamoDBStreamParameters:
362362
MaximumRetryAttempts: 3
363+
BatchSize: 1
364+
StartingPosition: LATEST
363365
DeadLetterConfig:
364366
Arn: !GetAtt ContractsTableStreamToEventPipeDLQ.Arn
365-
StartingPosition: LATEST
366-
OnPartialBatchItemFailure: AUTOMATIC_BISECT
367-
BatchSize: 1
368367
FilterCriteria:
369368
Filters:
370-
- Pattern: !ToJsonString
371-
eventName: [INSERT, MODIFY]
372-
dynamodb:
373-
NewImage:
374-
contract_status:
375-
S: [DRAFT, APPROVED]
376-
Target: !GetAtt UnicornContractsEventBus.Arn
369+
- Pattern: >-
370+
{"eventName":["INSERT","MODIFY"],"dynamodb":{"NewImage":{"contract_status":{"S":["DRAFT","APPROVED"]}}}}
371+
LogConfiguration:
372+
CloudwatchLogsLogDestination:
373+
LogGroupArn: !GetAtt ContractsTableStreamToEventPipeLogGroup.Arn
374+
Level: ERROR
377375
TargetParameters:
378376
EventBridgeEventBusParameters:
379-
Source: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
380377
DetailType: ContractStatusChanged
381-
InputTemplate: !ToJsonString
382-
property_id: "<$.dynamodb.NewImage.property_id.S>"
383-
contract_id: "<$.dynamodb.NewImage.contract_id.S>"
384-
contract_status: "<$.dynamodb.NewImage.contract_status.S>"
385-
contract_last_modified_on: "<$.dynamodb.NewImage.contract_last_modified_on.S>"
378+
Source: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
379+
InputTemplate: |-
380+
{
381+
"property_id": "<$.dynamodb.Keys.property_id.S>",
382+
"contract_id": "<$.dynamodb.NewImage.contract_id.S>",
383+
"contract_status": "<$.dynamodb.NewImage.contract_status.S>",
384+
"contract_last_modified_on": "<$.dynamodb.NewImage.contract_last_modified_on.S>"
385+
}
386+
Target: !GetAtt UnicornContractsEventBus.Arn
387+
388+
ContractsTableStreamToEventPipeLogGroup:
389+
Type: AWS::Logs::LogGroup
390+
UpdateReplacePolicy: Delete
391+
DeletionPolicy: Delete
392+
Properties:
393+
RetentionInDays: !FindInMap [LogsRetentionPeriodMap, !Ref Stage, Days]
386394

387395
# IAM Role for Event Bridge Pipe
388396
ContractsTableStreamToEventPipeRole:
@@ -394,6 +402,9 @@ Resources:
394402
Effect: Allow
395403
Principal:
396404
Service: pipes.amazonaws.com
405+
Condition:
406+
StringEquals:
407+
aws:SourceAccount: !Ref AWS::AccountId
397408
Policies:
398409
- PolicyName: ContractsTableStreamToEventPipePolicy
399410
PolicyDocument:
@@ -408,6 +419,7 @@ Resources:
408419
- dynamodb:DescribeStream
409420
- dynamodb:GetRecords
410421
- dynamodb:GetShardIterator
422+
- dynamodb:ListStreams
411423
Resource: !GetAtt ContractsTable.StreamArn
412424
- Effect: Allow
413425
Action:

0 commit comments

Comments
 (0)