@webiny/pulumi-aws 5.40.6 → 5.41.0-beta.0

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.
Files changed (47) hide show
  1. package/apps/admin/createAdminPulumiApp.d.ts +1 -1
  2. package/apps/api/ApiApwScheduler.d.ts +1 -1
  3. package/apps/api/ApiBackgroundTask.d.ts +3 -3
  4. package/apps/api/ApiBackgroundTask.js +31 -10
  5. package/apps/api/ApiBackgroundTask.js.map +1 -1
  6. package/apps/api/ApiCloudfront.d.ts +1 -1
  7. package/apps/api/ApiFileManager.d.ts +1 -1
  8. package/apps/api/ApiGateway.d.ts +1 -1
  9. package/apps/api/ApiGraphql.d.ts +1 -1
  10. package/apps/api/ApiGraphql.js +1 -0
  11. package/apps/api/ApiGraphql.js.map +1 -1
  12. package/apps/api/ApiMigration.d.ts +1 -1
  13. package/apps/api/ApiOutput.d.ts +1 -1
  14. package/apps/api/ApiPageBuilder.d.ts +1 -1
  15. package/apps/api/ApiWebsocket.d.ts +1 -1
  16. package/apps/api/backgroundTask/definition.js +4 -0
  17. package/apps/api/backgroundTask/definition.js.map +1 -1
  18. package/apps/api/backgroundTask/types.d.ts +3 -2
  19. package/apps/api/backgroundTask/types.js.map +1 -1
  20. package/apps/api/createApiPulumiApp.d.ts +15 -11
  21. package/apps/api/createApiPulumiApp.js +6 -0
  22. package/apps/api/createApiPulumiApp.js.map +1 -1
  23. package/apps/awsUtils.d.ts +1 -1
  24. package/apps/common/CoreOutput.d.ts +1 -1
  25. package/apps/core/CoreCognito.d.ts +1 -1
  26. package/apps/core/CoreDynamo.d.ts +1 -1
  27. package/apps/core/CoreFileManager.d.ts +1 -1
  28. package/apps/core/CoreVpc.d.ts +1 -1
  29. package/apps/core/cognitoIdentityProviders/configure.d.ts +1 -1
  30. package/apps/core/createCorePulumiApp.d.ts +13 -9
  31. package/apps/core/createCorePulumiApp.js +3 -0
  32. package/apps/core/createCorePulumiApp.js.map +1 -1
  33. package/apps/react/createReactPulumiApp.d.ts +1 -1
  34. package/apps/website/createWebsitePulumiApp.d.ts +1 -1
  35. package/apps/website/createWebsitePulumiApp.js +17 -0
  36. package/apps/website/createWebsitePulumiApp.js.map +1 -1
  37. package/constants.d.ts +1 -1
  38. package/constants.js +1 -1
  39. package/constants.js.map +1 -1
  40. package/enterprise/createApiPulumiApp.d.ts +4 -4
  41. package/enterprise/createCorePulumiApp.d.ts +2 -2
  42. package/enterprise/createWebsitePulumiApp.d.ts +2 -2
  43. package/package.json +13 -13
  44. package/utils/lambdaEnvVariables.d.ts +1 -1
  45. package/utils/tagResources.js +1 -1
  46. package/utils/tagResources.js.map +1 -1
  47. package/utils/uploadFolderToS3.d.ts +1 -1
@@ -1,6 +1,6 @@
1
1
  import { PulumiAppParam, PulumiAppParamCallback } from "@webiny/pulumi";
2
2
  import { createReactPulumiApp, CustomDomainParams } from "..";
