Skip to content

Commit 9ce1aeb

Browse files
committed
Move fixity state machine and trigger lambda to infrastructure
1 parent 9688bc9 commit 9ce1aeb

5 files changed

Lines changed: 1414 additions & 0 deletions

File tree

core/.terraform.lock.hcl

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixity/execute-fixity/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { SFNClient, StartExecutionCommand } = require("@aws-sdk/client-sfn");
2+
const stateMachineArn = process.env.stateMachineArn;
3+
4+
const fullyDecode = (str) => decodeURIComponent(str.replace(/\+/g, " "));
5+
6+
exports.handler = (event, context, callback) => {
7+
var params = {
8+
stateMachineArn: stateMachineArn,
9+
input: JSON.stringify({
10+
Bucket: fullyDecode(event.Records[0].s3.bucket.name),
11+
Key: fullyDecode(event.Records[0].s3.object.key),
12+
}),
13+
};
14+
var stepfunctions = new SFNClient();
15+
const cmd = new StartExecutionCommand(params);
16+
return new Promise((resolve, _reject) => {
17+
stepfunctions.send(cmd)
18+
.then((data) => {
19+
console.log(data);
20+
resolve({
21+
statusCode: 200,
22+
body: JSON.stringify({
23+
message: "Step function worked",
24+
}),
25+
});
26+
})
27+
.catch((err) => {
28+
console.log(err);
29+
resolve({
30+
statusCode: 500,
31+
body: JSON.stringify({
32+
message: "There was an error",
33+
}),
34+
});
35+
});
36+
});
37+
};

0 commit comments

Comments
 (0)