@justworkflowit/cdk-constructs 0.0.3 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,12 +6,14 @@ const constructs_1 = require("constructs");
|
|
|
6
6
|
const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
|
|
7
7
|
const aws_iam_1 = require("aws-cdk-lib/aws-iam");
|
|
8
8
|
const aws_secretsmanager_1 = require("aws-cdk-lib/aws-secretsmanager");
|
|
9
|
+
const custom_resources_1 = require("aws-cdk-lib/custom-resources");
|
|
9
10
|
class JustWorkflowItConstruct extends constructs_1.Construct {
|
|
10
11
|
constructor(scope, props) {
|
|
11
12
|
super(scope, `${JustWorkflowItConstruct.CONSTRUCT_ID_PREFIX}${props.disambiguator}`);
|
|
12
13
|
const secretName = '/justworkflowit/api/authToken';
|
|
13
14
|
const secret = new aws_secretsmanager_1.Secret(this, 'JustWorkflowItAuthTokenSecret', {
|
|
14
15
|
secretName,
|
|
16
|
+
secretStringValue: aws_cdk_lib_1.SecretValue.unsafePlainText('REPLACE_ME_WITH_JUST_WORKFLOW_IT_AUTH_TOKEN'),
|
|
15
17
|
description: 'Paste your JustWorkflowIt API auth token here to enable secure communication.',
|
|
16
18
|
});
|
|
17
19
|
const integrationLambda = new aws_lambda_1.Function(this, 'JustWorkflowItAutomationIntegrationLambda', {
|
|
@@ -19,10 +21,26 @@ class JustWorkflowItConstruct extends constructs_1.Construct {
|
|
|
19
21
|
runtime: aws_lambda_1.Runtime.NODEJS_18_X,
|
|
20
22
|
handler: 'index.handler',
|
|
21
23
|
code: aws_lambda_1.Code.fromInline(`
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
exports.handler = async (event) => {
|
|
25
|
+
console.log("Custom Resource event:", JSON.stringify(event, null, 2));
|
|
26
|
+
|
|
27
|
+
const requestType = event.RequestType;
|
|
28
|
+
if (requestType === 'Create') {
|
|
29
|
+
console.log("Handling CREATE...");
|
|
30
|
+
} else if (requestType === 'Update') {
|
|
31
|
+
console.log("Handling UPDATE...");
|
|
32
|
+
} else if (requestType === 'Delete') {
|
|
33
|
+
console.log("Handling DELETE...");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
PhysicalResourceId: 'JustWorkflowItIntegrationTrigger',
|
|
38
|
+
Data: {
|
|
39
|
+
Message: "Integration Lambda ran successfully"
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
`),
|
|
26
44
|
timeout: aws_cdk_lib_1.Duration.seconds(10),
|
|
27
45
|
environment: {
|
|
28
46
|
AUTH_SECRET_NAME: secretName,
|
|
@@ -30,6 +48,15 @@ class JustWorkflowItConstruct extends constructs_1.Construct {
|
|
|
30
48
|
},
|
|
31
49
|
});
|
|
32
50
|
secret.grantRead(integrationLambda);
|
|
51
|
+
const provider = new custom_resources_1.Provider(this, 'JustWorkflowItAutomationLambdaTriggerProvider', {
|
|
52
|
+
onEventHandler: integrationLambda,
|
|
53
|
+
});
|
|
54
|
+
new aws_cdk_lib_1.CustomResource(this, 'JustWorkflowItAutomationLambdaTrigger', {
|
|
55
|
+
serviceToken: provider.serviceToken,
|
|
56
|
+
properties: {
|
|
57
|
+
timestamp: new Date().toISOString()
|
|
58
|
+
}
|
|
59
|
+
});
|
|
33
60
|
const executionRole = new aws_iam_1.Role(this, 'JustWorkflowItAutomationExecutionRole', {
|
|
34
61
|
roleName: 'JustWorkflowItAutomationExecutionRole',
|
|
35
62
|
assumedBy: new aws_iam_1.AccountPrincipal('588738588052'),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justworkflowit/cdk-constructs",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.6",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -26,6 +26,14 @@
|
|
|
26
26
|
"eslint": "^9.29.0",
|
|
27
27
|
"prettier": "^3.6.2",
|
|
28
28
|
"ts-node": "^10.9.2",
|
|
29
|
+
"eslint-config-prettier": "^9.1.0",
|
|
30
|
+
"eslint-plugin-jest": "^28.10.0",
|
|
31
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
32
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
33
|
+
"eslint-plugin-testing-library": "^7.1.1",
|
|
34
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
35
|
+
"globals": "^15.15.0",
|
|
36
|
+
"typescript-eslint": "^8.24.1",
|
|
29
37
|
"typescript": "^5.8.3"
|
|
30
38
|
},
|
|
31
39
|
"peerDependencies": {
|