3
- export declare type AdminPulumiApp = ReturnType<typeof createReactPulumiApp>;
3
+ export type AdminPulumiApp = ReturnType<typeof createReactPulumiApp>;
4
4
  export interface CreateAdminPulumiAppParams {
5
5
  /** Custom domain configuration */
6
6
  domains?: PulumiAppParamCallback<CustomDomainParams>;
@@ -2,7 +2,7 @@ import { PulumiAppModule } from "@webiny/pulumi";
2
2
  interface ScheduleActionParams {
3
3
  env: Record<string, any>;
4
4
  }
5
- export declare type ApiApwScheduler = PulumiAppModule<typeof ApiApwScheduler>;
5
+ export type ApiApwScheduler = PulumiAppModule<typeof ApiApwScheduler>;
6
6
  export declare const ApiApwScheduler: import("@webiny/pulumi").PulumiAppModuleDefinition<{
7
7
  executeAction: {
8
8
  role: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
@@ -1,12 +1,12 @@
1
1
  import { PulumiAppModule } from "@webiny/pulumi";
2
- export declare type ApiBackgroundTask = PulumiAppModule<typeof ApiBackgroundTask>;
2
+ export type ApiBackgroundTask = PulumiAppModule<typeof ApiBackgroundTask>;
3
3
  export declare const ApiBackgroundTaskLambdaName = "background-task";
4
4
  export declare const ApiBackgroundTask: import("@webiny/pulumi").PulumiAppModuleDefinition<{
5
5
  backgroundTask: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function").Function>;
6
6
  stepFunction: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/sfn/stateMachine").StateMachine>;
7
- eventRole: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
7
+ stepFunctionRole: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
8
+ stepFunctionPolicy: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/policy").Policy>;
8
9
  eventPolicy: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/policy").Policy>;
9
10
  eventRolePolicyAttachment: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/rolePolicyAttachment").RolePolicyAttachment>;
10
- eventRule: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudwatch/eventRule").EventRule>;
11
11
  eventTarget: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudwatch/eventTarget").EventTarget>;
12
12
  }, void>;
@@ -13,10 +13,13 @@ var _definition = require("./backgroundTask/definition");
13
13
  var _policy = require("./backgroundTask/policy");
14
14
  var _role = require("./backgroundTask/role");
15
15
  var _awsLayers = require("@webiny/aws-layers");
16
+ var _awsUtils = require("../awsUtils");
16
17
  const ApiBackgroundTaskLambdaName = exports.ApiBackgroundTaskLambdaName = "background-task";
17
18
  const ApiBackgroundTask = exports.ApiBackgroundTask = (0, _pulumi2.createAppModule)({
18
19
  name: "ApiBackgroundTask",
19
20
  config(app) {
21
+ const awsAccountId = (0, _awsUtils.getAwsAccountId)(app);
22
+ const awsRegion = (0, _awsUtils.getAwsRegion)(app);
20
23
  const core = app.getModule(_.CoreOutput);
21
24
  const graphql = app.getModule(_.ApiGraphql);
22
25
  const baseConfig = graphql.functions.graphql.config.clone();
@@ -43,14 +46,6 @@ const ApiBackgroundTask = exports.ApiBackgroundTask = (0, _pulumi2.createAppModu
43
46
  const stepFunction = app.addResource(aws.sfn.StateMachine, {
44
47
  name: "background-task-sfn",
45
48
  config: {
46
- // TODO logging to cloudwatch
47
- /*
48
- loggingConfiguration: {
49
- level: "ALL",
50
- includeExecutionData: true,
51
- // insert real ARN
52
- logDestination: ARN
53
- */
54
49
  roleArn: stepFunctionRole.output.arn,
55
50
  definition: pulumi.jsonStringify((0, _definition.createBackgroundTaskDefinition)({
56
51
  lambdaName: ApiBackgroundTaskLambdaName,
@@ -58,6 +53,32 @@ const ApiBackgroundTask = exports.ApiBackgroundTask = (0, _pulumi2.createAppModu
58
53
  }))
59
54
  }
60
55
  });
56
+ const policyToAccessStepFunction = app.addResource(aws.iam.Policy, {
57
+ name: "background-task-step-function-policy",
58
+ config: {
59
+ policy: {
60
+ Version: "2012-10-17",
61
+ Statement: [{
62
+ Action: ["states:StartExecution", "states:StopExecution"],
63
+ Effect: "Allow",
64
+ Resource: [stepFunction.output.arn.apply(arn => `${arn}`), stepFunction.output.arn.apply(arn => `${arn}*`)]
65
+ }, {
66
+ Action: ["states:DescribeExecution", "states:ListExecutions"],
67
+ Effect: "Allow",
68
+ Resource: [stepFunction.output.name.apply(name => {
69
+ return pulumi.interpolate`arn:aws:states:${awsRegion}:${awsAccountId}:execution:${name}:*`;
70
+ })]
71
+ }]
72
+ }
73
+ }
74
+ });
75
+ app.addResource(aws.iam.RolePolicyAttachment, {
76
+ name: "background-task-step-function-policy-attachment-graphql",
77
+ config: {
78
+ policyArn: policyToAccessStepFunction.output.arn,
79
+ role: graphql.role.output.name
80
+ }
81
+ });
61
82
  const eventRole = app.addResource(aws.iam.Role, {
62
83
  name: "background-task-event-role",
63
84
  config: {
@@ -119,10 +140,10 @@ const ApiBackgroundTask = exports.ApiBackgroundTask = (0, _pulumi2.createAppModu
119
140
  return {
120
141
  backgroundTask,
121
142
  stepFunction,
122
- eventRole,
143
+ stepFunctionRole,
144
+ stepFunctionPolicy,
123
145
  eventPolicy,
124
146
  eventRolePolicyAttachment,
125
- eventRule,
126
147
  eventTarget
127
148
  };
128
149
  }
@@ -1 +1 @@
1
- {"version":3,"names":["pulumi","_interopRequireWildcard","require","aws","_pulumi2","_","_definition","_policy","_role","_awsLayers","ApiBackgroundTaskLambdaName","exports","ApiBackgroundTask","createAppModule","name","config","app","core","getModule","CoreOutput","graphql","ApiGraphql","baseConfig","functions","clone","backgroundTask","addResource","lambda","Function","layers","output","apply","arns","Array","from","Set","getLayerArn","timeout","memorySize","description","stepFunctionPolicy","createBackgroundTaskStepFunctionPolicy","lambdaFunctionArn","arn","stepFunctionRole","createBackgroundTaskStepFunctionRole","policy","stepFunction","sfn","StateMachine","roleArn","definition","jsonStringify","createBackgroundTaskDefinition","lambdaName","lambdaArn","eventRole","iam","Role","assumeRolePolicy","Version","Statement","Action","Effect","Principal","Service","eventPolicy","Policy","Resource","eventRolePolicyAttachment","RolePolicyAttachment","role","policyArn","eventRule","cloudwatch","EventRule","eventBusName","eventPattern","JSON","stringify","eventTarget","EventTarget","rule"],"sources":["ApiBackgroundTask.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport { createAppModule, PulumiApp, PulumiAppModule } from \"@webiny/pulumi\";\nimport { ApiGraphql, CoreOutput } from \"~/apps\";\nimport { createBackgroundTaskDefinition } from \"./backgroundTask/definition\";\nimport { createBackgroundTaskStepFunctionPolicy } from \"~/apps/api/backgroundTask/policy\";\nimport { createBackgroundTaskStepFunctionRole } from \"./backgroundTask/role\";\nimport { getLayerArn } from \"@webiny/aws-layers\";\n\nexport type ApiBackgroundTask = PulumiAppModule<typeof ApiBackgroundTask>;\n\nexport const ApiBackgroundTaskLambdaName = \"background-task\";\n\nexport const ApiBackgroundTask = createAppModule({\n name: \"ApiBackgroundTask\",\n config(app: PulumiApp) {\n const core = app.getModule(CoreOutput);\n const graphql = app.getModule(ApiGraphql);\n const baseConfig = graphql.functions.graphql.config.clone();\n\n const backgroundTask = app.addResource(aws.lambda.Function, {\n name: ApiBackgroundTaskLambdaName,\n config: {\n ...baseConfig,\n layers: graphql.functions.graphql.output.layers.apply(arns => {\n return Array.from(new Set([...(arns || []), getLayerArn(\"sharp\")]));\n }),\n timeout: 900,\n memorySize: 1024,\n description: \"Performs background tasks.\"\n }\n });\n\n const stepFunctionPolicy = createBackgroundTaskStepFunctionPolicy(app, {\n name: \"background-task-sfn-policy\",\n lambdaFunctionArn: backgroundTask.output.arn\n });\n\n const stepFunctionRole = createBackgroundTaskStepFunctionRole(app, {\n name: \"background-task-sfn-role\",\n policy: stepFunctionPolicy.output\n });\n\n const stepFunction = app.addResource(aws.sfn.StateMachine, {\n name: \"background-task-sfn\",\n config: {\n // TODO logging to cloudwatch\n /*\n loggingConfiguration: {\n level: \"ALL\",\n includeExecutionData: true,\n // insert real ARN\n logDestination: ARN\n */\n roleArn: stepFunctionRole.output.arn,\n definition: pulumi.jsonStringify(\n createBackgroundTaskDefinition({\n lambdaName: ApiBackgroundTaskLambdaName,\n lambdaArn: backgroundTask.output.arn\n })\n )\n }\n });\n\n const eventRole = app.addResource(aws.iam.Role, {\n name: \"background-task-event-role\",\n config: {\n assumeRolePolicy: {\n Version: \"2012-10-17\",\n Statement: [\n {\n Action: \"sts:AssumeRole\",\n Effect: \"Allow\",\n Principal: {\n Service: \"events.amazonaws.com\"\n }\n }\n ]\n }\n }\n });\n\n const eventPolicy = app.addResource(aws.iam.Policy, {\n name: \"background-task-event-policy\",\n config: {\n policy: {\n Version: \"2012-10-17\",\n Statement: [\n {\n Action: \"states:StartExecution\",\n Effect: \"Allow\",\n Resource: stepFunction.output.arn\n }\n ]\n }\n }\n });\n\n const eventRolePolicyAttachment = app.addResource(aws.iam.RolePolicyAttachment, {\n name: \"background-task-event-role-policy-attachment\",\n config: {\n role: eventRole.output.name,\n policyArn: eventPolicy.output.arn\n }\n });\n\n const eventRule = app.addResource(aws.cloudwatch.EventRule, {\n name: \"background-task-event-rule\",\n config: {\n eventBusName: core.eventBusName,\n roleArn: eventRole.output.arn,\n eventPattern: JSON.stringify({\n \"detail-type\": [\"WebinyBackgroundTask\"]\n })\n }\n });\n\n const eventTarget = app.addResource(aws.cloudwatch.EventTarget, {\n name: \"background-task-event-target\",\n config: {\n // This is going to get called.\n arn: stepFunction.output.arn,\n // This is the rule which determines if this target gets called.\n rule: eventRule.output.name,\n // This is the role which gets assumed when calling the target.\n roleArn: eventRole.output.arn,\n // This is the event bus name.\n eventBusName: core.eventBusName\n }\n });\n\n return {\n backgroundTask,\n stepFunction,\n eventRole,\n eventPolicy,\n eventRolePolicyAttachment,\n eventRule,\n eventTarget\n };\n }\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,GAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,CAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AAIO,MAAMQ,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,GAAG,iBAAiB;AAErD,MAAME,iBAAiB,GAAAD,OAAA,CAAAC,iBAAA,GAAG,IAAAC,wBAAe,EAAC;EAC7CC,IAAI,EAAE,mBAAmB;EACzBC,MAAMA,CAACC,GAAc,EAAE;IACnB,MAAMC,IAAI,GAAGD,GAAG,CAACE,SAAS,CAACC,YAAU,CAAC;IACtC,MAAMC,OAAO,GAAGJ,GAAG,CAACE,SAAS,CAACG,YAAU,CAAC;IACzC,MAAMC,UAAU,GAAGF,OAAO,CAACG,SAAS,CAACH,OAAO,CAACL,MAAM,CAACS,KAAK,CAAC,CAAC;IAE3D,MAAMC,cAAc,GAAGT,GAA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AS,CAAC;UACzB,aAAa,EAAE,CAAC,sBAAsB;QAC1C,CAAC;MACL;IACJ,CAAC,CAAC;IAEF,MAAMC,WAAW,GAAGhE,GAAG,CAACU,WAAW,CAACvB,GAAG,CAACuE,UAAU,CAACO,WAAW,EAAE;MAC5DnE,IAAI,EAAE,8BAA8B;MACpCC,MAAM,EAAE;QACJ;QACA4B,GAAG,EAAEI,YAAY,CAACjB,MAAM,CAACa,GAAG;QAC5B;QACAuC,IAAI,EAAET,SAAS,CAAC3C,MAAM,CAAChB,IAAI;QAC3B;QACAoC,OAAO,EAAEM,SAAS,CAAC1B,MAAM,CAACa,GAAG;QAC7B;QACAiC,YAAY,EAAE3D,IAAI,CAAC2D;MACvB;IACJ,CAAC,CAAC;IAEF,OAAO;MACHnD,cAAc;MACdsB,YAAY;MACZS,SAAS;MACTU,WAAW;MACXG,yBAAyB;MACzBI,SAAS;MACTO;IACJ,CAAC;EACL;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["pulumi","_interopRequireWildcard","require","aws","_pulumi2","_","_definition","_policy","_role","_awsLayers","_awsUtils","ApiBackgroundTaskLambdaName","exports","ApiBackgroundTask","createAppModule","name","config","app","awsAccountId","getAwsAccountId","awsRegion","getAwsRegion","core","getModule","CoreOutput","graphql","ApiGraphql","baseConfig","functions","clone","backgroundTask","addResource","lambda","Function","layers","output","apply","arns","Array","from","Set","getLayerArn","timeout","memorySize","description","stepFunctionPolicy","createBackgroundTaskStepFunctionPolicy","lambdaFunctionArn","arn","stepFunctionRole","createBackgroundTaskStepFunctionRole","policy","stepFunction","sfn","StateMachine","roleArn","definition","jsonStringify","createBackgroundTaskDefinition","lambdaName","lambdaArn","policyToAccessStepFunction","iam","Policy","Version","Statement","Action","Effect","Resource","interpolate","RolePolicyAttachment","policyArn","role","eventRole","Role","assumeRolePolicy","Principal","Service","eventPolicy","eventRolePolicyAttachment","eventRule","cloudwatch","EventRule","eventBusName","eventPattern","JSON","stringify","eventTarget","EventTarget","rule"],"sources":["ApiBackgroundTask.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport { createAppModule, PulumiApp, PulumiAppModule } from \"@webiny/pulumi\";\nimport { ApiGraphql, CoreOutput } from \"~/apps\";\nimport { createBackgroundTaskDefinition } from \"./backgroundTask/definition\";\nimport { createBackgroundTaskStepFunctionPolicy } from \"~/apps/api/backgroundTask/policy\";\nimport { createBackgroundTaskStepFunctionRole } from \"./backgroundTask/role\";\nimport { getLayerArn } from \"@webiny/aws-layers\";\nimport { getAwsAccountId, getAwsRegion } from \"~/apps/awsUtils\";\n\nexport type ApiBackgroundTask = PulumiAppModule<typeof ApiBackgroundTask>;\n\nexport const ApiBackgroundTaskLambdaName = \"background-task\";\n\nexport const ApiBackgroundTask = createAppModule({\n name: \"ApiBackgroundTask\",\n config(app: PulumiApp) {\n const awsAccountId = getAwsAccountId(app);\n const awsRegion = getAwsRegion(app);\n const core = app.getModule(CoreOutput);\n const graphql = app.getModule(ApiGraphql);\n const baseConfig = graphql.functions.graphql.config.clone();\n\n const backgroundTask = app.addResource(aws.lambda.Function, {\n name: ApiBackgroundTaskLambdaName,\n config: {\n ...baseConfig,\n layers: graphql.functions.graphql.output.layers.apply(arns => {\n return Array.from(new Set([...(arns || []), getLayerArn(\"sharp\")]));\n }),\n timeout: 900,\n memorySize: 1024,\n description: \"Performs background tasks.\"\n }\n });\n\n const stepFunctionPolicy = createBackgroundTaskStepFunctionPolicy(app, {\n name: \"background-task-sfn-policy\",\n lambdaFunctionArn: backgroundTask.output.arn\n });\n\n const stepFunctionRole = createBackgroundTaskStepFunctionRole(app, {\n name: \"background-task-sfn-role\",\n policy: stepFunctionPolicy.output\n });\n\n const stepFunction = app.addResource(aws.sfn.StateMachine, {\n name: \"background-task-sfn\",\n config: {\n roleArn: stepFunctionRole.output.arn,\n definition: pulumi.jsonStringify(\n createBackgroundTaskDefinition({\n lambdaName: ApiBackgroundTaskLambdaName,\n lambdaArn: backgroundTask.output.arn\n })\n )\n }\n });\n\n const policyToAccessStepFunction = app.addResource(aws.iam.Policy, {\n name: \"background-task-step-function-policy\",\n config: {\n policy: {\n Version: \"2012-10-17\",\n Statement: [\n {\n Action: [\"states:StartExecution\", \"states:StopExecution\"],\n Effect: \"Allow\",\n Resource: [\n stepFunction.output.arn.apply(arn => `${arn}`),\n stepFunction.output.arn.apply(arn => `${arn}*`)\n ]\n },\n {\n Action: [\"states:DescribeExecution\", \"states:ListExecutions\"],\n Effect: \"Allow\",\n Resource: [\n stepFunction.output.name.apply(name => {\n return pulumi.interpolate`arn:aws:states:${awsRegion}:${awsAccountId}:execution:${name}:*`;\n })\n ]\n }\n ]\n }\n }\n });\n\n app.addResource(aws.iam.RolePolicyAttachment, {\n name: \"background-task-step-function-policy-attachment-graphql\",\n config: {\n policyArn: policyToAccessStepFunction.output.arn,\n role: graphql.role.output.name\n }\n });\n\n const eventRole = app.addResource(aws.iam.Role, {\n name: \"background-task-event-role\",\n config: {\n assumeRolePolicy: {\n Version: \"2012-10-17\",\n Statement: [\n {\n Action: \"sts:AssumeRole\",\n Effect: \"Allow\",\n Principal: {\n Service: \"events.amazonaws.com\"\n }\n }\n ]\n }\n }\n });\n\n const eventPolicy = app.addResource(aws.iam.Policy, {\n name: \"background-task-event-policy\",\n config: {\n policy: {\n Version: \"2012-10-17\",\n Statement: [\n {\n Action: \"states:StartExecution\",\n Effect: \"Allow\",\n Resource: stepFunction.output.arn\n }\n ]\n }\n }\n });\n\n const eventRolePolicyAttachment = app.addResource(aws.iam.RolePolicyAttachment, {\n name: \"background-task-event-role-policy-attachment\",\n config: {\n role: eventRole.output.name,\n policyArn: eventPolicy.output.arn\n }\n });\n\n const eventRule = app.addResource(aws.cloudwatch.EventRule, {\n name: \"background-task-event-rule\",\n config: {\n eventBusName: core.eventBusName,\n roleArn: eventRole.output.arn,\n eventPattern: JSON.stringify({\n \"detail-type\": [\"WebinyBackgroundTask\"]\n })\n }\n });\n\n const eventTarget = app.addResource(aws.cloudwatch.EventTarget, {\n name: \"background-task-event-target\",\n config: {\n // This is going to get called.\n arn: stepFunction.output.arn,\n // This is the rule which determines if this target gets called.\n rule: eventRule.output.name,\n // This is the role which gets assumed when calling the target.\n roleArn: eventRole.output.arn,\n // This is the event bus name.\n eventBusName: core.eventBusName\n }\n });\n\n return {\n backgroundTask,\n stepFunction,\n stepFunctionRole,\n stepFunctionPolicy,\n eventPolicy,\n eventRolePolicyAttachment,\n eventTarget\n };\n }\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,GAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,CAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAIO,MAAMS,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,GAAG,iBAAiB;AAErD,MAAME,iBAAiB,GAAAD,OAAA,CAAAC,iBAAA,GAAG,IAAAC,wBAAe,EAAC;EAC7CC,IAAI,EAAE,mBAAmB;EACzBC,MAAMA,CAACC,GAAc,EAAE;IACnB,MAAMC,YAAY,GAAG,IAAAC,yBAAe,EAACF,GAAG,CAAC;IACzC,MAAMG,SAAS,GAAG,IAAAC,sBAAY,EAACJ,GAAG,CAAC;IACnC,MAAMK,IAAI,GAAGL,GAAG,CAACM,SAAS,CAACC,YAAU,CAAC;IACtC,MAAMC,OAAO,GAAGR,GAAG,CAACM,SAAS,CAACG,YAAU,CAAC;IACzC,MAAMC,UAAU,GAAGF,OAAO,CAACG,SAAS,CAACH,OAAO,CAACT,MAAM,CAACa,KAAK,CAAC,CAAC;IAE3D,MAAMC,cAAc,GAAGb,GAAG,CAACc,WAAW,CAAC5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zE,IAAI,EAAE,8BAA8B;MACpCC,MAAM,EAAE;QACJ;QACAgC,GAAG,EAAEI,YAAY,CAACjB,MAAM,CAACa,GAAG;QAC5B;QACAyC,IAAI,EAAET,SAAS,CAAC7C,MAAM,CAACpB,IAAI;QAC3B;QACAwC,OAAO,EAAEkB,SAAS,CAACtC,MAAM,CAACa,GAAG;QAC7B;QACAmC,YAAY,EAAE7D,IAAI,CAAC6D;MACvB;IACJ,CAAC,CAAC;IAEF,OAAO;MACHrD,cAAc;MACdsB,YAAY;MACZH,gBAAgB;MAChBJ,kBAAkB;MAClBiC,WAAW;MACXC,yBAAyB;MACzBQ;IACJ,CAAC;EACL;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1,3 +1,3 @@
1
1
  import { PulumiAppModule } from "@webiny/pulumi";
2
- export declare type ApiCloudfront = PulumiAppModule<typeof ApiCloudfront>;
2
+ export type ApiCloudfront = PulumiAppModule<typeof ApiCloudfront>;
3
3
  export declare const ApiCloudfront: import("@webiny/pulumi").PulumiAppModuleDefinition<import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudfront/distribution").Distribution>, void>;
@@ -1,5 +1,5 @@
1
1
  import { PulumiAppModule } from "@webiny/pulumi";
2
- export declare type ApiFileManager = PulumiAppModule<typeof ApiFileManager>;
2
+ export type ApiFileManager = PulumiAppModule<typeof ApiFileManager>;
3
3
  interface ApiFileManagerConfig {
4
4
  env: Record<string, any>;
5
5
  }
@@ -5,7 +5,7 @@ export interface ApiRouteParams {
5
5
  method: pulumi.Input<string>;
6
6
  function: pulumi.Input<string>;
7
7
  }
8
- export declare type ApiGateway = PulumiAppModule<typeof ApiGateway>;
8
+ export type ApiGateway = PulumiAppModule<typeof ApiGateway>;
9
9
  export declare const ApiGateway: import("@webiny/pulumi").PulumiAppModuleDefinition<{
10
10
  api: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/apigatewayv2/api").Api>;
11
11
  stage: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/apigatewayv2/stage").Stage>;
@@ -14,7 +14,7 @@ export interface AddRouteParams {
14
14
  path: `/${string}`;
15
15
  method: "DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | "OPTIONS" | "ANY";
16
16
  }
17
- export declare type ApiGraphql = PulumiAppModule<typeof ApiGraphql>;
17
+ export type ApiGraphql = PulumiAppModule<typeof ApiGraphql>;
18
18
  export declare const ApiGraphql: import("@webiny/pulumi").PulumiAppModuleDefinition<{
19
19
  role: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
20
20
  policy: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/policy").Policy>;
@@ -27,6 +27,7 @@ const ApiGraphql = exports.ApiGraphql = (0, _pulumi2.createAppModule)({
27
27
  name: "api-lambda-role",
28
28
  policy: policy.output
29
29
  });
30
+ policy.config.policy;
30
31
  const graphql = app.addResource(aws.lambda.Function, {
31
32
  name: "graphql",
32
33
  config: {
@@ -1 +1 @@
1
- {"version":3,"names":["_path","_interopRequireDefault","require","pulumi","_interopRequireWildcard","aws","_kebabCase","_pulumi2","_lambdaUtils","_","_awsUtils","_constants","EMPTY_TRASH_BIN_EVENT_RULE_NAME","EMPTY_TRASH_BIN_EVENT_PERMISSION_NAME","EMPTY_TRASH_BIN_EVENT_RULE_TARGET","ApiGraphql","exports","createAppModule","name","config","app","params","core","getModule","CoreOutput","policy","createGraphqlLambdaPolicy","role","createLambdaRole","output","graphql","addResource","lambda","Function","runtime","LAMBDA_RUNTIME","handler","arn","timeout","memorySize","code","asset","AssetArchive","FileArchive","path","join","paths","workspace","environment","variables","getCommonLambdaEnvVariables","apply","value","env","AWS_NODEJS_CONNECTION_REUSE_ENABLED","vpcConfig","VpcConfig","functionVpcConfig","dynamodb","TableItem","tableName","primaryDynamodbTableName","hashKey","primaryDynamodbTableHashKey","rangeKey","primaryDynamodbTableRangeKey","key","item","interpolate","run","variant","apwSchedulerEventRule","apwSchedulerEventTarget","targetId","eventRule","cloudwatch","EventRule","description","scheduleExpression","Permission","action","function","principal","statementId","EventTarget","rule","input","JSON","stringify","source","functions","addRoute","routeParams","apiGateway","resources","console","log","kebabName","toKebabCase","method","coreOutput","awsAccountId","getAwsAccountId","awsRegion","getAwsRegion","iam","Policy","Version","Statement","Sid","Effect","Action","Resource","primaryDynamodbTableArn","elasticsearchDynamodbTableArn","fileManagerBucketId","cognitoUserPoolArn","eventBusArn","elasticsearchDomainArn"],"sources":["ApiGraphql.ts"],"sourcesContent":["import path from \"path\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport toKebabCase from \"lodash/kebabCase\";\n\nimport { createAppModule, PulumiApp, PulumiAppModule } from \"@webiny/pulumi\";\nimport { createLambdaRole, getCommonLambdaEnvVariables } from \"../lambdaUtils\";\nimport { CoreOutput, VpcConfig } from \"~/apps\";\nimport { getAwsAccountId, getAwsRegion } from \"../awsUtils\";\nimport { LAMBDA_RUNTIME } from \"~/constants\";\n\ninterface GraphqlParams {\n env: Record<string, any>;\n apwSchedulerEventRule: pulumi.Output<aws.cloudwatch.EventRule>;\n apwSchedulerEventTarget: pulumi.Output<aws.cloudwatch.EventTarget>;\n}\n\nexport interface AddRouteParams {\n /**\n * Must be in kebab case (a-z and -)\n */\n name: string;\n path: `/${string}`;\n method: \"DELETE\" | \"GET\" | \"HEAD\" | \"PATCH\" | \"POST\" | \"PUT\" | \"OPTIONS\" | \"ANY\";\n}\n\nconst EMPTY_TRASH_BIN_EVENT_RULE_NAME = `empty-trash-bin-event-rule`;\nconst EMPTY_TRASH_BIN_EVENT_PERMISSION_NAME = `empty-trash-bin-event-target-permission`;\nconst EMPTY_TRASH_BIN_EVENT_RULE_TARGET = `empty-trash-bin-event-rule-target`;\n\nexport type ApiGraphql = PulumiAppModule<typeof ApiGraphql>;\n\nexport const ApiGraphql = createAppModule({\n name: \"ApiGraphql\",\n config(app: PulumiApp, params: GraphqlParams) {\n const core = app.getModule(CoreOutput);\n\n const policy = createGraphqlLambdaPolicy(app);\n const role = createLambdaRole(app, {\n name: \"api-lambda-role\",\n policy: policy.output\n });\n\n const graphql = app.addResource(aws.lambda.Function, {\n name: \"graphql\",\n config: {\n runtime: LAMBDA_RUNTIME,\n handler: \"handler.handler\",\n role: role.output.arn,\n timeout: 30,\n memorySize: 1024,\n code: new pulumi.asset.AssetArchive({\n \".\": new pulumi.asset.FileArchive(\n path.join(app.paths.workspace, \"graphql/build\")\n )\n }),\n environment: {\n variables: getCommonLambdaEnvVariables().apply(value => ({\n ...value,\n ...params.env,\n AWS_NODEJS_CONNECTION_REUSE_ENABLED: \"1\"\n }))\n },\n vpcConfig: app.getModule(VpcConfig).functionVpcConfig\n }\n });\n /**\n * Store meta information like \"mainGraphqlFunctionArn\" in APW settings at deploy time.\n *\n * Note: We can't pass \"mainGraphqlFunctionArn\" as env variable due to circular dependency between\n * \"graphql\" lambda and \"api-apw-scheduler-execute-action\" lambda.\n */\n app.addResource(aws.dynamodb.TableItem, {\n name: \"apwSettings\",\n config: {\n tableName: core.primaryDynamodbTableName,\n hashKey: core.primaryDynamodbTableHashKey,\n rangeKey: pulumi\n .output(core.primaryDynamodbTableRangeKey)\n .apply(key => key || \"SK\"),\n item: pulumi.interpolate`{\n \"PK\": {\"S\": \"APW#SETTINGS\"},\n \"SK\": {\"S\": \"${app.params.run.variant || \"default\"}\"},\n \"mainGraphqlFunctionArn\": {\"S\": \"${graphql.output.arn}\"},\n \"eventRuleName\": {\"S\": \"${params.apwSchedulerEventRule.name}\"},\n \"eventTargetId\": {\"S\": \"${params.apwSchedulerEventTarget.targetId}\"}\n }`\n }\n });\n\n // Create event rule.\n const eventRule = app.addResource(aws.cloudwatch.EventRule, {\n name: EMPTY_TRASH_BIN_EVENT_RULE_NAME,\n config: {\n description: \"Enable us to empty the trash-bin ever day\",\n scheduleExpression: \"cron(0 3 * * ? *)\"\n }\n });\n\n // Add required permission to the target lambda.\n app.addResource(aws.lambda.Permission, {\n name: EMPTY_TRASH_BIN_EVENT_PERMISSION_NAME,\n config: {\n action: \"lambda:InvokeFunction\",\n function: graphql.output.arn,\n principal: \"events.amazonaws.com\",\n statementId: \"allow-rule-invoke-\" + EMPTY_TRASH_BIN_EVENT_RULE_NAME\n }\n });\n\n // Target the main graphql lambda.\n app.addResource(aws.cloudwatch.EventTarget, {\n name: EMPTY_TRASH_BIN_EVENT_RULE_TARGET,\n config: {\n rule: eventRule.output.name,\n arn: graphql.output.arn,\n input: JSON.stringify({\n source: \"webiny.events\",\n \"detail-type\": \"WebinyEmptyTrashBin\"\n })\n }\n });\n\n return {\n role,\n policy,\n functions: {\n graphql\n },\n addRoute: (routeParams: AddRouteParams) => {\n const apiGateway: any = app.resources.apiGateway;\n if (!apiGateway) {\n console.log(\n \"Could not add route because there is no apiGateway in the resources.\"\n );\n return;\n }\n const kebabName = toKebabCase(routeParams.name);\n if (kebabName !== routeParams.name) {\n console.log(`Route name is not allowed: \"${routeParams.name}\".`);\n return;\n }\n return apiGateway.addRoute(routeParams.name, {\n path: routeParams.path,\n method: routeParams.method,\n function: graphql.output.arn\n });\n }\n };\n }\n});\n\nfunction createGraphqlLambdaPolicy(app: PulumiApp) {\n const coreOutput = app.getModule(CoreOutput);\n const awsAccountId = getAwsAccountId(app);\n const awsRegion = getAwsRegion(app);\n\n return app.addResource(aws.iam.Policy, {\n name: \"ApiGraphqlLambdaPolicy\",\n config: {\n description: \"This policy enables access to Dynamodb, S3, Lambda and Cognito IDP\",\n // Core is pulumi.Output, so we need to run apply() to resolve policy based on it\n policy: coreOutput.apply(core => {\n const policy: aws.iam.PolicyDocument = {\n Version: \"2012-10-17\",\n Statement: [\n {\n Sid: \"PermissionForDynamodb\",\n Effect: \"Allow\",\n Action: [\n \"dynamodb:BatchGetItem\",\n \"dynamodb:BatchWriteItem\",\n \"dynamodb:ConditionCheckItem\",\n \"dynamodb:CreateBackup\",\n \"dynamodb:CreateTable\",\n \"dynamodb:CreateTableReplica\",\n \"dynamodb:DeleteBackup\",\n \"dynamodb:DeleteItem\",\n \"dynamodb:DeleteTable\",\n \"dynamodb:DeleteTableReplica\",\n \"dynamodb:DescribeBackup\",\n \"dynamodb:DescribeContinuousBackups\",\n \"dynamodb:DescribeContributorInsights\",\n \"dynamodb:DescribeExport\",\n \"dynamodb:DescribeKinesisStreamingDestination\",\n \"dynamodb:DescribeLimits\",\n \"dynamodb:DescribeReservedCapacity\",\n \"dynamodb:DescribeReservedCapacityOfferings\",\n \"dynamodb:DescribeStream\",\n \"dynamodb:DescribeTable\",\n \"dynamodb:DescribeTableReplicaAutoScaling\",\n \"dynamodb:DescribeTimeToLive\",\n \"dynamodb:DisableKinesisStreamingDestination\",\n \"dynamodb:EnableKinesisStreamingDestination\",\n \"dynamodb:ExportTableToPointInTime\",\n \"dynamodb:GetItem\",\n \"dynamodb:GetRecords\",\n \"dynamodb:GetShardIterator\",\n \"dynamodb:ListBackups\",\n \"dynamodb:ListContributorInsights\",\n \"dynamodb:ListExports\",\n \"dynamodb:ListStreams\",\n \"dynamodb:ListTables\",\n \"dynamodb:ListTagsOfResource\",\n \"dynamodb:PartiQLDelete\",\n \"dynamodb:PartiQLInsert\",\n \"dynamodb:PartiQLSelect\",\n \"dynamodb:PartiQLUpdate\",\n \"dynamodb:PurchaseReservedCapacityOfferings\",\n \"dynamodb:PutItem\",\n \"dynamodb:Query\",\n \"dynamodb:RestoreTableFromBackup\",\n \"dynamodb:RestoreTableToPointInTime\",\n \"dynamodb:Scan\",\n \"dynamodb:UpdateContinuousBackups\",\n \"dynamodb:UpdateContributorInsights\",\n \"dynamodb:UpdateItem\",\n \"dynamodb:UpdateTable\",\n \"dynamodb:UpdateTableReplicaAutoScaling\",\n \"dynamodb:UpdateTimeToLive\"\n ],\n Resource: [\n `${core.primaryDynamodbTableArn}`,\n `${core.primaryDynamodbTableArn}/*`,\n // Attach permissions for elastic search dynamo as well (if ES is enabled).\n ...(core.elasticsearchDynamodbTableArn\n ? [\n `${core.elasticsearchDynamodbTableArn}`,\n `${core.elasticsearchDynamodbTableArn}/*`\n ]\n : [])\n ]\n },\n {\n Sid: \"PermissionForS3\",\n Effect: \"Allow\",\n Action: [\n \"s3:ListBucket\",\n \"s3:GetObjectAcl\",\n \"s3:DeleteObject\",\n \"s3:PutObjectAcl\",\n \"s3:PutObject\",\n \"s3:GetObject\"\n ],\n Resource: [\n pulumi.interpolate`arn:aws:s3:::${core.fileManagerBucketId}`,\n pulumi.interpolate`arn:aws:s3:::${core.fileManagerBucketId}/*`\n ]\n },\n {\n Sid: \"PermissionForLambda\",\n Effect: \"Allow\",\n Action: [\"lambda:InvokeFunction\"],\n Resource: pulumi.interpolate`arn:aws:lambda:${awsRegion}:${awsAccountId}:function:*`\n },\n {\n Sid: \"PermissionForCognitoIdp\",\n Effect: \"Allow\",\n Action: \"cognito-idp:*\",\n Resource: `${core.cognitoUserPoolArn}`\n },\n {\n Sid: \"PermissionForEventBus\",\n Effect: \"Allow\",\n Action: \"events:PutEvents\",\n Resource: core.eventBusArn\n },\n {\n Sid: \"PermissionForCloudfront\",\n Effect: \"Allow\",\n Action: \"cloudfront:CreateInvalidation\",\n Resource: pulumi.interpolate`arn:aws:cloudfront::${awsAccountId}:distribution/*`\n },\n // Attach permissions for elastic search domain as well (if ES is enabled).\n ...(core.elasticsearchDomainArn\n ? [\n {\n Sid: \"PermissionForES\",\n Effect: \"Allow\" as const,\n Action: \"es:*\",\n Resource: [\n `${core.elasticsearchDomainArn}`,\n `${core.elasticsearchDomainArn}/*`\n ]\n }\n ]\n : [])\n ]\n };\n\n return policy;\n })\n }\n });\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,GAAA,GAAAD,uBAAA,CAAAF,OAAA;AACA,IAAAI,UAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEA,IAAAK,QAAA,GAAAL,OAAA;AACA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OAAO;YACfC,MAAM,EAAE,+BAA+B;YACvCC,QAAQ,EAAE7G,MAAM,CAACiE,WAAY,uBAAsBiC,YAAa;UACpE,CAAC;UACD;UACA,IAAI/E,IAAI,CAACgG,sBAAsB,GACzB,CACI;YACIT,GAAG,EAAE,iBAAiB;YACtBC,MAAM,EAAE,OAAgB;YACxBC,MAAM,EAAE,MAAM;YACdC,QAAQ,EAAE,CACL,GAAE1F,IAAI,CAACgG,sBAAuB,EAAC,EAC/B,GAAEhG,IAAI,CAACgG,sBAAuB,IAAG;UAE1C,CAAC,CACJ,GACD,EAAE,CAAC;QAEjB,CAAC;QAED,OAAO7F,MAAM;MACjB,CAAC;IACL;EACJ,CAAC,CAAC;AACN","ignoreList":[]}
1
+ {"version":3,"names":["_path","_interopRequireDefault","require","pulumi","_interopRequireWildcard","aws","_kebabCase","_pulumi2","_lambdaUtils","_","_awsUtils","_constants","EMPTY_TRASH_BIN_EVENT_RULE_NAME","EMPTY_TRASH_BIN_EVENT_PERMISSION_NAME","EMPTY_TRASH_BIN_EVENT_RULE_TARGET","ApiGraphql","exports","createAppModule","name","config","app","params","core","getModule","CoreOutput","policy","createGraphqlLambdaPolicy","role","createLambdaRole","output","graphql","addResource","lambda","Function","runtime","LAMBDA_RUNTIME","handler","arn","timeout","memorySize","code","asset","AssetArchive","FileArchive","path","join","paths","workspace","environment","variables","getCommonLambdaEnvVariables","apply","value","env","AWS_NODEJS_CONNECTION_REUSE_ENABLED","vpcConfig","VpcConfig","functionVpcConfig","dynamodb","TableItem","tableName","primaryDynamodbTableName","hashKey","primaryDynamodbTableHashKey","rangeKey","primaryDynamodbTableRangeKey","key","item","interpolate","run","variant","apwSchedulerEventRule","apwSchedulerEventTarget","targetId","eventRule","cloudwatch","EventRule","description","scheduleExpression","Permission","action","function","principal","statementId","EventTarget","rule","input","JSON","stringify","source","functions","addRoute","routeParams","apiGateway","resources","console","log","kebabName","toKebabCase","method","coreOutput","awsAccountId","getAwsAccountId","awsRegion","getAwsRegion","iam","Policy","Version","Statement","Sid","Effect","Action","Resource","primaryDynamodbTableArn","elasticsearchDynamodbTableArn","fileManagerBucketId","cognitoUserPoolArn","eventBusArn","elasticsearchDomainArn"],"sources":["ApiGraphql.ts"],"sourcesContent":["import path from \"path\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport toKebabCase from \"lodash/kebabCase\";\n\nimport { createAppModule, PulumiApp, PulumiAppModule } from \"@webiny/pulumi\";\nimport { createLambdaRole, getCommonLambdaEnvVariables } from \"../lambdaUtils\";\nimport { CoreOutput, VpcConfig } from \"~/apps\";\nimport { getAwsAccountId, getAwsRegion } from \"../awsUtils\";\nimport { LAMBDA_RUNTIME } from \"~/constants\";\n\ninterface GraphqlParams {\n env: Record<string, any>;\n apwSchedulerEventRule: pulumi.Output<aws.cloudwatch.EventRule>;\n apwSchedulerEventTarget: pulumi.Output<aws.cloudwatch.EventTarget>;\n}\n\nexport interface AddRouteParams {\n /**\n * Must be in kebab case (a-z and -)\n */\n name: string;\n path: `/${string}`;\n method: \"DELETE\" | \"GET\" | \"HEAD\" | \"PATCH\" | \"POST\" | \"PUT\" | \"OPTIONS\" | \"ANY\";\n}\n\nconst EMPTY_TRASH_BIN_EVENT_RULE_NAME = `empty-trash-bin-event-rule`;\nconst EMPTY_TRASH_BIN_EVENT_PERMISSION_NAME = `empty-trash-bin-event-target-permission`;\nconst EMPTY_TRASH_BIN_EVENT_RULE_TARGET = `empty-trash-bin-event-rule-target`;\n\nexport type ApiGraphql = PulumiAppModule<typeof ApiGraphql>;\n\nexport const ApiGraphql = createAppModule({\n name: \"ApiGraphql\",\n config(app: PulumiApp, params: GraphqlParams) {\n const core = app.getModule(CoreOutput);\n\n const policy = createGraphqlLambdaPolicy(app);\n const role = createLambdaRole(app, {\n name: \"api-lambda-role\",\n policy: policy.output\n });\n policy.config.policy;\n\n const graphql = app.addResource(aws.lambda.Function, {\n name: \"graphql\",\n config: {\n runtime: LAMBDA_RUNTIME,\n handler: \"handler.handler\",\n role: role.output.arn,\n timeout: 30,\n memorySize: 1024,\n code: new pulumi.asset.AssetArchive({\n \".\": new pulumi.asset.FileArchive(\n path.join(app.paths.workspace, \"graphql/build\")\n )\n }),\n environment: {\n variables: getCommonLambdaEnvVariables().apply(value => ({\n ...value,\n ...params.env,\n AWS_NODEJS_CONNECTION_REUSE_ENABLED: \"1\"\n }))\n },\n vpcConfig: app.getModule(VpcConfig).functionVpcConfig\n }\n });\n /**\n * Store meta information like \"mainGraphqlFunctionArn\" in APW settings at deploy time.\n *\n * Note: We can't pass \"mainGraphqlFunctionArn\" as env variable due to circular dependency between\n * \"graphql\" lambda and \"api-apw-scheduler-execute-action\" lambda.\n */\n app.addResource(aws.dynamodb.TableItem, {\n name: \"apwSettings\",\n config: {\n tableName: core.primaryDynamodbTableName,\n hashKey: core.primaryDynamodbTableHashKey,\n rangeKey: pulumi\n .output(core.primaryDynamodbTableRangeKey)\n .apply(key => key || \"SK\"),\n item: pulumi.interpolate`{\n \"PK\": {\"S\": \"APW#SETTINGS\"},\n \"SK\": {\"S\": \"${app.params.run.variant || \"default\"}\"},\n \"mainGraphqlFunctionArn\": {\"S\": \"${graphql.output.arn}\"},\n \"eventRuleName\": {\"S\": \"${params.apwSchedulerEventRule.name}\"},\n \"eventTargetId\": {\"S\": \"${params.apwSchedulerEventTarget.targetId}\"}\n }`\n }\n });\n\n // Create event rule.\n const eventRule = app.addResource(aws.cloudwatch.EventRule, {\n name: EMPTY_TRASH_BIN_EVENT_RULE_NAME,\n config: {\n description: \"Enable us to empty the trash-bin ever day\",\n scheduleExpression: \"cron(0 3 * * ? *)\"\n }\n });\n\n // Add required permission to the target lambda.\n app.addResource(aws.lambda.Permission, {\n name: EMPTY_TRASH_BIN_EVENT_PERMISSION_NAME,\n config: {\n action: \"lambda:InvokeFunction\",\n function: graphql.output.arn,\n principal: \"events.amazonaws.com\",\n statementId: \"allow-rule-invoke-\" + EMPTY_TRASH_BIN_EVENT_RULE_NAME\n }\n });\n\n // Target the main graphql lambda.\n app.addResource(aws.cloudwatch.EventTarget, {\n name: EMPTY_TRASH_BIN_EVENT_RULE_TARGET,\n config: {\n rule: eventRule.output.name,\n arn: graphql.output.arn,\n input: JSON.stringify({\n source: \"webiny.events\",\n \"detail-type\": \"WebinyEmptyTrashBin\"\n })\n }\n });\n\n return {\n role,\n policy,\n functions: {\n graphql\n },\n addRoute: (routeParams: AddRouteParams) => {\n const apiGateway: any = app.resources.apiGateway;\n if (!apiGateway) {\n console.log(\n \"Could not add route because there is no apiGateway in the resources.\"\n );\n return;\n }\n const kebabName = toKebabCase(routeParams.name);\n if (kebabName !== routeParams.name) {\n console.log(`Route name is not allowed: \"${routeParams.name}\".`);\n return;\n }\n return apiGateway.addRoute(routeParams.name, {\n path: routeParams.path,\n method: routeParams.method,\n function: graphql.output.arn\n });\n }\n };\n }\n});\n\nfunction createGraphqlLambdaPolicy(app: PulumiApp) {\n const coreOutput = app.getModule(CoreOutput);\n const awsAccountId = getAwsAccountId(app);\n const awsRegion = getAwsRegion(app);\n\n return app.addResource(aws.iam.Policy, {\n name: \"ApiGraphqlLambdaPolicy\",\n config: {\n description: \"This policy enables access to Dynamodb, S3, Lambda and Cognito IDP\",\n // Core is pulumi.Output, so we need to run apply() to resolve policy based on it\n policy: coreOutput.apply(core => {\n const policy: aws.iam.PolicyDocument = {\n Version: \"2012-10-17\",\n Statement: [\n {\n Sid: \"PermissionForDynamodb\",\n Effect: \"Allow\",\n Action: [\n \"dynamodb:BatchGetItem\",\n \"dynamodb:BatchWriteItem\",\n \"dynamodb:ConditionCheckItem\",\n \"dynamodb:CreateBackup\",\n \"dynamodb:CreateTable\",\n \"dynamodb:CreateTableReplica\",\n \"dynamodb:DeleteBackup\",\n \"dynamodb:DeleteItem\",\n \"dynamodb:DeleteTable\",\n \"dynamodb:DeleteTableReplica\",\n \"dynamodb:DescribeBackup\",\n \"dynamodb:DescribeContinuousBackups\",\n \"dynamodb:DescribeContributorInsights\",\n \"dynamodb:DescribeExport\",\n \"dynamodb:DescribeKinesisStreamingDestination\",\n \"dynamodb:DescribeLimits\",\n \"dynamodb:DescribeReservedCapacity\",\n \"dynamodb:DescribeReservedCapacityOfferings\",\n \"dynamodb:DescribeStream\",\n \"dynamodb:DescribeTable\",\n \"dynamodb:DescribeTableReplicaAutoScaling\",\n \"dynamodb:DescribeTimeToLive\",\n \"dynamodb:DisableKinesisStreamingDestination\",\n \"dynamodb:EnableKinesisStreamingDestination\",\n \"dynamodb:ExportTableToPointInTime\",\n \"dynamodb:GetItem\",\n \"dynamodb:GetRecords\",\n \"dynamodb:GetShardIterator\",\n \"dynamodb:ListBackups\",\n \"dynamodb:ListContributorInsights\",\n \"dynamodb:ListExports\",\n \"dynamodb:ListStreams\",\n \"dynamodb:ListTables\",\n \"dynamodb:ListTagsOfResource\",\n \"dynamodb:PartiQLDelete\",\n \"dynamodb:PartiQLInsert\",\n \"dynamodb:PartiQLSelect\",\n \"dynamodb:PartiQLUpdate\",\n \"dynamodb:PurchaseReservedCapacityOfferings\",\n \"dynamodb:PutItem\",\n \"dynamodb:Query\",\n \"dynamodb:RestoreTableFromBackup\",\n \"dynamodb:RestoreTableToPointInTime\",\n \"dynamodb:Scan\",\n \"dynamodb:UpdateContinuousBackups\",\n \"dynamodb:UpdateContributorInsights\",\n \"dynamodb:UpdateItem\",\n \"dynamodb:UpdateTable\",\n \"dynamodb:UpdateTableReplicaAutoScaling\",\n \"dynamodb:UpdateTimeToLive\"\n ],\n Resource: [\n `${core.primaryDynamodbTableArn}`,\n `${core.primaryDynamodbTableArn}/*`,\n // Attach permissions for elastic search dynamo as well (if ES is enabled).\n ...(core.elasticsearchDynamodbTableArn\n ? [\n `${core.elasticsearchDynamodbTableArn}`,\n `${core.elasticsearchDynamodbTableArn}/*`\n ]\n : [])\n ]\n },\n {\n Sid: \"PermissionForS3\",\n Effect: \"Allow\",\n Action: [\n \"s3:ListBucket\",\n \"s3:GetObjectAcl\",\n \"s3:DeleteObject\",\n \"s3:PutObjectAcl\",\n \"s3:PutObject\",\n \"s3:GetObject\"\n ],\n Resource: [\n pulumi.interpolate`arn:aws:s3:::${core.fileManagerBucketId}`,\n pulumi.interpolate`arn:aws:s3:::${core.fileManagerBucketId}/*`\n ]\n },\n {\n Sid: \"PermissionForLambda\",\n Effect: \"Allow\",\n Action: [\"lambda:InvokeFunction\"],\n Resource: pulumi.interpolate`arn:aws:lambda:${awsRegion}:${awsAccountId}:function:*`\n },\n {\n Sid: \"PermissionForCognitoIdp\",\n Effect: \"Allow\",\n Action: \"cognito-idp:*\",\n Resource: `${core.cognitoUserPoolArn}`\n },\n {\n Sid: \"PermissionForEventBus\",\n Effect: \"Allow\",\n Action: \"events:PutEvents\",\n Resource: core.eventBusArn\n },\n {\n Sid: \"PermissionForCloudfront\",\n Effect: \"Allow\",\n Action: \"cloudfront:CreateInvalidation\",\n Resource: pulumi.interpolate`arn:aws:cloudfront::${awsAccountId}:distribution/*`\n },\n // Attach permissions for elastic search domain as well (if ES is enabled).\n ...(core.elasticsearchDomainArn\n ? [\n {\n Sid: \"PermissionForES\",\n Effect: \"Allow\" as const,\n Action: \"es:*\",\n Resource: [\n `${core.elasticsearchDomainArn}`,\n `${core.elasticsearchDomainArn}/*`\n ]\n }\n ]\n : [])\n ]\n };\n\n return policy;\n })\n }\n });\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,GAAA,GAAAD,uBAAA,CAAAF,OAAA;AACA,IAAAI,UAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,CAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,UAAA,GAAAT,OAAA;AAiBA,MAAMU,+BAA+B,GAAI,4BAA2B;AACpE,MA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ACgG,sBAAsB,GACzB,CACI;YACIT,GAAG,EAAE,iBAAiB;YACtBC,MAAM,EAAE,OAAgB;YACxBC,MAAM,EAAE,MAAM;YACdC,QAAQ,EAAE,CACL,GAAE1F,IAAI,CAACgG,sBAAuB,EAAC,EAC/B,GAAEhG,IAAI,CAACgG,sBAAuB,IAAG;UAE1C,CAAC,CACJ,GACD,EAAE,CAAC;QAEjB,CAAC;QAED,OAAO7F,MAAM;MACjB,CAAC;IACL;EACJ,CAAC,CAAC;AACN","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import { PulumiAppModule } from "@webiny/pulumi";
2
- export declare type ApiMigration = PulumiAppModule<typeof ApiMigration>;
2
+ export type ApiMigration = PulumiAppModule<typeof ApiMigration>;
3
3
  export declare const ApiMigration: import("@webiny/pulumi").PulumiAppModuleDefinition<{
4
4
  function: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function").Function>;
5
5
  }, void>;
@@ -1,5 +1,5 @@
1
1
  import { PulumiAppModule } from "@webiny/pulumi";
2
- export declare type ApiOutput = PulumiAppModule<typeof ApiOutput>;
2
+ export type ApiOutput = PulumiAppModule<typeof ApiOutput>;
3
3
  export declare const ApiOutput: import("@webiny/pulumi").PulumiAppModuleDefinition<import("@pulumi/pulumi").Output<import("@pulumi/pulumi").UnwrappedObject<{
4
4
  apiDomain: string;
5
5
  apiUrl: string;
@@ -2,7 +2,7 @@ import { PulumiAppModule } from "@webiny/pulumi";
2
2
  interface PageBuilderParams {
3
3
  env: Record<string, any>;
4
4
  }
5
- export declare type ApiPageBuilder = PulumiAppModule<typeof ApiPageBuilder>;
5
+ export type ApiPageBuilder = PulumiAppModule<typeof ApiPageBuilder>;
6
6
  export declare const ApiPageBuilder: import("@webiny/pulumi").PulumiAppModuleDefinition<{
7
7
  export: {
8
8
  role: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
@@ -1,6 +1,6 @@
1
1
  import * as pulumi from "@pulumi/pulumi";
2
2
  import { PulumiAppModule } from "@webiny/pulumi";
3
- export declare type ApiWebsocket = PulumiAppModule<typeof ApiWebsocket>;
3
+ export type ApiWebsocket = PulumiAppModule<typeof ApiWebsocket>;
4
4
  export declare const ApiWebsocket: import("@webiny/pulumi").PulumiAppModuleDefinition<{
5
5
  websocketApi: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/apigatewayv2/api").Api>;
6
6
  websocketApiStage: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/apigatewayv2/stage").Stage>;
@@ -76,6 +76,10 @@ const createBackgroundTaskDefinition = params => {
76
76
  * It can be used to handle waiting for child tasks or some resource to be created.
77
77
  */
78
78
  {
79
+ Variable: "$",
80
+ IsNull: true,
81
+ Next: "UnknownError"
82
+ }, {
79
83
  And: [{
80
84
  Variable: "$.status",
81
85
  StringEquals: "continue"
@@ -1 +1 @@
1
- {"version":3,"names":["_types","require","createBackgroundTaskDefinition","params","lambdaName","lambdaArn","Comment","StartAt","States","TransformEvent","Type","StepFunctionDefinitionStatesType","Pass","Next","Parameters","Run","Task","Resource","ResultPath","InputPath","name","payload","endpoint","Catch","ErrorEquals","CheckStatus","Choice","Choices","And","Variable","StringEquals","IsPresent","IsNumeric","NumericGreaterThan","Default","Waiter","Wait","SecondsPath","UnknownError","Fail","Cause","UnknownStatus","Error","CausePath","ErrorPath","Done","Succeed","Aborted","exports"],"sources":["definition.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\nimport { StepFunctionDefinition, StepFunctionDefinitionStatesType } from \"./types\";\n\nexport interface BackgroundTaskParams {\n lambdaName: string;\n lambdaArn: pulumi.Input<string>;\n}\n\nexport const createBackgroundTaskDefinition = (\n params: BackgroundTaskParams\n): StepFunctionDefinition => {\n const { lambdaName, lambdaArn } = params;\n return {\n Comment: \"Background tasks\",\n StartAt: \"TransformEvent\",\n States: {\n /**\n * Transform the EventBridge event to a format that will be used in the Lambda.\n */\n TransformEvent: {\n Type: StepFunctionDefinitionStatesType.Pass,\n Next: \"Run\",\n Parameters: {\n \"webinyTaskId.$\": \"$.detail.webinyTaskId\",\n \"webinyTaskDefinitionId.$\": \"$.detail.webinyTaskDefinitionId\",\n \"tenant.$\": \"$.detail.tenant\",\n \"locale.$\": \"$.detail.locale\",\n \"delay.$\": \"$.detail.delay\"\n }\n },\n /**\n * Run the task and wait for the response from lambda.\n * On some fatal error go to Error step.\n * In other cases, check the status of the task.\n */\n Run: {\n Type: StepFunctionDefinitionStatesType.Task,\n Resource: lambdaArn,\n Next: \"CheckStatus\",\n ResultPath: \"$\",\n InputPath: \"$\",\n /**\n * Parameters will be received as an event in the Lambda.\n * Task Handler determines that it can run a task based on the Payload.webinyTaskId parameter - it must be set!\n */\n Parameters: {\n name: lambdaName,\n payload: {\n \"webinyTaskId.$\": \"$.webinyTaskId\",\n \"webinyTaskDefinitionId.$\": \"$.webinyTaskDefinitionId\",\n \"locale.$\": \"$.locale\",\n \"tenant.$\": \"$.tenant\",\n \"delay.$\": \"$.delay\",\n endpoint: \"manage\",\n \"executionName.$\": \"$$.Execution.Name\",\n \"stateMachineId.$\": \"$$.StateMachine.Id\"\n }\n },\n Catch: [\n {\n ErrorEquals: [\"States.ALL\"],\n Next: \"UnknownError\"\n }\n ]\n },\n /**\n * On CONTINUE, go back to Run.\n * On ERROR, go to Error step.\n * On DONE, go to Done step.\n */\n CheckStatus: {\n Type: StepFunctionDefinitionStatesType.Choice,\n InputPath: \"$\",\n Choices: [\n /**\n * There is a possibility that the task will return a CONTINUE status and a waitUntil value.\n * This means that task will wait for the specified time and then continue.\n * It can be used to handle waiting for child tasks or some resource to be created.\n */\n {\n And: [\n {\n Variable: \"$.status\",\n StringEquals: \"continue\"\n },\n {\n Variable: \"$.wait\",\n IsPresent: true\n },\n {\n Variable: \"$.wait\",\n IsNumeric: true\n },\n {\n Variable: \"$.wait\",\n NumericGreaterThan: 0\n }\n ],\n Next: \"Waiter\"\n },\n /**\n * When no wait value is present, go to Run.\n */\n {\n Variable: \"$.status\",\n StringEquals: \"continue\",\n Next: \"Run\"\n },\n {\n Variable: \"$.status\",\n StringEquals: \"error\",\n Next: \"Error\"\n },\n {\n Variable: \"$.status\",\n StringEquals: \"done\",\n Next: \"Done\"\n },\n {\n Variable: \"$.status\",\n StringEquals: \"aborted\",\n Next: \"Aborted\"\n }\n ],\n Default: \"UnknownStatus\"\n },\n Waiter: {\n Type: StepFunctionDefinitionStatesType.Wait,\n SecondsPath: \"$.wait\",\n Next: \"Run\"\n },\n UnknownError: {\n Type: StepFunctionDefinitionStatesType.Fail,\n Cause: \"Fatal error - unknown task error.\"\n },\n /**\n * Unknown task status on Choice step.\n */\n UnknownStatus: {\n Type: StepFunctionDefinitionStatesType.Fail,\n Cause: \"Fatal error - unknown status.\"\n },\n /**\n * Fail the task and output the error.\n */\n Error: {\n Type: StepFunctionDefinitionStatesType.Fail,\n CausePath: \"States.JsonToString($.error)\",\n ErrorPath: \"$.error.message\"\n },\n /**\n * Complete the task.\n */\n Done: {\n Type: StepFunctionDefinitionStatesType.Succeed\n },\n Aborted: {\n Type: StepFunctionDefinitionStatesType.Succeed\n }\n }\n };\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAOO,MAAMC,8BAA8B,GACvCC,MAA4B,IACH;EACzB,MAAM;IAAEC,UAAU;IAAEC;EAAU,CAAC,GAAGF,MAAM;EACxC,OAAO;IACHG,OAAO,EAAE,kBAAkB;IAC3BC,OAAO,EAAE,gBAAgB;IACzBC,MAAM,EAAE;MACJ;AACZ;AACA;MACYC,cAAc,EAAE;QACZC,IAAI,EAAEC,uCAAgC,CAACC,IAAI;QAC3CC,IAAI,EAAE,KAAK;QACXC,UAAU,EAAE;UACR,gBAAgB,EAAE,uBAAuB;UACzC,0BAA0B,EAAE,iCAAiC;UAC7D,UAAU,EAAE,iBAAiB;UAC7B,UAAU,EAAE,iBAAiB;UAC7B,SAAS,EAAE;QACf;MACJ,CAAC;MACD;AACZ;AACA;AACA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AC,EACD;UACIgB,QAAQ,EAAE,UAAU;UACpBC,YAAY,EAAE,MAAM;UACpBjB,IAAI,EAAE;QACV,CAAC,EACD;UACIgB,QAAQ,EAAE,UAAU;UACpBC,YAAY,EAAE,SAAS;UACvBjB,IAAI,EAAE;QACV,CAAC,CACJ;QACDqB,OAAO,EAAE;MACb,CAAC;MACDC,MAAM,EAAE;QACJzB,IAAI,EAAEC,uCAAgC,CAACyB,IAAI;QAC3CC,WAAW,EAAE,QAAQ;QACrBxB,IAAI,EAAE;MACV,CAAC;MACDyB,YAAY,EAAE;QACV5B,IAAI,EAAEC,uCAAgC,CAAC4B,IAAI;QAC3CC,KAAK,EAAE;MACX,CAAC;MACD;AACZ;AACA;MACYC,aAAa,EAAE;QACX/B,IAAI,EAAEC,uCAAgC,CAAC4B,IAAI;QAC3CC,KAAK,EAAE;MACX,CAAC;MACD;AACZ;AACA;MACYE,KAAK,EAAE;QACHhC,IAAI,EAAEC,uCAAgC,CAAC4B,IAAI;QAC3CI,SAAS,EAAE,8BAA8B;QACzCC,SAAS,EAAE;MACf,CAAC;MACD;AACZ;AACA;MACYC,IAAI,EAAE;QACFnC,IAAI,EAAEC,uCAAgC,CAACmC;MAC3C,CAAC;MACDC,OAAO,EAAE;QACLrC,IAAI,EAAEC,uCAAgC,CAACmC;MAC3C;IACJ;EACJ,CAAC;AACL,CAAC;AAACE,OAAA,CAAA9C,8BAAA,GAAAA,8BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_types","require","createBackgroundTaskDefinition","params","lambdaName","lambdaArn","Comment","StartAt","States","TransformEvent","Type","StepFunctionDefinitionStatesType","Pass","Next","Parameters","Run","Task","Resource","ResultPath","InputPath","name","payload","endpoint","Catch","ErrorEquals","CheckStatus","Choice","Choices","Variable","IsNull","And","StringEquals","IsPresent","IsNumeric","NumericGreaterThan","Default","Waiter","Wait","SecondsPath","UnknownError","Fail","Cause","UnknownStatus","Error","CausePath","ErrorPath","Done","Succeed","Aborted","exports"],"sources":["definition.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\nimport { StepFunctionDefinition, StepFunctionDefinitionStatesType } from \"./types\";\n\nexport interface BackgroundTaskParams {\n lambdaName: string;\n lambdaArn: pulumi.Input<string>;\n}\n\nexport const createBackgroundTaskDefinition = (\n params: BackgroundTaskParams\n): StepFunctionDefinition => {\n const { lambdaName, lambdaArn } = params;\n return {\n Comment: \"Background tasks\",\n StartAt: \"TransformEvent\",\n States: {\n /**\n * Transform the EventBridge event to a format that will be used in the Lambda.\n */\n TransformEvent: {\n Type: StepFunctionDefinitionStatesType.Pass,\n Next: \"Run\",\n Parameters: {\n \"webinyTaskId.$\": \"$.detail.webinyTaskId\",\n \"webinyTaskDefinitionId.$\": \"$.detail.webinyTaskDefinitionId\",\n \"tenant.$\": \"$.detail.tenant\",\n \"locale.$\": \"$.detail.locale\",\n \"delay.$\": \"$.detail.delay\"\n }\n },\n /**\n * Run the task and wait for the response from lambda.\n * On some fatal error go to Error step.\n * In other cases, check the status of the task.\n */\n Run: {\n Type: StepFunctionDefinitionStatesType.Task,\n Resource: lambdaArn,\n Next: \"CheckStatus\",\n ResultPath: \"$\",\n InputPath: \"$\",\n /**\n * Parameters will be received as an event in the Lambda.\n * Task Handler determines that it can run a task based on the Payload.webinyTaskId parameter - it must be set!\n */\n Parameters: {\n name: lambdaName,\n payload: {\n \"webinyTaskId.$\": \"$.webinyTaskId\",\n \"webinyTaskDefinitionId.$\": \"$.webinyTaskDefinitionId\",\n \"locale.$\": \"$.locale\",\n \"tenant.$\": \"$.tenant\",\n \"delay.$\": \"$.delay\",\n endpoint: \"manage\",\n \"executionName.$\": \"$$.Execution.Name\",\n \"stateMachineId.$\": \"$$.StateMachine.Id\"\n }\n },\n Catch: [\n {\n ErrorEquals: [\"States.ALL\"],\n Next: \"UnknownError\"\n }\n ]\n },\n /**\n * On CONTINUE, go back to Run.\n * On ERROR, go to Error step.\n * On DONE, go to Done step.\n */\n CheckStatus: {\n Type: StepFunctionDefinitionStatesType.Choice,\n InputPath: \"$\",\n Choices: [\n /**\n * There is a possibility that the task will return a CONTINUE status and a waitUntil value.\n * This means that task will wait for the specified time and then continue.\n * It can be used to handle waiting for child tasks or some resource to be created.\n */\n {\n Variable: \"$\",\n IsNull: true,\n Next: \"UnknownError\"\n },\n {\n And: [\n {\n Variable: \"$.status\",\n StringEquals: \"continue\"\n },\n {\n Variable: \"$.wait\",\n IsPresent: true\n },\n {\n Variable: \"$.wait\",\n IsNumeric: true\n },\n {\n Variable: \"$.wait\",\n NumericGreaterThan: 0\n }\n ],\n Next: \"Waiter\"\n },\n /**\n * When no wait value is present, go to Run.\n */\n {\n Variable: \"$.status\",\n StringEquals: \"continue\",\n Next: \"Run\"\n },\n {\n Variable: \"$.status\",\n StringEquals: \"error\",\n Next: \"Error\"\n },\n {\n Variable: \"$.status\",\n StringEquals: \"done\",\n Next: \"Done\"\n },\n {\n Variable: \"$.status\",\n StringEquals: \"aborted\",\n Next: \"Aborted\"\n }\n ],\n Default: \"UnknownStatus\"\n },\n Waiter: {\n Type: StepFunctionDefinitionStatesType.Wait,\n SecondsPath: \"$.wait\",\n Next: \"Run\"\n },\n UnknownError: {\n Type: StepFunctionDefinitionStatesType.Fail,\n Cause: \"Fatal error - unknown task error.\"\n },\n /**\n * Unknown task status on Choice step.\n */\n UnknownStatus: {\n Type: StepFunctionDefinitionStatesType.Fail,\n Cause: \"Fatal error - unknown status.\"\n },\n /**\n * Fail the task and output the error.\n */\n Error: {\n Type: StepFunctionDefinitionStatesType.Fail,\n CausePath: \"States.JsonToString($.error)\",\n ErrorPath: \"$.error.message\"\n },\n /**\n * Complete the task.\n */\n Done: {\n Type: StepFunctionDefinitionStatesType.Succeed\n },\n Aborted: {\n Type: StepFunctionDefinitionStatesType.Succeed\n }\n }\n };\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAOO,MAAMC,8BAA8B,GACvCC,MAA4B,IACH;EACzB,MAAM;IAAEC,UAAU;IAAE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3C,CAAC;MACDC,OAAO,EAAE;QACLtC,IAAI,EAAEC,uCAAgC,CAACoC;MAC3C;IACJ;EACJ,CAAC;AACL,CAAC;AAACE,OAAA,CAAA/C,8BAAA,GAAAA,8BAAA","ignoreList":[]}
@@ -21,6 +21,7 @@ export interface StepFunctionDefinitionStatesChoiceBase {
21
21
  StringEquals?: string;
22
22
  StringMatches?: string;
23
23
  IsPresent?: boolean;
24
+ IsNull?: boolean;
24
25
  }
25
26
  export interface StepFunctionDefinitionStatesChoiceAndItem {
26
27
  Variable: string;
@@ -35,7 +36,7 @@ export interface StepFunctionDefinitionStatesChoiceAnd {
35
36
  And: StepFunctionDefinitionStatesChoiceAndItem[];
36
37
  Next: string;
37
38
  }
38
- export declare type StepFunctionDefinitionStatesChoice = StepFunctionDefinitionStatesChoiceBase | StepFunctionDefinitionStatesChoiceAnd;
39
+ export type StepFunctionDefinitionStatesChoice = StepFunctionDefinitionStatesChoiceBase | StepFunctionDefinitionStatesChoiceAnd;
39
40
  export interface StepFunctionDefinitionStatesTypeBase {
40
41
  Type: StepFunctionDefinitionStatesType;
41
42
  Comment?: string;
@@ -80,7 +81,7 @@ export interface StepFunctionDefinitionStatesTypeWait extends StepFunctionDefini
80
81
  SecondsPath?: string;
81
82
  TimestampPath?: string;
82
83
  }
83
- export declare type StepFunctionDefinitionStatesTypes = StepFunctionDefinitionStatesTypeTask | StepFunctionDefinitionStatesTypePass | StepFunctionDefinitionStatesTypeChoice | StepFunctionDefinitionStatesTypeFail | StepFunctionDefinitionStatesTypeSucceed | StepFunctionDefinitionStatesTypeWait;
84
+ export type StepFunctionDefinitionStatesTypes = StepFunctionDefinitionStatesTypeTask | StepFunctionDefinitionStatesTypePass | StepFunctionDefinitionStatesTypeChoice | StepFunctionDefinitionStatesTypeFail | StepFunctionDefinitionStatesTypeSucceed | StepFunctionDefinitionStatesTypeWait;
84
85
  export interface StepFunctionDefinition {
85
86
  Comment: string;
86
87
  StartAt: string;
@@ -1 +1 @@
1
- {"version":3,"names":["StepFunctionDefinitionStatesType","exports"],"sources":["types.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\n\n/**\n * Update types if required. Try to avoid generic objects\n */\nexport enum StepFunctionDefinitionStatesType {\n Task = \"Task\",\n Pass = \"Pass\",\n Choice = \"Choice\",\n Wait = \"Wait\",\n Fail = \"Fail\",\n Succeed = \"Succeed\"\n}\n\nexport interface StepFunctionDefinitionStatesCatch {\n ErrorEquals: string[];\n Next: string;\n ResultPath?: string;\n}\n\nexport interface StepFunctionDefinitionStatesChoiceBase {\n Variable: string;\n Next: string;\n StringEquals?: string;\n StringMatches?: string;\n IsPresent?: boolean;\n}\n\nexport interface StepFunctionDefinitionStatesChoiceAndItem {\n Variable: string;\n StringEquals?: string;\n StringMatches?: string;\n IsPresent?: boolean;\n IsTimestamp?: boolean;\n IsNumeric?: boolean;\n NumericGreaterThan?: number;\n}\nexport interface StepFunctionDefinitionStatesChoiceAnd {\n And: StepFunctionDefinitionStatesChoiceAndItem[];\n Next: string;\n}\n\nexport type StepFunctionDefinitionStatesChoice =\n | StepFunctionDefinitionStatesChoiceBase\n | StepFunctionDefinitionStatesChoiceAnd;\n\nexport interface StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType;\n Comment?: string;\n InputPath?: string;\n OutputPath?: string;\n}\n\nexport interface StepFunctionDefinitionStatesTypeTask extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Task;\n Resource: pulumi.Input<string>;\n Next: string;\n ResultPath?: string;\n Parameters: Record<string, any>;\n Catch: StepFunctionDefinitionStatesCatch[];\n End?: boolean;\n}\n\nexport interface StepFunctionDefinitionStatesTypePass extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Pass;\n Next: string;\n ResultPath?: string;\n Parameters: Record<string, any>;\n End?: boolean;\n}\n\nexport interface StepFunctionDefinitionStatesTypeChoice\n extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Choice;\n Choices: StepFunctionDefinitionStatesChoice[];\n Default?: string;\n}\n\nexport interface StepFunctionDefinitionStatesTypeFail extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Fail;\n Error?: string;\n Cause?: string;\n CausePath?: string;\n ErrorPath?: string;\n}\n\nexport interface StepFunctionDefinitionStatesTypeSucceed\n extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Succeed;\n}\n\nexport interface StepFunctionDefinitionStatesTypeWait extends StepFunctionDefinitionStatesTypeBase {\n Next: string;\n Seconds?: number;\n Timestamp?: string;\n SecondsPath?: string;\n TimestampPath?: string;\n}\n\nexport type StepFunctionDefinitionStatesTypes =\n | StepFunctionDefinitionStatesTypeTask\n | StepFunctionDefinitionStatesTypePass\n | StepFunctionDefinitionStatesTypeChoice\n | StepFunctionDefinitionStatesTypeFail\n | StepFunctionDefinitionStatesTypeSucceed\n | StepFunctionDefinitionStatesTypeWait;\n\nexport interface StepFunctionDefinition {\n Comment: string;\n StartAt: string;\n States: {\n [key: string]: StepFunctionDefinitionStatesTypes;\n };\n}\n"],"mappings":";;;;;;AAEA;AACA;AACA;AAFA,IAGYA,gCAAgC,GAAAC,OAAA,CAAAD,gCAAA,0BAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAA,OAAhCA,gCAAgC;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["StepFunctionDefinitionStatesType","exports"],"sources":["types.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\n\n/**\n * Update types if required. Try to avoid generic objects\n */\nexport enum StepFunctionDefinitionStatesType {\n Task = \"Task\",\n Pass = \"Pass\",\n Choice = \"Choice\",\n Wait = \"Wait\",\n Fail = \"Fail\",\n Succeed = \"Succeed\"\n}\n\nexport interface StepFunctionDefinitionStatesCatch {\n ErrorEquals: string[];\n Next: string;\n ResultPath?: string;\n}\n\nexport interface StepFunctionDefinitionStatesChoiceBase {\n Variable: string;\n Next: string;\n StringEquals?: string;\n StringMatches?: string;\n IsPresent?: boolean;\n IsNull?: boolean;\n}\n\nexport interface StepFunctionDefinitionStatesChoiceAndItem {\n Variable: string;\n StringEquals?: string;\n StringMatches?: string;\n IsPresent?: boolean;\n IsTimestamp?: boolean;\n IsNumeric?: boolean;\n NumericGreaterThan?: number;\n}\nexport interface StepFunctionDefinitionStatesChoiceAnd {\n And: StepFunctionDefinitionStatesChoiceAndItem[];\n Next: string;\n}\n\nexport type StepFunctionDefinitionStatesChoice =\n | StepFunctionDefinitionStatesChoiceBase\n | StepFunctionDefinitionStatesChoiceAnd;\n\nexport interface StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType;\n Comment?: string;\n InputPath?: string;\n OutputPath?: string;\n}\n\nexport interface StepFunctionDefinitionStatesTypeTask extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Task;\n Resource: pulumi.Input<string>;\n Next: string;\n ResultPath?: string;\n Parameters: Record<string, any>;\n Catch: StepFunctionDefinitionStatesCatch[];\n End?: boolean;\n}\n\nexport interface StepFunctionDefinitionStatesTypePass extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Pass;\n Next: string;\n ResultPath?: string;\n Parameters: Record<string, any>;\n End?: boolean;\n}\n\nexport interface StepFunctionDefinitionStatesTypeChoice\n extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Choice;\n Choices: StepFunctionDefinitionStatesChoice[];\n Default?: string;\n}\n\nexport interface StepFunctionDefinitionStatesTypeFail extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Fail;\n Error?: string;\n Cause?: string;\n CausePath?: string;\n ErrorPath?: string;\n}\n\nexport interface StepFunctionDefinitionStatesTypeSucceed\n extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Succeed;\n}\n\nexport interface StepFunctionDefinitionStatesTypeWait extends StepFunctionDefinitionStatesTypeBase {\n Next: string;\n Seconds?: number;\n Timestamp?: string;\n SecondsPath?: string;\n TimestampPath?: string;\n}\n\nexport type StepFunctionDefinitionStatesTypes =\n | StepFunctionDefinitionStatesTypeTask\n | StepFunctionDefinitionStatesTypePass\n | StepFunctionDefinitionStatesTypeChoice\n | StepFunctionDefinitionStatesTypeFail\n | StepFunctionDefinitionStatesTypeSucceed\n | StepFunctionDefinitionStatesTypeWait;\n\nexport interface StepFunctionDefinition {\n Comment: string;\n StartAt: string;\n States: {\n [key: string]: StepFunctionDefinitionStatesTypes;\n };\n}\n"],"mappings":";;;;;;AAEA;AACA;AACA;AAFA,IAGYA,gCAAgC,GAAAC,OAAA,CAAAD,gCAAA,0BAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAA,OAAhCA,gCAAgC;AAAA","ignoreList":[]}
@@ -1,23 +1,27 @@
1
1
  import { PulumiAppParam, PulumiAppParamCallback } from "@webiny/pulumi";
2
2
  import { CustomDomainParams } from "../customDomain";
3
- export declare type ApiPulumiApp = ReturnType<typeof createApiPulumiApp>;
3
+ export type ApiPulumiApp = ReturnType<typeof createApiPulumiApp>;
4
+ export interface ApiElasticsearchConfig {
5
+ domainName: string;
6
+ indexPrefix: string;
7
+ sharedIndexes: boolean;
8
+ }
9
+ export interface ApiOpenSearchConfig {
10
+ domainName: string;
11
+ indexPrefix: string;
12
+ sharedIndexes: boolean;
13
+ }
4
14
  export interface CreateApiPulumiAppParams {
5
15
  /**
6
16
  * Enables ElasticSearch infrastructure.
7
17
  * Note that it requires also changes in application code.
8
18
  */
9
- elasticSearch?: PulumiAppParam<boolean | Partial<{
10
- domainName: string;
11
- indexPrefix: string;
12
- }>>;
19
+ elasticSearch?: PulumiAppParam<boolean | Partial<ApiElasticsearchConfig>>;
13
20
  /**
14
21
  * Enables OpenSearch infrastructure.
15
22
  * Note that it requires also changes in application code.
16
23
  */
17
- openSearch?: PulumiAppParam<boolean | Partial<{
18
- domainName: string;
19
- indexPrefix: string;
20
- }>>;
24
+ openSearch?: PulumiAppParam<boolean | Partial<ApiOpenSearchConfig>>;
21
25
  /**
22
26
  * Enables or disables VPC for the API.
23
27
  * For VPC to work you also have to enable it in the Core application.
@@ -88,10 +92,10 @@ export declare const createApiPulumiApp: (projectAppParams?: CreateApiPulumiAppP
88
92
  backgroundTask: {
89
93
  backgroundTask: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function").Function>;
90
94
  stepFunction: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/sfn/stateMachine").StateMachine>;
91
- eventRole: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
95
+ stepFunctionRole: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
96
+ stepFunctionPolicy: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/policy").Policy>;
92
97
  eventPolicy: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/policy").Policy>;
93
98
  eventRolePolicyAttachment: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/rolePolicyAttachment").RolePolicyAttachment>;
94
- eventRule: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudwatch/eventRule").EventRule>;
95
99
  eventTarget: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudwatch/eventTarget").EventTarget>;
96
100
  };
97
101
  }> & import("../lambdaUtils").WithCommonLambdaEnvVariables & import("../../utils/withServiceManifest").WithServiceManifest;
@@ -32,6 +32,9 @@ const createApiPulumiApp = (projectAppParams = {}) => {
32
32
  if (params.indexPrefix) {
33
33
  process.env.ELASTIC_SEARCH_INDEX_PREFIX = params.indexPrefix;
34
34
  }
35
+ if (params.sharedIndexes) {
36
+ process.env.ELASTICSEARCH_SHARED_INDEXES = "true";
37
+ }
35
38
  }
36
39
  }
37
40
  const pulumiResourceNamePrefix = app.getParam(projectAppParams.pulumiResourceNamePrefix);
@@ -75,6 +78,7 @@ const createApiPulumiApp = (projectAppParams = {}) => {
75
78
  // Not required. Useful for testing purposes / ephemeral environments.
76
79
  // https://www.webiny.com/docs/key-topics/ci-cd/testing/slow-ephemeral-environments
77
80
  ELASTIC_SEARCH_INDEX_PREFIX: process.env.ELASTIC_SEARCH_INDEX_PREFIX,
81
+ ELASTICSEARCH_SHARED_INDEXES: process.env.ELASTICSEARCH_SHARED_INDEXES,
78
82
  S3_BUCKET: core.fileManagerBucketId,
79
83
  WEBINY_LOGS_FORWARD_URL
80
84
  }
@@ -99,6 +103,7 @@ const createApiPulumiApp = (projectAppParams = {}) => {
99
103
  // Not required. Useful for testing purposes / ephemeral environments.
100
104
  // https://www.webiny.com/docs/key-topics/ci-cd/testing/slow-ephemeral-environments
101
105
  ELASTIC_SEARCH_INDEX_PREFIX: process.env.ELASTIC_SEARCH_INDEX_PREFIX,
106
+ ELASTICSEARCH_SHARED_INDEXES: process.env.ELASTICSEARCH_SHARED_INDEXES,
102
107
  S3_BUCKET: core.fileManagerBucketId,
103
108
  EVENT_BUS: core.eventBusArn,
104
109
  IMPORT_CREATE_HANDLER: pageBuilder.import.functions.create.output.arn,
@@ -218,6 +223,7 @@ const createApiPulumiApp = (projectAppParams = {}) => {
218
223
  app.addServiceManifest({
219
224
  name: "api",
220
225
  manifest: {
226
+ bgTaskSfn: baseApp.resources.backgroundTask.stepFunction.output.arn,
221
227
  cloudfront: {
222
228
  distributionId: baseApp.resources.cloudfront.output.id
223
229
  }