stream_processor.yaml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. AWSTemplateFormatVersion: "2010-09-09"
  2. Transform: AWS::Serverless-2016-10-31
  3. Description: Amazon S3 Find and Forget Stream Processor
  4. Metadata:
  5. cfn-lint:
  6. config:
  7. ignore_checks:
  8. - E3002
  9. Globals:
  10. Function:
  11. Runtime: python3.9
  12. Timeout: 900
  13. Layers: !Ref CommonLayers
  14. Environment:
  15. Variables:
  16. DeletionQueueTable: !Ref DeletionQueueTableName
  17. GlueDatabase: !Ref GlueDatabase
  18. GSIBucketCount: "1"
  19. JobManifestsGlueTable: !Ref JobManifestsGlueTable
  20. JobTable: !Ref JobTableName
  21. JobTableDateGSI: !Ref JobTableDateGSI
  22. LogLevel: !Ref LogLevel
  23. StateMachineArn: !Ref StateMachineArn
  24. Parameters:
  25. CommonLayers:
  26. Type: CommaDelimitedList
  27. Description: Common layers supplied to all functions
  28. DeletionQueueTableName:
  29. Description: Table name for Deletion Queue Table
  30. Type: String
  31. GlueDatabase:
  32. Type: String
  33. JobManifestsGlueTable:
  34. Type: String
  35. JobTableDateGSI:
  36. Description: Date ordered GSI for Jobs Table
  37. Type: String
  38. JobTableName:
  39. Description: Table name for Jobs Table
  40. Type: String
  41. JobTableStreamArn:
  42. Description: Stream ARN for Jobs Table
  43. Type: String
  44. LogLevel:
  45. Type: String
  46. Default: INFO
  47. AllowedValues:
  48. - CRITICAL
  49. - FATAL
  50. - ERROR
  51. - WARNING
  52. - INFO
  53. - DEBUG
  54. - NOTSET
  55. ManifestsBucket:
  56. Type: String
  57. StateMachineArn:
  58. Description: State Machine to invoke to process the deletion queue
  59. Type: String
  60. Resources:
  61. StreamProcessor:
  62. Type: AWS::Serverless::Function
  63. Properties:
  64. Handler: stream_processor.handler
  65. CodeUri: ../backend/lambdas/jobs/
  66. MemorySize: 512
  67. Policies:
  68. - DynamoDBCrudPolicy:
  69. TableName: !Ref JobTableName
  70. - DynamoDBCrudPolicy:
  71. TableName: !Ref DeletionQueueTableName
  72. - Statement:
  73. - Effect: Allow
  74. Action:
  75. - "states:DescribeStateMachine"
  76. - "states:DescribeExecution"
  77. - "states:StartExecution"
  78. Resource: !Ref StateMachineArn
  79. - Effect: Allow
  80. Action: s3:GetObject*
  81. Resource: !Sub arn:${AWS::Partition}:s3:::${ManifestsBucket}/manifests/*
  82. - Effect: Allow
  83. Action: glue:BatchDeletePartition
  84. Resource:
  85. - !Sub "arn:${AWS::Partition}:glue:*:*:catalog*"
  86. - !Sub "arn:${AWS::Partition}:glue:*:*:database/${GlueDatabase}"
  87. - !Sub "arn:${AWS::Partition}:glue:*:*:table/${GlueDatabase}/${JobManifestsGlueTable}"
  88. Events:
  89. Stream:
  90. Type: DynamoDB
  91. Properties:
  92. Stream: !Ref JobTableStreamArn
  93. StartingPosition: TRIM_HORIZON
  94. BatchSize: 10
  95. MaximumBatchingWindowInSeconds: 5
  96. BisectBatchOnFunctionError: true
  97. ParallelizationFactor: 1
  98. MaximumRetryAttempts: 3
  99. MaximumRecordAgeInSeconds: 86400
  100. DestinationConfig:
  101. OnFailure:
  102. Type: SQS
  103. Destination: !GetAtt EventsDLQ.Arn
  104. EventsDLQ:
  105. Type: AWS::SQS::Queue
  106. Properties:
  107. KmsMasterKeyId: alias/aws/sqs