Skip to content

Commit b2aab7a

Browse files
committed
feat: updated pipes implementation
1 parent f9c9763 commit b2aab7a

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

Unicorn.Contracts/template.yaml

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
ContractStatus:
375-
S: [DRAFT, APPROVED]
376-
Target: !GetAtt UnicornContractsEventBus.Arn
369+
- Pattern: >-
370+
{"eventName":["INSERT","MODIFY"],"dynamodb":{"NewImage":{"ContractStatus":{"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-
PropertyId: "<$.dynamodb.NewImage.PropertyId.S>"
383-
ContractId: "<$.dynamodb.NewImage.ContractId.S>"
384-
ContractStatus: "<$.dynamodb.NewImage.ContractStatus.S>"
385-
ContractLastModifiedOn: "<$.dynamodb.NewImage.ContractLastModifiedOn.S>"
378+
Source: "{{resolve:ssm:/uni-prop/UnicornContractsNamespace}}"
379+
InputTemplate: |-
380+
{
381+
"PropertyId": "<$.dynamodb.Keys.PropertyId.S>",
382+
"ContractId": "<$.dynamodb.NewImage.ContractId.S>",
383+
"ContractStatus": "<$.dynamodb.NewImage.ContractStatus.S>",
384+
"ContractLastModifiedOn": "<$.dynamodb.NewImage.ContractLastModifiedOn.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)