Skip to content

Commit

Permalink
Revert "feature(cb2-11817): sns/sqs and event bridge for tech records (
Browse files Browse the repository at this point in the history
  • Loading branch information
naathanbrown authored Jun 3, 2024
1 parent 37002b9 commit 5427b65
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 1,107 deletions.
19 changes: 7 additions & 12 deletions src/functions/process-stream-event.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { _Record } from '@aws-sdk/client-dynamodb-streams';
import type {
Context,
DynamoDBRecord,
Expand All @@ -7,13 +6,12 @@ import type {
SQSEvent,
StreamRecord,
} from 'aws-lambda';
import { BatchItemFailuresResponse } from '../models/batch-item-failure-response';
import { destroyConnectionPool } from '../services/connection-pool';
import { DynamoDbImage } from '../services/dynamodb-images';
import { convert } from '../services/entity-conversion';
import { DynamoDbImage } from '../services/dynamodb-images';
import { deriveSqlOperation, SqlOperation } from '../services/sql-operations';
import { destroyConnectionPool } from '../services/connection-pool';
import { debugLog } from '../services/logger';
import { SqlOperation, deriveSqlOperation } from '../services/sql-operations';
import { transformTechRecord } from '../utils/transform-tech-record';
import { BatchItemFailuresResponse } from '../models/batch-item-failure-response';

/**
* λ function: convert a DynamoDB document to Aurora RDS rows
Expand Down Expand Up @@ -44,7 +42,9 @@ export const processStreamEvent: Handler = async (

for await (const record of event.Records) {
const id = record.messageId;
const dynamoRecord: DynamoDBRecord = JSON.parse(JSON.parse(record.body).Message) as DynamoDBRecord;
const dynamoRecord: DynamoDBRecord = JSON.parse(
record.body,
) as DynamoDBRecord;

debugLog('Original DynamoDB stream event body (parsed): ', dynamoRecord);

Expand All @@ -55,11 +55,6 @@ export const processStreamEvent: Handler = async (
dynamoRecord.eventSourceARN!,
);

if (tableName.includes('flat-tech-records')) {
transformTechRecord(dynamoRecord as _Record);
debugLog(`Dynamo Record after transformation: ${dynamoRecord}`);
}

// is this an INSERT, UPDATE, or DELETE?
const operationType: SqlOperation = deriveSqlOperation(
dynamoRecord.eventName!,
Expand Down
73 changes: 0 additions & 73 deletions src/utils/transform-tech-record.ts

This file was deleted.

116 changes: 50 additions & 66 deletions tests/integration/auth-into-service-document-conversion.intTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,12 @@ describe('convertTechRecordDocument() integration tests', () => {
Records: [
{
body: JSON.stringify({
Message: JSON.stringify({
eventSourceARN:
"arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000",
eventName: "INSERT",
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
})
eventSourceARN:
'arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000',
eventName: 'INSERT',
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
}),
},
],
Expand Down Expand Up @@ -166,14 +164,12 @@ describe('convertTechRecordDocument() integration tests', () => {
Records: [
{
body: JSON.stringify({
Message: JSON.stringify({
eventSourceARN:
"arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000",
eventName: "INSERT",
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
}),
eventSourceARN:
'arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000',
eventName: 'INSERT',
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
}),
},
],
Expand Down Expand Up @@ -244,14 +240,12 @@ describe('convertTechRecordDocument() integration tests', () => {
Records: [
{
body: JSON.stringify({
Message: JSON.stringify({
eventSourceARN:
"arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000",
eventName: "INSERT",
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
}),
eventSourceARN:
'arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000',
eventName: 'INSERT',
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
}),
},
],
Expand Down Expand Up @@ -301,14 +295,12 @@ describe('convertTechRecordDocument() integration tests', () => {
Records: [
{
body: JSON.stringify({
Message: JSON.stringify({
eventSourceARN:
"arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000",
eventName: "INSERT",
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
}),
eventSourceARN:
'arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000',
eventName: 'INSERT',
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
}),
},
],
Expand Down Expand Up @@ -383,14 +375,12 @@ describe('convertTechRecordDocument() integration tests', () => {
Records: [
{
body: JSON.stringify({
Message: JSON.stringify({
eventSourceARN:
"arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000",
eventName: "INSERT",
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
})
eventSourceARN:
'arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000',
eventName: 'INSERT',
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
}),
},
],
Expand Down Expand Up @@ -443,14 +433,12 @@ describe('convertTechRecordDocument() integration tests', () => {
Records: [
{
body: JSON.stringify({
Message: JSON.stringify({
eventSourceARN:
"arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000",
eventName: "INSERT",
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
}),
eventSourceARN:
'arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000',
eventName: 'INSERT',
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
}),
},
],
Expand Down Expand Up @@ -505,14 +493,12 @@ describe('convertTechRecordDocument() integration tests', () => {
Records: [
{
body: JSON.stringify({
Message: JSON.stringify({
eventSourceARN:
"arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000",
eventName: "INSERT",
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
}),
eventSourceARN:
'arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000',
eventName: 'INSERT',
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
}),
},
],
Expand Down Expand Up @@ -586,16 +572,14 @@ describe('convertTechRecordDocument() integration tests', () => {
const event = {
Records: [
{
body: JSON.stringify( {
Message: JSON.stringify({
eventSourceARN:
"arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000",
eventName: "INSERT",
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
}),
})
body: JSON.stringify({
eventSourceARN:
'arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000',
eventName: 'INSERT',
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
}),
},
],
};
Expand Down
42 changes: 18 additions & 24 deletions tests/integration/tech-record-document-conversion.intTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ describe('convertTechRecordDocument() integration tests', () => {
Records: [
{
body: JSON.stringify({
Message: JSON.stringify({
eventSourceARN:
"arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000",
eventName: "INSERT",
dynamodb: {
NewImage: techRecordDocumentJson,
},
})
eventSourceARN:
'arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000',
eventName: 'INSERT',
dynamodb: {
NewImage: techRecordDocumentJson,
},
}),
},
],
Expand Down Expand Up @@ -606,14 +604,12 @@ describe('convertTechRecordDocument() integration tests', () => {
Records: [
{
body: JSON.stringify({
Message: JSON.stringify({
eventSourceARN:
"arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000",
eventName: "INSERT",
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
})
eventSourceARN:
'arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000',
eventName: 'INSERT',
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
}),
},
],
Expand Down Expand Up @@ -654,14 +650,12 @@ describe('convertTechRecordDocument() integration tests', () => {
Records: [
{
body: JSON.stringify({
Message: JSON.stringify({
eventSourceARN:
"arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000",
eventName: "INSERT",
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
})
eventSourceARN:
'arn:aws:dynamodb:eu-west-1:1:table/technical-records/stream/2020-01-01T00:00:00.000',
eventName: 'INSERT',
dynamodb: {
NewImage: techRecordDocumentJsonNew,
},
}),
},
],
Expand Down
Loading

0 comments on commit 5427b65

Please sign in to comment.