@justworkflowit/cdk-constructs 0.0.2 → 0.0.5

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.
@@ -1,4 +1,8 @@
1
1
  import { Construct } from 'constructs';
2
+ export interface JustWorkflowItConstructProps {
3
+ disambiguator: string;
4
+ }
2
5
  export declare class JustWorkflowItConstruct extends Construct {
3
- constructor(scope: Construct, id: string);
6
+ private static readonly CONSTRUCT_ID_PREFIX;
7
+ constructor(scope: Construct, props: JustWorkflowItConstructProps);
4
8
  }
@@ -6,31 +6,51 @@ 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
- constructor(scope, id) {
11
- super(scope, id);
11
+ constructor(scope, props) {
12
+ super(scope, `${JustWorkflowItConstruct.CONSTRUCT_ID_PREFIX}${props.disambiguator}`);
13
+ const secretName = '/justworkflowit/api/authToken';
12
14
  const secret = new aws_secretsmanager_1.Secret(this, 'JustWorkflowItAuthTokenSecret', {
13
- secretName: '/justworkflowit/api/authToken',
15
+ secretName,
16
+ secretStringValue: aws_cdk_lib_1.SecretValue.unsafePlainText('REPLACE_ME_WITH_JUST_WORKFLOW_IT_AUTH_TOKEN'),
14
17
  description: 'Paste your JustWorkflowIt API auth token here to enable secure communication.',
15
18
  });
16
- const integrationLambda = new aws_lambda_1.Function(this, 'IntegrationLambda', {
19
+ const integrationLambda = new aws_lambda_1.Function(this, 'JustWorkflowItAutomationIntegrationLambda', {
20
+ functionName: 'JustWorkflowItAutomationIntegrationLambda',
17
21
  runtime: aws_lambda_1.Runtime.NODEJS_18_X,
18
22
  handler: 'index.handler',
19
23
  code: aws_lambda_1.Code.fromInline(`
20
- exports.handler = async () => {
21
- console.log("Integration Lambda triggered.");
24
+ exports.handler = async (event) => {
25
+ console.log("Custom Resource event:", JSON.stringify(event));
26
+ try {
27
+ // Put real logic here
28
+ console.log("Integration Lambda triggered.");
29
+ return {
30
+ PhysicalResourceId: 'JustWorkflowItIntegrationTrigger'
31
+ };
32
+ } catch (err) {
33
+ console.error("Failure:", err);
34
+ throw err;
35
+ }
22
36
  };
23
37
  `),
24
38
  timeout: aws_cdk_lib_1.Duration.seconds(10),
25
39
  environment: {
26
- AUTH_SECRET_NAME: '/justworkflowit/api/authToken',
40
+ AUTH_SECRET_NAME: secretName,
27
41
  API_BASE_URL: 'https://api.justworkflowit.com',
28
42
  },
29
43
  });
30
44
  secret.grantRead(integrationLambda);
31
- const executionRole = new aws_iam_1.Role(this, 'JustWorkflowItExecutionRole', {
32
- roleName: 'JustWorkflowItExecutionRole',
33
- assumedBy: new aws_iam_1.AccountPrincipal('588738588052'), // <-- Replace this with your actual account ID
45
+ const provider = new custom_resources_1.Provider(this, 'JustWorkflowItAutomationLambdaTriggerProvider', {
46
+ onEventHandler: integrationLambda,
47
+ });
48
+ new aws_cdk_lib_1.CustomResource(this, 'JustWorkflowItAutomationLambdaTrigger', {
49
+ serviceToken: provider.serviceToken,
50
+ });
51
+ const executionRole = new aws_iam_1.Role(this, 'JustWorkflowItAutomationExecutionRole', {
52
+ roleName: 'JustWorkflowItAutomationExecutionRole',
53
+ assumedBy: new aws_iam_1.AccountPrincipal('588738588052'),
34
54
  description: 'Role assumed by JustWorkflowIt backend to perform actions inside this account.',
35
55
  });
36
56
  executionRole.addToPolicy(new aws_iam_1.PolicyStatement({
@@ -48,3 +68,4 @@ class JustWorkflowItConstruct extends constructs_1.Construct {
48
68
  }
49
69
  }
50
70
  exports.JustWorkflowItConstruct = JustWorkflowItConstruct;
71
+ JustWorkflowItConstruct.CONSTRUCT_ID_PREFIX = "JustWorkflowItConstruct";
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@justworkflowit/cdk-constructs",
3
3
  "description": "",
4
- "version": "0.0.2",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
4
+ "version": "0.0.5",
5
+ "main": "dist/src/index.js",
6
+ "types": "dist/src/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
9
  "prepare": "npm run build",
@@ -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": {