@justworkflowit/cdk-constructs 0.0.38 → 0.0.39
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.
- package/dist/constructs/justWorkflowItConstructs.d.ts +10 -0
- package/dist/constructs/justWorkflowItConstructs.js +124 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/lambda/definitionDeployerLambda.d.ts +7 -0
- package/dist/lambda/definitionDeployerLambda.js +51304 -0
- package/dist/lambda/justWorkflowItApiClient.d.ts +4 -0
- package/dist/lambda/justWorkflowItApiClient.js +95 -0
- package/dist/lambda/justWorkflowItApiExceptions.d.ts +3 -0
- package/dist/lambda/justWorkflowItApiExceptions.js +70 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
export interface JustWorkflowItConstructsProps {
|
|
3
|
+
disambiguator: string;
|
|
4
|
+
organizationId: string;
|
|
5
|
+
workflowDefinitions: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare class JustWorkflowItConstructs extends Construct {
|
|
8
|
+
private static readonly CONSTRUCT_ID_PREFIX;
|
|
9
|
+
constructor(scope: Construct, props: JustWorkflowItConstructsProps);
|
|
10
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.JustWorkflowItConstructs = void 0;
|
|
37
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
38
|
+
const constructs_1 = require("constructs");
|
|
39
|
+
const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
|
|
40
|
+
const aws_iam_1 = require("aws-cdk-lib/aws-iam");
|
|
41
|
+
const aws_secretsmanager_1 = require("aws-cdk-lib/aws-secretsmanager");
|
|
42
|
+
const custom_resources_1 = require("aws-cdk-lib/custom-resources");
|
|
43
|
+
const aws_lambda_nodejs_1 = require("aws-cdk-lib/aws-lambda-nodejs");
|
|
44
|
+
const aws_s3_1 = require("aws-cdk-lib/aws-s3");
|
|
45
|
+
const aws_s3_deployment_1 = require("aws-cdk-lib/aws-s3-deployment");
|
|
46
|
+
const path = __importStar(require("path"));
|
|
47
|
+
const uuid_1 = require("uuid");
|
|
48
|
+
class JustWorkflowItConstructs extends constructs_1.Construct {
|
|
49
|
+
constructor(scope, props) {
|
|
50
|
+
super(scope, `${JustWorkflowItConstructs.CONSTRUCT_ID_PREFIX}${props.disambiguator}`);
|
|
51
|
+
const secretName = '/justworkflowit/api/authToken';
|
|
52
|
+
const secret = new aws_secretsmanager_1.Secret(this, 'JustWorkflowItAuthTokenSecret', {
|
|
53
|
+
secretName,
|
|
54
|
+
secretStringValue: aws_cdk_lib_1.SecretValue.unsafePlainText('REPLACE_ME_WITH_JUST_WORKFLOW_IT_AUTH_TOKEN'),
|
|
55
|
+
description: 'Paste your JustWorkflowIt API auth token here to enable secure communication.',
|
|
56
|
+
});
|
|
57
|
+
const bucket = new aws_s3_1.Bucket(this, 'WorkflowDefinitionsBucket', {
|
|
58
|
+
removalPolicy: aws_cdk_lib_1.RemovalPolicy.DESTROY,
|
|
59
|
+
autoDeleteObjects: true,
|
|
60
|
+
});
|
|
61
|
+
// Upload each definition and collect its S3 key
|
|
62
|
+
const definitionKeys = [];
|
|
63
|
+
const deploymentSources = [];
|
|
64
|
+
props.workflowDefinitions.forEach((definition, index) => {
|
|
65
|
+
const uuidKey = `definitions/${(0, uuid_1.v4)()}.json`;
|
|
66
|
+
definitionKeys.push(uuidKey);
|
|
67
|
+
deploymentSources.push(aws_s3_deployment_1.Source.data(uuidKey, definition));
|
|
68
|
+
});
|
|
69
|
+
const bucketDeployment = new aws_s3_deployment_1.BucketDeployment(this, 'WorkflowDefinitionUploads', {
|
|
70
|
+
sources: deploymentSources,
|
|
71
|
+
destinationBucket: bucket,
|
|
72
|
+
destinationKeyPrefix: 'definitions/',
|
|
73
|
+
});
|
|
74
|
+
const integrationLambda = new aws_lambda_nodejs_1.NodejsFunction(this, 'JustWorkflowItDefinitionDeployerLambda', {
|
|
75
|
+
functionName: `JustWorkflowItDefinitionDeployer-${props.disambiguator}`,
|
|
76
|
+
entry: path.join(__dirname, '../lambda/definitionDeployerLambda.js'),
|
|
77
|
+
handler: 'handler',
|
|
78
|
+
runtime: aws_lambda_1.Runtime.NODEJS_18_X,
|
|
79
|
+
timeout: aws_cdk_lib_1.Duration.minutes(5),
|
|
80
|
+
environment: {
|
|
81
|
+
AUTH_SECRET_NAME: secretName,
|
|
82
|
+
ORGANIZATION_ID: props.organizationId,
|
|
83
|
+
API_BASE_URL: 'https://api.justworkflowit.com',
|
|
84
|
+
DEFINITION_BUCKET: bucket.bucketName,
|
|
85
|
+
DEFINITION_KEYS_JSON: JSON.stringify(definitionKeys)
|
|
86
|
+
},
|
|
87
|
+
bundling: {
|
|
88
|
+
nodeModules: ['@justworkflowit/api-client'],
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
secret.grantRead(integrationLambda);
|
|
92
|
+
bucket.grantRead(integrationLambda);
|
|
93
|
+
const provider = new custom_resources_1.Provider(this, 'JustWorkflowItDefinitionDeployerTriggerProvider', {
|
|
94
|
+
onEventHandler: integrationLambda,
|
|
95
|
+
});
|
|
96
|
+
const resource = new aws_cdk_lib_1.CustomResource(this, 'JustWorkflowItDefinitionDeployerTrigger', {
|
|
97
|
+
serviceToken: provider.serviceToken,
|
|
98
|
+
properties: {
|
|
99
|
+
timestamp: new Date().toISOString(),
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
provider.node.addDependency(bucketDeployment);
|
|
103
|
+
resource.node.addDependency(bucketDeployment);
|
|
104
|
+
const executionRole = new aws_iam_1.Role(this, 'JustWorkflowItAutomationExecutionRole', {
|
|
105
|
+
roleName: `JustWorkflowItExecutionRole-${props.disambiguator}`,
|
|
106
|
+
assumedBy: new aws_iam_1.AccountPrincipal('588738588052'),
|
|
107
|
+
description: 'Role assumed by JustWorkflowIt backend to perform actions inside this account.',
|
|
108
|
+
});
|
|
109
|
+
executionRole.addToPolicy(new aws_iam_1.PolicyStatement({
|
|
110
|
+
actions: ['lambda:InvokeFunction'],
|
|
111
|
+
resources: ['*'],
|
|
112
|
+
}));
|
|
113
|
+
executionRole.addToPolicy(new aws_iam_1.PolicyStatement({
|
|
114
|
+
actions: ['sns:Publish'],
|
|
115
|
+
resources: ['*'],
|
|
116
|
+
}));
|
|
117
|
+
executionRole.addToPolicy(new aws_iam_1.PolicyStatement({
|
|
118
|
+
actions: ['sqs:SendMessage'],
|
|
119
|
+
resources: ['*'],
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.JustWorkflowItConstructs = JustWorkflowItConstructs;
|
|
124
|
+
JustWorkflowItConstructs.CONSTRUCT_ID_PREFIX = 'JustWorkflowItConstructs';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './constructs/justWorkflowItConstructs';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constructs/justWorkflowItConstructs"), exports);
|