@webiny/pulumi-aws 6.0.0-alpha.0 → 6.0.0-alpha.1
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/apps/admin/createAdminPulumiApp.d.ts +3 -2
- package/apps/admin/createAdminPulumiApp.js +1 -0
- package/apps/admin/createAdminPulumiApp.js.map +1 -1
- package/apps/api/ApiApwScheduler.d.ts +1 -1
- package/apps/api/ApiApwScheduler.js.map +1 -1
- package/apps/api/ApiBackgroundTask.d.ts +1 -1
- package/apps/api/ApiBackgroundTask.js.map +1 -1
- package/apps/api/ApiCloudfront.d.ts +1 -1
- package/apps/api/ApiCloudfront.js.map +1 -1
- package/apps/api/ApiFileManager.d.ts +7 -1
- package/apps/api/ApiFileManager.js +6 -0
- package/apps/api/ApiFileManager.js.map +1 -1
- package/apps/api/ApiGateway.d.ts +2 -2
- package/apps/api/ApiGateway.js.map +1 -1
- package/apps/api/ApiGraphql.d.ts +1 -1
- package/apps/api/ApiGraphql.js.map +1 -1
- package/apps/api/ApiMigration.d.ts +1 -1
- package/apps/api/ApiMigration.js.map +1 -1
- package/apps/api/ApiOutput.d.ts +11 -1
- package/apps/api/ApiOutput.js +11 -1
- package/apps/api/ApiOutput.js.map +1 -1
- package/apps/api/ApiPageBuilder.d.ts +1 -1
- package/apps/api/ApiPageBuilder.js.map +1 -1
- package/apps/api/ApiScheduler.d.ts +8 -0
- package/apps/api/ApiScheduler.js +105 -0
- package/apps/api/ApiScheduler.js.map +1 -0
- package/apps/api/ApiWebsocket.d.ts +1 -1
- package/apps/api/ApiWebsocket.js.map +1 -1
- package/apps/api/backgroundTask/definition.d.ts +2 -2
- package/apps/api/backgroundTask/definition.js.map +1 -1
- package/apps/api/backgroundTask/policy.d.ts +2 -2
- package/apps/api/backgroundTask/policy.js.map +1 -1
- package/apps/api/backgroundTask/role.d.ts +2 -2
- package/apps/api/backgroundTask/role.js.map +1 -1
- package/apps/api/backgroundTask/types.d.ts +1 -1
- package/apps/api/backgroundTask/types.js.map +1 -1
- package/apps/api/createApiPulumiApp.d.ts +19 -13
- package/apps/api/createApiPulumiApp.js +50 -19
- package/apps/api/createApiPulumiApp.js.map +1 -1
- package/apps/awsUtils.d.ts +1 -1
- package/apps/awsUtils.js.map +1 -1
- package/apps/blueGreen/createBlueGreenPulumiApp.d.ts +7 -1
- package/apps/blueGreen/createBlueGreenPulumiApp.js +2 -2
- package/apps/blueGreen/createBlueGreenPulumiApp.js.map +1 -1
- package/apps/blueGreen/domains/attachDomainsToOutput.d.ts +1 -1
- package/apps/blueGreen/domains/attachDomainsToOutput.js.map +1 -1
- package/apps/blueGreen/types.d.ts +4 -1
- package/apps/blueGreen/types.js.map +1 -1
- package/apps/common/CoreOutput.d.ts +2 -1
- package/apps/common/CoreOutput.js +1 -0
- package/apps/common/CoreOutput.js.map +1 -1
- package/apps/common/VpcConfig.d.ts +1 -1
- package/apps/common/VpcConfig.js.map +1 -1
- package/apps/core/CoreCognito.d.ts +1 -1
- package/apps/core/CoreCognito.js.map +1 -1
- package/apps/core/CoreDynamo.d.ts +1 -1
- package/apps/core/CoreDynamo.js.map +1 -1
- package/apps/core/CoreElasticSearch.d.ts +1 -1
- package/apps/core/CoreElasticSearch.js +7 -1
- package/apps/core/CoreElasticSearch.js.map +1 -1
- package/apps/core/CoreEventBus.js.map +1 -1
- package/apps/core/CoreFileManager.d.ts +1 -1
- package/apps/core/CoreFileManager.js.map +1 -1
- package/apps/core/CoreOpenSearch.d.ts +1 -1
- package/apps/core/CoreOpenSearch.js +7 -1
- package/apps/core/CoreOpenSearch.js.map +1 -1
- package/apps/core/CoreVpc.d.ts +1 -1
- package/apps/core/CoreVpc.js.map +1 -1
- package/apps/core/LogDynamo.d.ts +1 -1
- package/apps/core/LogDynamo.js.map +1 -1
- package/apps/core/WatchCommand.js.map +1 -1
- package/apps/core/cognitoIdentityProviders/amazon.d.ts +3 -3
- package/apps/core/cognitoIdentityProviders/amazon.js.map +1 -1
- package/apps/core/cognitoIdentityProviders/apple.d.ts +3 -3
- package/apps/core/cognitoIdentityProviders/apple.js.map +1 -1
- package/apps/core/cognitoIdentityProviders/configure.d.ts +3 -3
- package/apps/core/cognitoIdentityProviders/configure.js.map +1 -1
- package/apps/core/cognitoIdentityProviders/facebook.d.ts +3 -3
- package/apps/core/cognitoIdentityProviders/facebook.js.map +1 -1
- package/apps/core/cognitoIdentityProviders/getIdpConfig.d.ts +2 -2
- package/apps/core/cognitoIdentityProviders/getIdpConfig.js.map +1 -1
- package/apps/core/cognitoIdentityProviders/google.d.ts +3 -3
- package/apps/core/cognitoIdentityProviders/google.js.map +1 -1
- package/apps/core/cognitoIdentityProviders/oidc.d.ts +3 -3
- package/apps/core/cognitoIdentityProviders/oidc.js.map +1 -1
- package/apps/core/createCorePulumiApp.d.ts +1 -1
- package/apps/core/createCorePulumiApp.js +2 -1
- package/apps/core/createCorePulumiApp.js.map +1 -1
- package/apps/createAppBucket.d.ts +1 -1
- package/apps/createAppBucket.js.map +1 -1
- package/apps/customDomain.d.ts +3 -3
- package/apps/customDomain.js.map +1 -1
- package/apps/lambdaUtils.d.ts +3 -2
- package/apps/lambdaUtils.js +21 -3
- package/apps/lambdaUtils.js.map +1 -1
- package/apps/react/createReactPulumiApp.d.ts +2 -2
- package/apps/react/createReactPulumiApp.js.map +1 -1
- package/apps/syncSystem/SyncSystemDynamo.d.ts +1 -1
- package/apps/syncSystem/SyncSystemDynamo.js.map +1 -1
- package/apps/syncSystem/SyncSystemDynamoDb.d.ts +3 -0
- package/apps/syncSystem/SyncSystemDynamoDb.js +55 -0
- package/apps/syncSystem/SyncSystemDynamoDb.js.map +1 -0
- package/apps/syncSystem/SyncSystemEventBus.d.ts +6 -0
- package/apps/syncSystem/SyncSystemEventBus.js +84 -0
- package/apps/syncSystem/SyncSystemEventBus.js.map +1 -0
- package/apps/syncSystem/SyncSystemLambda.d.ts +1 -1
- package/apps/syncSystem/SyncSystemLambda.js.map +1 -1
- package/apps/syncSystem/SyncSystemOutput.d.ts +3 -0
- package/apps/syncSystem/SyncSystemOutput.js +26 -0
- package/apps/syncSystem/SyncSystemOutput.js.map +1 -0
- package/apps/syncSystem/SyncSystemResolverLambda.d.ts +8 -0
- package/apps/syncSystem/SyncSystemResolverLambda.js +78 -0
- package/apps/syncSystem/SyncSystemResolverLambda.js.map +1 -0
- package/apps/syncSystem/SyncSystemSQS.d.ts +3 -4
- package/apps/syncSystem/SyncSystemSQS.js +33 -12
- package/apps/syncSystem/SyncSystemSQS.js.map +1 -1
- package/apps/syncSystem/SyncSystemWorkerLambda.d.ts +7 -0
- package/apps/syncSystem/SyncSystemWorkerLambda.js +57 -0
- package/apps/syncSystem/SyncSystemWorkerLambda.js.map +1 -0
- package/apps/syncSystem/api/addServiceManifest.d.ts +8 -0
- package/apps/syncSystem/api/addServiceManifest.js +25 -0
- package/apps/syncSystem/api/addServiceManifest.js.map +1 -0
- package/apps/syncSystem/api/attachCognitoPermissions.d.ts +14 -0
- package/apps/syncSystem/api/attachCognitoPermissions.js +67 -0
- package/apps/syncSystem/api/attachCognitoPermissions.js.map +1 -0
- package/apps/syncSystem/api/attachDynamoDbPermissions.d.ts +13 -0
- package/apps/syncSystem/api/attachDynamoDbPermissions.js +53 -0
- package/apps/syncSystem/api/attachDynamoDbPermissions.js.map +1 -0
- package/apps/syncSystem/api/attachEventBusPermissions.d.ts +18 -0
- package/apps/syncSystem/api/attachEventBusPermissions.js +66 -0
- package/apps/syncSystem/api/attachEventBusPermissions.js.map +1 -0
- package/apps/syncSystem/api/attachS3Permissions.d.ts +14 -0
- package/apps/syncSystem/api/attachS3Permissions.js +59 -0
- package/apps/syncSystem/api/attachS3Permissions.js.map +1 -0
- package/apps/syncSystem/api/index.d.ts +9 -0
- package/apps/syncSystem/api/index.js +65 -0
- package/apps/syncSystem/api/index.js.map +1 -0
- package/apps/syncSystem/constants.d.ts +1 -0
- package/apps/syncSystem/constants.js +9 -0
- package/apps/syncSystem/constants.js.map +1 -0
- package/apps/syncSystem/createSyncResourceName.d.ts +4 -0
- package/apps/syncSystem/createSyncResourceName.js +17 -0
- package/apps/syncSystem/createSyncResourceName.js.map +1 -0
- package/apps/syncSystem/createSyncSystemPulumiApp.d.ts +19 -10
- package/apps/syncSystem/createSyncSystemPulumiApp.js +107 -34
- package/apps/syncSystem/createSyncSystemPulumiApp.js.map +1 -1
- package/apps/syncSystem/customApp.d.ts +6 -0
- package/apps/syncSystem/customApp.js +26 -0
- package/apps/syncSystem/customApp.js.map +1 -0
- package/apps/syncSystem/getSyncSystemOutput.d.ts +6 -0
- package/apps/syncSystem/getSyncSystemOutput.js +28 -0
- package/apps/syncSystem/getSyncSystemOutput.js.map +1 -0
- package/apps/syncSystem/lambda/createSyncSystemResolverLambdaPolicy.d.ts +7 -0
- package/apps/syncSystem/lambda/createSyncSystemResolverLambdaPolicy.js +55 -0
- package/apps/syncSystem/lambda/createSyncSystemResolverLambdaPolicy.js.map +1 -0
- package/apps/syncSystem/types.d.ts +55 -0
- package/apps/syncSystem/types.js +7 -0
- package/apps/syncSystem/types.js.map +1 -0
- package/apps/tenantRouter.d.ts +1 -1
- package/apps/tenantRouter.js.map +1 -1
- package/apps/website/WebsitePrerendering.d.ts +1 -1
- package/apps/website/WebsitePrerendering.js.map +1 -1
- package/apps/website/createWebsitePulumiApp.d.ts +2 -2
- package/apps/website/createWebsitePulumiApp.js.map +1 -1
- package/enterprise/api/handleGuardDutyEvents.d.ts +1 -1
- package/enterprise/api/handleGuardDutyEvents.js.map +1 -1
- package/enterprise/createApiPulumiApp.d.ts +13 -2
- package/enterprise/createApiPulumiApp.js.map +1 -1
- package/enterprise/createCorePulumiApp.d.ts +2 -2
- package/enterprise/createCorePulumiApp.js.map +1 -1
- package/enterprise/createSyncSystemPulumiApp.d.ts +13 -8
- package/enterprise/createSyncSystemPulumiApp.js +1 -1
- package/enterprise/createSyncSystemPulumiApp.js.map +1 -1
- package/enterprise/createWebsitePulumiApp.d.ts +2 -2
- package/enterprise/createWebsitePulumiApp.js.map +1 -1
- package/package.json +12 -12
- package/utils/addDomainsUrlsOutputs.d.ts +2 -2
- package/utils/addDomainsUrlsOutputs.js.map +1 -1
- package/utils/addServiceManifestTableItem.d.ts +1 -1
- package/utils/addServiceManifestTableItem.js.map +1 -1
- package/utils/createAssetArchive.d.ts +2 -0
- package/utils/createAssetArchive.js +16 -0
- package/utils/createAssetArchive.js.map +1 -0
- package/utils/getPresignedPost.d.ts +1 -1
- package/utils/getPresignedPost.js.map +1 -1
- package/utils/lambdaEnvVariables.d.ts +1 -1
- package/utils/lambdaEnvVariables.js.map +1 -1
- package/utils/uploadFolderToS3.d.ts +1 -1
- package/utils/uploadFolderToS3.js.map +1 -1
- package/utils/withServiceManifest.d.ts +2 -2
- package/utils/withServiceManifest.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["path","_interopRequireWildcard","require","pulumi","aws","_clientDynamodb","_awsLayers","_lambdaUtils","_common","_awsUtils","_constants","createPrerenderingService","app","params","queue","addResource","sqs","Queue","name","config","visibilityTimeoutSeconds","fifoQueue","policy","createLambdaPolicy","output","renderer","createRenderer","subscriber","createRenderSubscriber","flush","createFlushService","settings","createPrerenderingSettingsDbItem","tableItem","dynamodb","TableItem","tableName","dbTableName","hashKey","dbTableHashKey","rangeKey","dbTableRangeKey","item","interpolate","appUrl","deliveryUrl","bucket","cloudfrontId","url","apply","v","JSON","stringify","marshall","parse","core","getModule","CoreOutput","role","createLambdaRole","lambda","Function","arn","runtime","LAMBDA_RUNTIME","handler","timeout","memorySize","environment","variables","getCommonLambdaEnvVariables","value","DB_TABLE","DB_TABLE_LOG","logDbTableName","description","code","asset","AssetArchive","FileArchive","join","paths","workspace","vpcConfig","VpcConfig","functionVpcConfig","eventRule","cloudwatch","EventRule","eventBusName","eventBusArn","eventPattern","eventPermission","Permission","action","function","principal","sourceArn","eventTarget","EventTarget","rule","executionRole","iam","ManagedPolicy","AWSLambdaSQSQueueExecutionRole","layers","getLayerArn","eventSourceMapping","EventSourceMapping","functionName","eventSourceArn","batchSize","awsAccountId","getAwsAccountId","Policy","Version","Statement","Sid","Effect","Action","Resource","s","resources","primaryDynamodbTableArn","logDynamodbTableArn","elasticsearchDynamodbTableArn","push"],"sources":["WebsitePrerendering.ts"],"sourcesContent":["import * as path from \"path\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport { marshall } from \"@webiny/aws-sdk/client-dynamodb\";\n\nimport { PulumiApp } from \"@webiny/pulumi\";\nimport { getLayerArn } from \"@webiny/aws-layers\";\n\nimport { createLambdaRole, getCommonLambdaEnvVariables } from \"../lambdaUtils\";\nimport { CoreOutput, VpcConfig } from \"../common\";\nimport { getAwsAccountId } from \"../awsUtils\";\nimport { LAMBDA_RUNTIME } from \"~/constants\";\n\ninterface PreRenderingServiceParams {\n dbTableName: pulumi.Output<string>;\n dbTableHashKey: pulumi.Output<string>;\n dbTableRangeKey: pulumi.Output<string>;\n logDbTableName: pulumi.Output<string>;\n appUrl: pulumi.Output<string>;\n deliveryUrl: pulumi.Output<string>;\n bucket: pulumi.Output<string>;\n cloudfrontId: pulumi.Output<string>;\n}\n\nexport function createPrerenderingService(app: PulumiApp, params: PreRenderingServiceParams) {\n const queue = app.addResource(aws.sqs.Queue, {\n name: \"ps-render-queue\",\n config: {\n visibilityTimeoutSeconds: 300,\n fifoQueue: true\n }\n });\n\n const policy = createLambdaPolicy(app, queue.output, params);\n const renderer = createRenderer(app, queue.output, policy.output, params);\n const subscriber = createRenderSubscriber(app, policy.output, params);\n const flush = createFlushService(app, policy.output, params);\n const settings = createPrerenderingSettingsDbItem(app, queue.output, params);\n\n return {\n subscriber,\n renderer,\n flush,\n settings\n };\n}\n\nfunction createPrerenderingSettingsDbItem(\n app: PulumiApp,\n queue: pulumi.Output<aws.sqs.Queue>,\n params: PreRenderingServiceParams\n) {\n /**\n * To handle everything related to prerendering, we need the following information:\n * - appUrl - SPA URL used to prerender HTML\n * - bucket - name of the S3 bucket used for storage of HTML snapshots\n * - cloudfrontId - for cache invalidation\n * - sqsQueueUrl - an SQS queue for prerendering tasks (messages)\n */\n const tableItem = app.addResource(aws.dynamodb.TableItem, {\n name: \"psSettings\",\n config: {\n tableName: params.dbTableName,\n hashKey: params.dbTableHashKey,\n rangeKey: params.dbTableRangeKey,\n item: pulumi.interpolate`{\n \"PK\": \"PS#SETTINGS\",\n \"SK\": \"default\",\n \"data\": {\n \"appUrl\": \"${params.appUrl}\",\n \"deliveryUrl\": \"${params.deliveryUrl}\",\n \"bucket\": \"${params.bucket}\",\n \"cloudfrontId\": \"${params.cloudfrontId}\",\n \"sqsQueueUrl\": \"${queue.url}\"\n }\n }`\n // We're using the native DynamoDB converter to avoid building those nested objects ourselves.\n .apply(v => JSON.stringify(marshall(JSON.parse(v))))\n }\n });\n\n return { tableItem };\n}\n\nfunction createRenderSubscriber(\n app: PulumiApp,\n policy: pulumi.Output<aws.iam.Policy>,\n params: PreRenderingServiceParams\n) {\n const core = app.getModule(CoreOutput);\n\n const role = createLambdaRole(app, {\n name: \"ps-render-subscriber-role\",\n policy: policy\n });\n\n const lambda = app.addResource(aws.lambda.Function, {\n name: \"ps-render-subscriber-lambda\",\n config: {\n role: role.output.arn,\n runtime: LAMBDA_RUNTIME,\n handler: \"handler.handler\",\n timeout: 30,\n memorySize: 1024,\n environment: {\n variables: getCommonLambdaEnvVariables().apply(value => ({\n ...value,\n DB_TABLE: params.dbTableName,\n DB_TABLE_LOG: params.logDbTableName\n }))\n },\n description: \"Subscribes to render events on event bus\",\n code: new pulumi.asset.AssetArchive({\n \".\": new pulumi.asset.FileArchive(\n path.join(app.paths.workspace, \"prerendering/subscribe/build\")\n )\n }),\n vpcConfig: app.getModule(VpcConfig).functionVpcConfig\n }\n });\n\n /**\n * TODO: when we get to staged rollouts and variants, maybe we can create per-variant event rules,\n * to avoid invocation of all variant lambdas just to do a `detail-type` check and exit early.\n * That way, we would be publishing events scoped to a variant, like \"RenderPages-{variant}\".\n */\n\n const eventRule = app.addResource(aws.cloudwatch.EventRule, {\n name: \"ps-render-subscriber-event-rule\",\n config: {\n eventBusName: core.eventBusArn,\n eventPattern: JSON.stringify({\n \"detail-type\": [\"RenderPages\"]\n })\n }\n });\n\n const eventPermission = app.addResource(aws.lambda.Permission, {\n name: \"ps-render-subscriber-event-permission\",\n config: {\n action: \"lambda:InvokeFunction\",\n function: lambda.output.arn,\n principal: \"events.amazonaws.com\",\n sourceArn: eventRule.output.arn\n }\n });\n\n const eventTarget = app.addResource(aws.cloudwatch.EventTarget, {\n name: \"ps-render-subscriber-event-target\",\n config: {\n rule: eventRule.output.name,\n eventBusName: core.eventBusArn,\n arn: lambda.output.arn\n }\n });\n\n return {\n policy,\n role,\n lambda,\n eventRule,\n eventPermission,\n eventTarget\n };\n}\n\nfunction createRenderer(\n app: PulumiApp,\n queue: pulumi.Output<aws.sqs.Queue>,\n policy: pulumi.Output<aws.iam.Policy>,\n params: PreRenderingServiceParams\n) {\n const role = createLambdaRole(app, {\n name: \"ps-render-lambda-role\",\n policy: policy,\n executionRole: aws.iam.ManagedPolicy.AWSLambdaSQSQueueExecutionRole\n });\n\n const lambda = app.addResource(aws.lambda.Function, {\n name: \"ps-render-lambda\",\n config: {\n role: role.output.arn,\n runtime: LAMBDA_RUNTIME,\n handler: \"handler.handler\",\n timeout: 300,\n memorySize: 2048,\n layers: [getLayerArn(\"chromium\")],\n environment: {\n variables: getCommonLambdaEnvVariables().apply(value => ({\n ...value,\n DB_TABLE: params.dbTableName,\n DB_TABLE_LOG: params.logDbTableName\n }))\n },\n description: \"Renders pages and stores output in an S3 bucket of choice.\",\n code: new pulumi.asset.AssetArchive({\n \".\": new pulumi.asset.FileArchive(\n path.join(app.paths.workspace, \"prerendering/render/build\")\n )\n }),\n vpcConfig: app.getModule(VpcConfig).functionVpcConfig\n }\n });\n\n const eventSourceMapping = app.addResource(aws.lambda.EventSourceMapping, {\n name: \"ps-render-event-source-mapping\",\n config: {\n functionName: lambda.output.arn,\n eventSourceArn: queue.arn,\n batchSize: 1\n }\n });\n\n return {\n policy,\n role,\n lambda,\n eventSourceMapping\n };\n}\n\nfunction createFlushService(\n app: PulumiApp,\n policy: pulumi.Output<aws.iam.Policy>,\n params: PreRenderingServiceParams\n) {\n const core = app.getModule(CoreOutput);\n\n const role = createLambdaRole(app, {\n name: \"ps-flush-lambda-role\",\n policy: policy\n });\n\n const lambda = app.addResource(aws.lambda.Function, {\n name: \"ps-flush-lambda\",\n config: {\n role: role.output.arn,\n runtime: LAMBDA_RUNTIME,\n handler: \"handler.handler\",\n timeout: 30,\n memorySize: 1024,\n environment: {\n variables: getCommonLambdaEnvVariables().apply(value => ({\n ...value,\n DB_TABLE: params.dbTableName,\n DB_TABLE_LOG: params.logDbTableName\n }))\n },\n description: \"Subscribes to flush events on event bus\",\n code: new pulumi.asset.AssetArchive({\n \".\": new pulumi.asset.FileArchive(\n path.join(app.paths.workspace, \"prerendering/flush/build\")\n )\n }),\n vpcConfig: app.getModule(VpcConfig).functionVpcConfig\n }\n });\n\n const eventRule = app.addResource(aws.cloudwatch.EventRule, {\n name: \"ps-flush-event-rule\",\n config: {\n eventBusName: core.eventBusArn,\n eventPattern: JSON.stringify({\n \"detail-type\": [\"FlushPages\"]\n })\n }\n });\n\n const eventPermission = app.addResource(aws.lambda.Permission, {\n name: \"ps-flush-event-permission\",\n config: {\n action: \"lambda:InvokeFunction\",\n function: lambda.output.arn,\n principal: \"events.amazonaws.com\",\n sourceArn: eventRule.output.arn\n }\n });\n\n const eventTarget = app.addResource(aws.cloudwatch.EventTarget, {\n name: \"ps-flush-event-target\",\n config: {\n rule: eventRule.output.name,\n eventBusName: core.eventBusArn,\n arn: lambda.output.arn\n }\n });\n\n return {\n policy,\n role,\n lambda,\n eventRule,\n eventPermission,\n eventTarget\n };\n}\n\nfunction createLambdaPolicy(\n app: PulumiApp,\n queue: pulumi.Output<aws.sqs.Queue>,\n params: PreRenderingServiceParams\n) {\n const core = app.getModule(CoreOutput);\n const awsAccountId = getAwsAccountId(app);\n\n return app.addResource(aws.iam.Policy, {\n name: \"ps-lambda-policy\",\n config: {\n description: \"This policy enables access to Lambda, S3, Cloudfront, SQS and Dynamodb\",\n policy: {\n Version: \"2012-10-17\",\n Statement: [\n {\n Sid: \"PermissionForDynamodb\",\n Effect: \"Allow\",\n Action: [\n \"dynamodb:BatchGetItem\",\n \"dynamodb:BatchWriteItem\",\n \"dynamodb:DeleteItem\",\n \"dynamodb:GetItem\",\n \"dynamodb:PutItem\",\n \"dynamodb:Query\",\n \"dynamodb:Scan\",\n \"dynamodb:UpdateItem\"\n ],\n Resource: core.apply(s => {\n // Add permissions to DynamoDB table\n const resources = [\n `${s.primaryDynamodbTableArn}`,\n `${s.primaryDynamodbTableArn}/*`,\n `${s.logDynamodbTableArn}`,\n `${s.logDynamodbTableArn}/*`\n ];\n\n // Attach permissions for elastic search dynamo as well (if ES is enabled).\n if (s.elasticsearchDynamodbTableArn) {\n resources.push(\n `${s.elasticsearchDynamodbTableArn}`,\n `${s.elasticsearchDynamodbTableArn}/*`\n );\n }\n\n return resources;\n })\n },\n {\n Sid: \"PermissionForS3\",\n Effect: \"Allow\",\n Action: [\"s3:DeleteObject\", \"s3:GetObject\", \"s3:PutObject\"],\n Resource: [pulumi.interpolate`arn:aws:s3:::${params.bucket}/*`]\n },\n {\n Sid: \"PermissionForCloudfront\",\n Effect: \"Allow\",\n Action: \"cloudfront:CreateInvalidation\",\n Resource: pulumi.interpolate`arn:aws:cloudfront::${awsAccountId}:distribution/*`\n },\n {\n Sid: \"PermissionForSQS\",\n Effect: \"Allow\",\n Action: [\"sqs:SendMessage\", \"sqs:SendMessageBatch\"],\n Resource: queue.arn\n }\n ]\n }\n }\n });\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,IAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,GAAA,GAAAH,uBAAA,CAAAC,OAAA;AACA,IAAAG,eAA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,CAC/B;;YAED;YACA,IAAIH,CAAC,CAACI,6BAA6B,EAAE;cACjCH,SAAS,CAACI,IAAI,CACV,GAAGL,CAAC,CAACI,6BAA6B,EAAE,EACpC,GAAGJ,CAAC,CAACI,6BAA6B,IACtC,CAAC;YACL;YAEA,OAAOH,SAAS;UACpB,CAAC;QACL,CAAC,EACD;UACIL,GAAG,EAAE,iBAAiB;UACtBC,MAAM,EAAE,OAAO;UACfC,MAAM,EAAE,CAAC,iBAAiB,EAAE,cAAc,EAAE,cAAc,CAAC;UAC3DC,QAAQ,EAAE,CAACrH,MAAM,CAACwC,WAAW,gBAAgB9B,MAAM,CAACiC,MAAM,IAAI;QAClE,CAAC,EACD;UACIuE,GAAG,EAAE,yBAAyB;UAC9BC,MAAM,EAAE,OAAO;UACfC,MAAM,EAAE,+BAA+B;UACvCC,QAAQ,EAAErH,MAAM,CAACwC,WAAW,uBAAuBqE,YAAY;QACnE,CAAC,EACD;UACIK,GAAG,EAAE,kBAAkB;UACvBC,MAAM,EAAE,OAAO;UACfC,MAAM,EAAE,CAAC,iBAAiB,EAAE,sBAAsB,CAAC;UACnDC,QAAQ,EAAE1G,KAAK,CAACgD;QACpB,CAAC;MAET;IACJ;EACJ,CAAC,CAAC;AACN","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["path","_interopRequireWildcard","require","pulumi","aws","_clientDynamodb","_awsLayers","_lambdaUtils","_common","_awsUtils","_constants","createPrerenderingService","app","params","queue","addResource","sqs","Queue","name","config","visibilityTimeoutSeconds","fifoQueue","policy","createLambdaPolicy","output","renderer","createRenderer","subscriber","createRenderSubscriber","flush","createFlushService","settings","createPrerenderingSettingsDbItem","tableItem","dynamodb","TableItem","tableName","dbTableName","hashKey","dbTableHashKey","rangeKey","dbTableRangeKey","item","interpolate","appUrl","deliveryUrl","bucket","cloudfrontId","url","apply","v","JSON","stringify","marshall","parse","core","getModule","CoreOutput","role","createLambdaRole","lambda","Function","arn","runtime","LAMBDA_RUNTIME","handler","timeout","memorySize","environment","variables","getCommonLambdaEnvVariables","value","DB_TABLE","DB_TABLE_LOG","logDbTableName","description","code","asset","AssetArchive","FileArchive","join","paths","workspace","vpcConfig","VpcConfig","functionVpcConfig","eventRule","cloudwatch","EventRule","eventBusName","eventBusArn","eventPattern","eventPermission","Permission","action","function","principal","sourceArn","eventTarget","EventTarget","rule","executionRole","iam","ManagedPolicy","AWSLambdaSQSQueueExecutionRole","layers","getLayerArn","eventSourceMapping","EventSourceMapping","functionName","eventSourceArn","batchSize","awsAccountId","getAwsAccountId","Policy","Version","Statement","Sid","Effect","Action","Resource","s","resources","primaryDynamodbTableArn","logDynamodbTableArn","elasticsearchDynamodbTableArn","push"],"sources":["WebsitePrerendering.ts"],"sourcesContent":["import * as path from \"path\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport { marshall } from \"@webiny/aws-sdk/client-dynamodb\";\n\nimport type { PulumiApp } from \"@webiny/pulumi\";\nimport { getLayerArn } from \"@webiny/aws-layers\";\n\nimport { createLambdaRole, getCommonLambdaEnvVariables } from \"../lambdaUtils\";\nimport { CoreOutput, VpcConfig } from \"../common\";\nimport { getAwsAccountId } from \"../awsUtils\";\nimport { LAMBDA_RUNTIME } from \"~/constants\";\n\ninterface PreRenderingServiceParams {\n dbTableName: pulumi.Output<string>;\n dbTableHashKey: pulumi.Output<string>;\n dbTableRangeKey: pulumi.Output<string>;\n logDbTableName: pulumi.Output<string>;\n appUrl: pulumi.Output<string>;\n deliveryUrl: pulumi.Output<string>;\n bucket: pulumi.Output<string>;\n cloudfrontId: pulumi.Output<string>;\n}\n\nexport function createPrerenderingService(app: PulumiApp, params: PreRenderingServiceParams) {\n const queue = app.addResource(aws.sqs.Queue, {\n name: \"ps-render-queue\",\n config: {\n visibilityTimeoutSeconds: 300,\n fifoQueue: true\n }\n });\n\n const policy = createLambdaPolicy(app, queue.output, params);\n const renderer = createRenderer(app, queue.output, policy.output, params);\n const subscriber = createRenderSubscriber(app, policy.output, params);\n const flush = createFlushService(app, policy.output, params);\n const settings = createPrerenderingSettingsDbItem(app, queue.output, params);\n\n return {\n subscriber,\n renderer,\n flush,\n settings\n };\n}\n\nfunction createPrerenderingSettingsDbItem(\n app: PulumiApp,\n queue: pulumi.Output<aws.sqs.Queue>,\n params: PreRenderingServiceParams\n) {\n /**\n * To handle everything related to prerendering, we need the following information:\n * - appUrl - SPA URL used to prerender HTML\n * - bucket - name of the S3 bucket used for storage of HTML snapshots\n * - cloudfrontId - for cache invalidation\n * - sqsQueueUrl - an SQS queue for prerendering tasks (messages)\n */\n const tableItem = app.addResource(aws.dynamodb.TableItem, {\n name: \"psSettings\",\n config: {\n tableName: params.dbTableName,\n hashKey: params.dbTableHashKey,\n rangeKey: params.dbTableRangeKey,\n item: pulumi.interpolate`{\n \"PK\": \"PS#SETTINGS\",\n \"SK\": \"default\",\n \"data\": {\n \"appUrl\": \"${params.appUrl}\",\n \"deliveryUrl\": \"${params.deliveryUrl}\",\n \"bucket\": \"${params.bucket}\",\n \"cloudfrontId\": \"${params.cloudfrontId}\",\n \"sqsQueueUrl\": \"${queue.url}\"\n }\n }`\n // We're using the native DynamoDB converter to avoid building those nested objects ourselves.\n .apply(v => JSON.stringify(marshall(JSON.parse(v))))\n }\n });\n\n return { tableItem };\n}\n\nfunction createRenderSubscriber(\n app: PulumiApp,\n policy: pulumi.Output<aws.iam.Policy>,\n params: PreRenderingServiceParams\n) {\n const core = app.getModule(CoreOutput);\n\n const role = createLambdaRole(app, {\n name: \"ps-render-subscriber-role\",\n policy: policy\n });\n\n const lambda = app.addResource(aws.lambda.Function, {\n name: \"ps-render-subscriber-lambda\",\n config: {\n role: role.output.arn,\n runtime: LAMBDA_RUNTIME,\n handler: \"handler.handler\",\n timeout: 30,\n memorySize: 1024,\n environment: {\n variables: getCommonLambdaEnvVariables().apply(value => ({\n ...value,\n DB_TABLE: params.dbTableName,\n DB_TABLE_LOG: params.logDbTableName\n }))\n },\n description: \"Subscribes to render events on event bus\",\n code: new pulumi.asset.AssetArchive({\n \".\": new pulumi.asset.FileArchive(\n path.join(app.paths.workspace, \"prerendering/subscribe/build\")\n )\n }),\n vpcConfig: app.getModule(VpcConfig).functionVpcConfig\n }\n });\n\n /**\n * TODO: when we get to staged rollouts and variants, maybe we can create per-variant event rules,\n * to avoid invocation of all variant lambdas just to do a `detail-type` check and exit early.\n * That way, we would be publishing events scoped to a variant, like \"RenderPages-{variant}\".\n */\n\n const eventRule = app.addResource(aws.cloudwatch.EventRule, {\n name: \"ps-render-subscriber-event-rule\",\n config: {\n eventBusName: core.eventBusArn,\n eventPattern: JSON.stringify({\n \"detail-type\": [\"RenderPages\"]\n })\n }\n });\n\n const eventPermission = app.addResource(aws.lambda.Permission, {\n name: \"ps-render-subscriber-event-permission\",\n config: {\n action: \"lambda:InvokeFunction\",\n function: lambda.output.arn,\n principal: \"events.amazonaws.com\",\n sourceArn: eventRule.output.arn\n }\n });\n\n const eventTarget = app.addResource(aws.cloudwatch.EventTarget, {\n name: \"ps-render-subscriber-event-target\",\n config: {\n rule: eventRule.output.name,\n eventBusName: core.eventBusArn,\n arn: lambda.output.arn\n }\n });\n\n return {\n policy,\n role,\n lambda,\n eventRule,\n eventPermission,\n eventTarget\n };\n}\n\nfunction createRenderer(\n app: PulumiApp,\n queue: pulumi.Output<aws.sqs.Queue>,\n policy: pulumi.Output<aws.iam.Policy>,\n params: PreRenderingServiceParams\n) {\n const role = createLambdaRole(app, {\n name: \"ps-render-lambda-role\",\n policy: policy,\n executionRole: aws.iam.ManagedPolicy.AWSLambdaSQSQueueExecutionRole\n });\n\n const lambda = app.addResource(aws.lambda.Function, {\n name: \"ps-render-lambda\",\n config: {\n role: role.output.arn,\n runtime: LAMBDA_RUNTIME,\n handler: \"handler.handler\",\n timeout: 300,\n memorySize: 2048,\n layers: [getLayerArn(\"chromium\")],\n environment: {\n variables: getCommonLambdaEnvVariables().apply(value => ({\n ...value,\n DB_TABLE: params.dbTableName,\n DB_TABLE_LOG: params.logDbTableName\n }))\n },\n description: \"Renders pages and stores output in an S3 bucket of choice.\",\n code: new pulumi.asset.AssetArchive({\n \".\": new pulumi.asset.FileArchive(\n path.join(app.paths.workspace, \"prerendering/render/build\")\n )\n }),\n vpcConfig: app.getModule(VpcConfig).functionVpcConfig\n }\n });\n\n const eventSourceMapping = app.addResource(aws.lambda.EventSourceMapping, {\n name: \"ps-render-event-source-mapping\",\n config: {\n functionName: lambda.output.arn,\n eventSourceArn: queue.arn,\n batchSize: 1\n }\n });\n\n return {\n policy,\n role,\n lambda,\n eventSourceMapping\n };\n}\n\nfunction createFlushService(\n app: PulumiApp,\n policy: pulumi.Output<aws.iam.Policy>,\n params: PreRenderingServiceParams\n) {\n const core = app.getModule(CoreOutput);\n\n const role = createLambdaRole(app, {\n name: \"ps-flush-lambda-role\",\n policy: policy\n });\n\n const lambda = app.addResource(aws.lambda.Function, {\n name: \"ps-flush-lambda\",\n config: {\n role: role.output.arn,\n runtime: LAMBDA_RUNTIME,\n handler: \"handler.handler\",\n timeout: 30,\n memorySize: 1024,\n environment: {\n variables: getCommonLambdaEnvVariables().apply(value => ({\n ...value,\n DB_TABLE: params.dbTableName,\n DB_TABLE_LOG: params.logDbTableName\n }))\n },\n description: \"Subscribes to flush events on event bus\",\n code: new pulumi.asset.AssetArchive({\n \".\": new pulumi.asset.FileArchive(\n path.join(app.paths.workspace, \"prerendering/flush/build\")\n )\n }),\n vpcConfig: app.getModule(VpcConfig).functionVpcConfig\n }\n });\n\n const eventRule = app.addResource(aws.cloudwatch.EventRule, {\n name: \"ps-flush-event-rule\",\n config: {\n eventBusName: core.eventBusArn,\n eventPattern: JSON.stringify({\n \"detail-type\": [\"FlushPages\"]\n })\n }\n });\n\n const eventPermission = app.addResource(aws.lambda.Permission, {\n name: \"ps-flush-event-permission\",\n config: {\n action: \"lambda:InvokeFunction\",\n function: lambda.output.arn,\n principal: \"events.amazonaws.com\",\n sourceArn: eventRule.output.arn\n }\n });\n\n const eventTarget = app.addResource(aws.cloudwatch.EventTarget, {\n name: \"ps-flush-event-target\",\n config: {\n rule: eventRule.output.name,\n eventBusName: core.eventBusArn,\n arn: lambda.output.arn\n }\n });\n\n return {\n policy,\n role,\n lambda,\n eventRule,\n eventPermission,\n eventTarget\n };\n}\n\nfunction createLambdaPolicy(\n app: PulumiApp,\n queue: pulumi.Output<aws.sqs.Queue>,\n params: PreRenderingServiceParams\n) {\n const core = app.getModule(CoreOutput);\n const awsAccountId = getAwsAccountId(app);\n\n return app.addResource(aws.iam.Policy, {\n name: \"ps-lambda-policy\",\n config: {\n description: \"This policy enables access to Lambda, S3, Cloudfront, SQS and Dynamodb\",\n policy: {\n Version: \"2012-10-17\",\n Statement: [\n {\n Sid: \"PermissionForDynamodb\",\n Effect: \"Allow\",\n Action: [\n \"dynamodb:BatchGetItem\",\n \"dynamodb:BatchWriteItem\",\n \"dynamodb:DeleteItem\",\n \"dynamodb:GetItem\",\n \"dynamodb:PutItem\",\n \"dynamodb:Query\",\n \"dynamodb:Scan\",\n \"dynamodb:UpdateItem\"\n ],\n Resource: core.apply(s => {\n // Add permissions to DynamoDB table\n const resources = [\n `${s.primaryDynamodbTableArn}`,\n `${s.primaryDynamodbTableArn}/*`,\n `${s.logDynamodbTableArn}`,\n `${s.logDynamodbTableArn}/*`\n ];\n\n // Attach permissions for elastic search dynamo as well (if ES is enabled).\n if (s.elasticsearchDynamodbTableArn) {\n resources.push(\n `${s.elasticsearchDynamodbTableArn}`,\n `${s.elasticsearchDynamodbTableArn}/*`\n );\n }\n\n return resources;\n })\n },\n {\n Sid: \"PermissionForS3\",\n Effect: \"Allow\",\n Action: [\"s3:DeleteObject\", \"s3:GetObject\", \"s3:PutObject\"],\n Resource: [pulumi.interpolate`arn:aws:s3:::${params.bucket}/*`]\n },\n {\n Sid: \"PermissionForCloudfront\",\n Effect: \"Allow\",\n Action: \"cloudfront:CreateInvalidation\",\n Resource: pulumi.interpolate`arn:aws:cloudfront::${awsAccountId}:distribution/*`\n },\n {\n Sid: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gB,EAChB,eAAe,EACf,qBAAqB,CACxB;UACDC,QAAQ,EAAEjE,IAAI,CAACN,KAAK,CAACwE,CAAC,IAAI;YACtB;YACA,MAAMC,SAAS,GAAG,CACd,GAAGD,CAAC,CAACE,uBAAuB,EAAE,EAC9B,GAAGF,CAAC,CAACE,uBAAuB,IAAI,EAChC,GAAGF,CAAC,CAACG,mBAAmB,EAAE,EAC1B,GAAGH,CAAC,CAACG,mBAAmB,IAAI,CAC/B;;YAED;YACA,IAAIH,CAAC,CAACI,6BAA6B,EAAE;cACjCH,SAAS,CAACI,IAAI,CACV,GAAGL,CAAC,CAACI,6BAA6B,EAAE,EACpC,GAAGJ,CAAC,CAACI,6BAA6B,IACtC,CAAC;YACL;YAEA,OAAOH,SAAS;UACpB,CAAC;QACL,CAAC,EACD;UACIL,GAAG,EAAE,iBAAiB;UACtBC,MAAM,EAAE,OAAO;UACfC,MAAM,EAAE,CAAC,iBAAiB,EAAE,cAAc,EAAE,cAAc,CAAC;UAC3DC,QAAQ,EAAE,CAACrH,MAAM,CAACwC,WAAW,gBAAgB9B,MAAM,CAACiC,MAAM,IAAI;QAClE,CAAC,EACD;UACIuE,GAAG,EAAE,yBAAyB;UAC9BC,MAAM,EAAE,OAAO;UACfC,MAAM,EAAE,+BAA+B;UACvCC,QAAQ,EAAErH,MAAM,CAACwC,WAAW,uBAAuBqE,YAAY;QACnE,CAAC,EACD;UACIK,GAAG,EAAE,kBAAkB;UACvBC,MAAM,EAAE,OAAO;UACfC,MAAM,EAAE,CAAC,iBAAiB,EAAE,sBAAsB,CAAC;UACnDC,QAAQ,EAAE1G,KAAK,CAACgD;QACpB,CAAC;MAET;IACJ;EACJ,CAAC,CAAC;AACN","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as pulumi from "@pulumi/pulumi";
|
|
2
2
|
import * as aws from "@pulumi/aws";
|
|
3
|
-
import { PulumiAppParam, PulumiAppParamCallback } from "@webiny/pulumi";
|
|
4
|
-
import { CustomDomainParams } from "../customDomain";
|
|
3
|
+
import type { PulumiAppParam, PulumiAppParamCallback } from "@webiny/pulumi";
|
|
4
|
+
import type { CustomDomainParams } from "../customDomain";
|
|
5
5
|
export type WebsitePulumiApp = ReturnType<typeof createWebsitePulumiApp>;
|
|
6
6
|
export interface CreateWebsitePulumiAppParams {
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["pulumi","_interopRequireWildcard","require","aws","_fs","_interopRequireDefault","_pulumi2","_createAppBucket","_customDomain","_WebsitePrerendering","_","_utils","_tenantRouter","_withServiceManifest","_constants","_variant","_env","_projectName","createWebsitePulumiApp","projectAppParams","baseApp","createPulumiApp","name","path","config","program","app","pulumiResourceNamePrefix","getParam","onResource","resource","startsWith","addHandler","productionEnvironments","params","create","DEFAULT_PROD_ENV_NAMES","isProduction","includes","run","env","core","addModule","CoreOutput","ApiOutput","vpcEnabled","vpc","VpcConfig","enabled","appBucket","createPrivateAppBucket","appCloudfront","addResource","cloudfront","Distribution","waitForDeployment","origins","origin","defaultRootObject","defaultCacheBehavior","compress","targetOriginId","originId","viewerProtocolPolicy","allowedMethods","cachedMethods","forwardedValues","cookies","forward","queryString","minTtl","defaultTtl","maxTtl","priceClass","customErrorResponses","errorCode","responseCode","responsePagePath","restrictions","geoRestriction","restrictionType","viewerCertificate","cloudfrontDefaultCertificate","opts","ignoreChanges","deliveryBucket","viewerRequest","Function","runtime","publish","code","fs","readFileSync","__dirname","deliveryCloudfront","originRequestPolicyId","functionAssociations","functionArn","output","arn","eventType","orderedCacheBehaviors","headers","pathPattern","prerendering","createPrerenderingService","dbTableName","primaryDynamodbTableName","dbTableHashKey","primaryDynamodbTableHashKey","dbTableRangeKey","primaryDynamodbTableRangeKey","logDbTableName","logDynamodbTableName","appUrl","interpolate","domainName","deliveryUrl","bucket","cloudfrontId","id","domains","applyCustomDomain","previewDomains","process","WCP_PROJECT_ENVIRONMENT","WEBINY_MULTI_TENANCY","originLambda","applyTenantRouter","addOutputs","websiteRouterOriginRequestFunction","appId","appStorage","deliveryId","deliveryStorage","addDomainsUrlsOutputs","cloudfrontDistribution","map","distributionDomain","distributionUrl","usedDomain","usedUrl","tagResources","WbyProjectName","getEnvVariableWebinyProjectName","WbyEnvironment","getEnvVariableWebinyEnv","WbyEnvironmentVariant","getEnvVariableWebinyVariant","preview","delivery","withServiceManifest","withCommonLambdaEnvVariables","resources","addServiceManifest","manifest","distributionId","bucketDomainName","bucketRegionalDomainName","exports"],"sources":["createWebsitePulumiApp.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport fs from \"fs\";\nimport { createPulumiApp, PulumiAppParam, PulumiAppParamCallback } from \"@webiny/pulumi\";\nimport { createPrivateAppBucket } from \"../createAppBucket\";\nimport { applyCustomDomain, CustomDomainParams } from \"../customDomain\";\nimport { createPrerenderingService } from \"./WebsitePrerendering\";\nimport { ApiOutput, CoreOutput, VpcConfig } from \"~/apps\";\nimport { addDomainsUrlsOutputs, tagResources, withCommonLambdaEnvVariables } from \"~/utils\";\nimport { applyTenantRouter } from \"~/apps/tenantRouter\";\nimport { withServiceManifest } from \"~/utils/withServiceManifest\";\nimport { DEFAULT_PROD_ENV_NAMES } from \"~/constants\";\nimport { getEnvVariableWebinyVariant } from \"~/env/variant\";\nimport { getEnvVariableWebinyEnv } from \"~/env/env\";\nimport { getEnvVariableWebinyProjectName } from \"~/env/projectName\";\n\nexport type WebsitePulumiApp = ReturnType<typeof createWebsitePulumiApp>;\n\nexport interface CreateWebsitePulumiAppParams {\n /**\n * Custom domain(s) configuration.\n */\n domains?: PulumiAppParamCallback<CustomDomainParams>;\n\n /**\n * Custom preview domain(s) configuration.\n */\n previewDomains?: PulumiAppParamCallback<CustomDomainParams>;\n\n /**\n * Enables or disables VPC for the API.\n * For VPC to work you also have to enable it in the `core` application.\n */\n vpc?: PulumiAppParam<boolean | undefined>;\n\n /**\n * Provides a way to adjust existing Pulumi code (cloud infrastructure resources)\n * or add additional ones into the mix.\n */\n pulumi?: (app: WebsitePulumiApp) => void | Promise<void>;\n\n /**\n * Prefixes names of all Pulumi cloud infrastructure resource with given prefix.\n */\n pulumiResourceNamePrefix?: PulumiAppParam<string>;\n\n /**\n * Treats provided environments as production environments, which\n * are deployed in production deployment mode.\n * https://www.webiny.com/docs/architecture/deployment-modes/production\n */\n productionEnvironments?: PulumiAppParam<string[]>;\n}\n\nexport const createWebsitePulumiApp = (projectAppParams: CreateWebsitePulumiAppParams = {}) => {\n const baseApp = createPulumiApp({\n name: \"website\",\n path: \"apps/website\",\n config: projectAppParams,\n program: async app => {\n const pulumiResourceNamePrefix = app.getParam(\n projectAppParams.pulumiResourceNamePrefix\n );\n if (pulumiResourceNamePrefix) {\n app.onResource(resource => {\n if (!resource.name.startsWith(pulumiResourceNamePrefix)) {\n resource.name = `${pulumiResourceNamePrefix}${resource.name}`;\n }\n });\n }\n\n // Overrides must be applied via a handler, registered at the very start of the program.\n // By doing this, we're ensuring user's adjustments are not applied to late.\n if (projectAppParams.pulumi) {\n app.addHandler(() => {\n return projectAppParams.pulumi!(app as WebsitePulumiApp);\n });\n }\n\n const productionEnvironments =\n app.params.create.productionEnvironments || DEFAULT_PROD_ENV_NAMES;\n const isProduction = productionEnvironments.includes(app.params.run.env);\n\n // Register core and api output as a module, to be available to all other modules.\n const core = app.addModule(CoreOutput);\n app.addModule(ApiOutput);\n\n // Register VPC config module to be available to other modules.\n const vpcEnabled = app.getParam(projectAppParams?.vpc) ?? isProduction;\n app.addModule(VpcConfig, { enabled: vpcEnabled });\n\n const appBucket = createPrivateAppBucket(app, \"app\");\n\n const appCloudfront = app.addResource(aws.cloudfront.Distribution, {\n name: \"app\",\n config: {\n enabled: true,\n waitForDeployment: true,\n origins: [appBucket.origin],\n defaultRootObject: \"index.html\",\n defaultCacheBehavior: {\n compress: true,\n targetOriginId: appBucket.origin.originId,\n viewerProtocolPolicy: \"redirect-to-https\",\n allowedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n cachedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n forwardedValues: {\n cookies: { forward: \"none\" },\n queryString: false\n },\n // MinTTL <= DefaultTTL <= MaxTTL\n minTtl: 0,\n defaultTtl: 0,\n maxTtl: 0\n },\n priceClass: \"PriceClass_100\",\n customErrorResponses: [\n { errorCode: 404, responseCode: 404, responsePagePath: \"/index.html\" }\n ],\n restrictions: {\n geoRestriction: {\n restrictionType: \"none\"\n }\n },\n viewerCertificate: {\n cloudfrontDefaultCertificate: true\n }\n },\n opts: {\n // We are ignoring changes to the \"staging\" property. This is because of the following.\n // With the 5.41.0 release of Webiny, we also upgraded Pulumi to v6. This introduced a change\n // with how Cloudfront distributions are deployed, where Pulumi now also controls the new\n // `staging` property.\n // If not set, Pulumi will default it to `false`. Which is fine, but, the problem is\n // that, because this property did not exist before, it will always be considered as a change\n // upon deployment.\n // We might think this is fine, but, the problem is that a change in this property causes\n // a full replacement of the Cloudfront distribution, which is not acceptable. Especially\n // if a custom domain has already been associated with the distribution. This then would\n // require the user to disassociate the domain, wait for the distribution to be replaced,\n // and then re-associate the domain. This is not a good experience.\n ignoreChanges: [\"staging\"]\n }\n });\n\n const deliveryBucket = createPrivateAppBucket(app, \"delivery\");\n\n /**\n * We need to have a Cloudfront Function to perform a simple request rewrite, so the request always includes\n * an \"/index.html\". This is necessary because our buckets are not \"website\" buckets, and we need to\n * have an exact object key when requesting page paths.\n */\n const viewerRequest = app.addResource(aws.cloudfront.Function, {\n name: \"cfViewerRequest\",\n config: {\n runtime: \"cloudfront-js-1.0\",\n publish: true,\n code: fs.readFileSync(__dirname + `/deliveryViewerRequest.js`, \"utf8\")\n }\n });\n\n const deliveryCloudfront = app.addResource(aws.cloudfront.Distribution, {\n name: \"delivery\",\n config: {\n enabled: true,\n waitForDeployment: true,\n origins: [deliveryBucket.origin, appBucket.origin],\n defaultRootObject: \"index.html\",\n defaultCacheBehavior: {\n compress: true,\n targetOriginId: deliveryBucket.origin.originId,\n viewerProtocolPolicy: \"redirect-to-https\",\n allowedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n cachedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n originRequestPolicyId: \"\",\n forwardedValues: {\n cookies: { forward: \"none\" },\n queryString: true\n },\n // MinTTL <= DefaultTTL <= MaxTTL\n minTtl: 0,\n defaultTtl: 30,\n maxTtl: 30,\n functionAssociations: [\n { functionArn: viewerRequest.output.arn, eventType: \"viewer-request\" }\n ]\n },\n orderedCacheBehaviors: [\n {\n compress: true,\n allowedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n cachedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n forwardedValues: {\n cookies: {\n forward: \"none\"\n },\n headers: [],\n queryString: false\n },\n pathPattern: \"/static/*\",\n viewerProtocolPolicy: \"allow-all\",\n targetOriginId: appBucket.origin.originId,\n // MinTTL <= DefaultTTL <= MaxTTL\n minTtl: 0,\n defaultTtl: 2592000, // 30 days\n maxTtl: 2592000\n },\n // This forward is necessary for non-WCP projects. For WCP projects, the\n // forwarding is performed by the `website-router` Lambda@Edge function.\n {\n compress: true,\n allowedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n cachedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n forwardedValues: {\n cookies: {\n forward: \"none\"\n },\n headers: [],\n queryString: false\n },\n pathPattern: \"/robots.txt\",\n viewerProtocolPolicy: \"allow-all\",\n targetOriginId: appBucket.origin.originId\n }\n ],\n customErrorResponses: [\n {\n errorCode: 404,\n responseCode: 404,\n responsePagePath: \"/_NOT_FOUND_PAGE_/index.html\"\n }\n ],\n priceClass: \"PriceClass_100\",\n restrictions: {\n geoRestriction: {\n restrictionType: \"none\"\n }\n },\n viewerCertificate: {\n cloudfrontDefaultCertificate: true\n }\n },\n opts: {\n // Check the comment in the `appCloudfront` resource above for more info.\n ignoreChanges: [\"staging\"]\n }\n });\n\n const prerendering = createPrerenderingService(app, {\n dbTableName: core.primaryDynamodbTableName,\n dbTableHashKey: core.primaryDynamodbTableHashKey,\n dbTableRangeKey: core.primaryDynamodbTableRangeKey,\n logDbTableName: core.logDynamodbTableName,\n appUrl: pulumi.interpolate`https://${appCloudfront.output.domainName}`,\n deliveryUrl: pulumi.interpolate`https://${deliveryCloudfront.output.domainName}`,\n bucket: deliveryBucket.bucket.output.bucket,\n cloudfrontId: deliveryCloudfront.output.id\n });\n\n const domains = app.getParam(projectAppParams.domains);\n if (domains) {\n applyCustomDomain(deliveryCloudfront, domains);\n }\n\n const previewDomains = app.getParam(projectAppParams.previewDomains);\n if (previewDomains) {\n applyCustomDomain(appCloudfront, previewDomains);\n }\n\n if (\n process.env.WCP_PROJECT_ENVIRONMENT ||\n process.env.WEBINY_MULTI_TENANCY === \"true\"\n ) {\n const { originLambda } = applyTenantRouter(app, deliveryCloudfront);\n\n app.addHandler(() => {\n app.addOutputs({\n websiteRouterOriginRequestFunction: originLambda.output.name\n });\n });\n }\n\n app.addOutputs({\n // Cloudfront and S3 bucket used to host the single-page application (SPA). The URL of the distribution is mainly\n // utilized by the Page Builder app's prerendering engine. Using this URL, it accesses the SPA and creates HTML snapshots.\n // The files that are generated in that process are stored in the `deliveryStorage` S3 bucket further below.\n appId: appCloudfront.output.id,\n appStorage: appBucket.bucket.output.id,\n\n // These are the Cloudfront and S3 bucket that will deliver static pages to the actual website visitors.\n // The static HTML snapshots delivered from them still rely on the app's S3 bucket\n // defined above, for serving static assets (JS, CSS, images).\n deliveryId: deliveryCloudfront.output.id,\n deliveryStorage: deliveryBucket.bucket.output.id\n });\n\n app.addHandler(() => {\n addDomainsUrlsOutputs({\n app,\n cloudfrontDistribution: appCloudfront,\n map: {\n distributionDomain: \"cloudfrontAppDomain\",\n distributionUrl: \"cloudfrontAppUrl\",\n usedDomain: \"appDomain\",\n usedUrl: \"appUrl\"\n }\n });\n\n addDomainsUrlsOutputs({\n app,\n cloudfrontDistribution: deliveryCloudfront,\n map: {\n distributionDomain: \"cloudfrontDeliveryDomain\",\n distributionUrl: \"cloudfrontDeliveryUrl\",\n usedDomain: \"deliveryDomain\",\n usedUrl: \"deliveryUrl\"\n }\n });\n });\n\n tagResources({\n WbyProjectName: getEnvVariableWebinyProjectName(),\n WbyEnvironment: getEnvVariableWebinyEnv(),\n WbyEnvironmentVariant: getEnvVariableWebinyVariant()\n });\n\n return {\n prerendering,\n\n // \"preview\" and \"app\" are the same.\n // We introduced \"preview\" just because it's the word we use when talking about\n // Page Builder and \"previewing\" pages. In other words, the \"preview\" property\n // contains all resources related to serving page previews, unlike \"delivery\",\n // which is used to serve published pages to actual website visitors.\n // The \"app\" property was still left here just for backwards compatibility.\n preview: {\n ...appBucket,\n cloudfront: appCloudfront\n },\n app: {\n ...appBucket,\n cloudfront: appCloudfront\n },\n\n delivery: {\n ...deliveryBucket,\n cloudfront: deliveryCloudfront\n }\n };\n }\n });\n\n const app = withServiceManifest(withCommonLambdaEnvVariables(baseApp));\n\n app.addHandler(() => {\n const preview = baseApp.resources.preview;\n const delivery = baseApp.resources.delivery;\n\n app.addServiceManifest({\n name: \"website\",\n manifest: {\n preview: {\n cloudfront: {\n distributionId: preview.cloudfront.output.id,\n domainName: preview.cloudfront.output.domainName\n },\n bucket: {\n name: preview.bucket.output.id,\n arn: preview.bucket.output.arn,\n bucketDomainName: preview.bucket.output.bucketDomainName,\n bucketRegionalDomainName: preview.bucket.output.bucketRegionalDomainName\n }\n },\n delivery: {\n cloudfront: {\n distributionId: delivery.cloudfront.output.id,\n domainName: delivery.cloudfront.output.domainName\n },\n bucket: {\n name: delivery.bucket.output.id,\n arn: delivery.bucket.output.arn,\n bucketDomainName: delivery.bucket.output.bucketDomainName,\n bucketRegionalDomainName: delivery.bucket.output.bucketRegionalDomainName\n }\n }\n }\n });\n });\n\n return app;\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,GAAA,GAAAF,uBAAA,CAAAC,OAA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MAAM,CAACC,GAAG;YAC9B0D,gBAAgB,EAAER,OAAO,CAAC/B,MAAM,CAACpB,MAAM,CAAC2D,gBAAgB;YACxDC,wBAAwB,EAAET,OAAO,CAAC/B,MAAM,CAACpB,MAAM,CAAC4D;UACpD;QACJ,CAAC;QACDR,QAAQ,EAAE;UACNjG,UAAU,EAAE;YACRuG,cAAc,EAAEN,QAAQ,CAACjG,UAAU,CAAC6C,MAAM,CAACsB,EAAE;YAC7CJ,UAAU,EAAEkC,QAAQ,CAACjG,UAAU,CAAC6C,MAAM,CAACkB;UAC3C,CAAC;UACDE,MAAM,EAAE;YACJhG,IAAI,EAAEgI,QAAQ,CAAChC,MAAM,CAACpB,MAAM,CAACsB,EAAE;YAC/BrB,GAAG,EAAEmD,QAAQ,CAAChC,MAAM,CAACpB,MAAM,CAACC,GAAG;YAC/B0D,gBAAgB,EAAEP,QAAQ,CAAChC,MAAM,CAACpB,MAAM,CAAC2D,gBAAgB;YACzDC,wBAAwB,EAAER,QAAQ,CAAChC,MAAM,CAACpB,MAAM,CAAC4D;UACrD;QACJ;MACJ;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;EAEF,OAAOpI,GAAG;AACd,CAAC;AAACqI,OAAA,CAAA7I,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["pulumi","_interopRequireWildcard","require","aws","_fs","_interopRequireDefault","_pulumi2","_createAppBucket","_customDomain","_WebsitePrerendering","_","_utils","_tenantRouter","_withServiceManifest","_constants","_variant","_env","_projectName","createWebsitePulumiApp","projectAppParams","baseApp","createPulumiApp","name","path","config","program","app","pulumiResourceNamePrefix","getParam","onResource","resource","startsWith","addHandler","productionEnvironments","params","create","DEFAULT_PROD_ENV_NAMES","isProduction","includes","run","env","core","addModule","CoreOutput","ApiOutput","vpcEnabled","vpc","VpcConfig","enabled","appBucket","createPrivateAppBucket","appCloudfront","addResource","cloudfront","Distribution","waitForDeployment","origins","origin","defaultRootObject","defaultCacheBehavior","compress","targetOriginId","originId","viewerProtocolPolicy","allowedMethods","cachedMethods","forwardedValues","cookies","forward","queryString","minTtl","defaultTtl","maxTtl","priceClass","customErrorResponses","errorCode","responseCode","responsePagePath","restrictions","geoRestriction","restrictionType","viewerCertificate","cloudfrontDefaultCertificate","opts","ignoreChanges","deliveryBucket","viewerRequest","Function","runtime","publish","code","fs","readFileSync","__dirname","deliveryCloudfront","originRequestPolicyId","functionAssociations","functionArn","output","arn","eventType","orderedCacheBehaviors","headers","pathPattern","prerendering","createPrerenderingService","dbTableName","primaryDynamodbTableName","dbTableHashKey","primaryDynamodbTableHashKey","dbTableRangeKey","primaryDynamodbTableRangeKey","logDbTableName","logDynamodbTableName","appUrl","interpolate","domainName","deliveryUrl","bucket","cloudfrontId","id","domains","applyCustomDomain","previewDomains","process","WCP_PROJECT_ENVIRONMENT","WEBINY_MULTI_TENANCY","originLambda","applyTenantRouter","addOutputs","websiteRouterOriginRequestFunction","appId","appStorage","deliveryId","deliveryStorage","addDomainsUrlsOutputs","cloudfrontDistribution","map","distributionDomain","distributionUrl","usedDomain","usedUrl","tagResources","WbyProjectName","getEnvVariableWebinyProjectName","WbyEnvironment","getEnvVariableWebinyEnv","WbyEnvironmentVariant","getEnvVariableWebinyVariant","preview","delivery","withServiceManifest","withCommonLambdaEnvVariables","resources","addServiceManifest","manifest","distributionId","bucketDomainName","bucketRegionalDomainName","exports"],"sources":["createWebsitePulumiApp.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport fs from \"fs\";\nimport type { PulumiAppParam, PulumiAppParamCallback } from \"@webiny/pulumi\";\nimport { createPulumiApp } from \"@webiny/pulumi\";\nimport { createPrivateAppBucket } from \"../createAppBucket\";\nimport type { CustomDomainParams } from \"../customDomain\";\nimport { applyCustomDomain } from \"../customDomain\";\nimport { createPrerenderingService } from \"./WebsitePrerendering\";\nimport { ApiOutput, CoreOutput, VpcConfig } from \"~/apps\";\nimport { addDomainsUrlsOutputs, tagResources, withCommonLambdaEnvVariables } from \"~/utils\";\nimport { applyTenantRouter } from \"~/apps/tenantRouter\";\nimport { withServiceManifest } from \"~/utils/withServiceManifest\";\nimport { DEFAULT_PROD_ENV_NAMES } from \"~/constants\";\nimport { getEnvVariableWebinyVariant } from \"~/env/variant\";\nimport { getEnvVariableWebinyEnv } from \"~/env/env\";\nimport { getEnvVariableWebinyProjectName } from \"~/env/projectName\";\n\nexport type WebsitePulumiApp = ReturnType<typeof createWebsitePulumiApp>;\n\nexport interface CreateWebsitePulumiAppParams {\n /**\n * Custom domain(s) configuration.\n */\n domains?: PulumiAppParamCallback<CustomDomainParams>;\n\n /**\n * Custom preview domain(s) configuration.\n */\n previewDomains?: PulumiAppParamCallback<CustomDomainParams>;\n\n /**\n * Enables or disables VPC for the API.\n * For VPC to work you also have to enable it in the `core` application.\n */\n vpc?: PulumiAppParam<boolean | undefined>;\n\n /**\n * Provides a way to adjust existing Pulumi code (cloud infrastructure resources)\n * or add additional ones into the mix.\n */\n pulumi?: (app: WebsitePulumiApp) => void | Promise<void>;\n\n /**\n * Prefixes names of all Pulumi cloud infrastructure resource with given prefix.\n */\n pulumiResourceNamePrefix?: PulumiAppParam<string>;\n\n /**\n * Treats provided environments as production environments, which\n * are deployed in production deployment mode.\n * https://www.webiny.com/docs/architecture/deployment-modes/production\n */\n productionEnvironments?: PulumiAppParam<string[]>;\n}\n\nexport const createWebsitePulumiApp = (projectAppParams: CreateWebsitePulumiAppParams = {}) => {\n const baseApp = createPulumiApp({\n name: \"website\",\n path: \"apps/website\",\n config: projectAppParams,\n program: async app => {\n const pulumiResourceNamePrefix = app.getParam(\n projectAppParams.pulumiResourceNamePrefix\n );\n if (pulumiResourceNamePrefix) {\n app.onResource(resource => {\n if (!resource.name.startsWith(pulumiResourceNamePrefix)) {\n resource.name = `${pulumiResourceNamePrefix}${resource.name}`;\n }\n });\n }\n\n // Overrides must be applied via a handler, registered at the very start of the program.\n // By doing this, we're ensuring user's adjustments are not applied to late.\n if (projectAppParams.pulumi) {\n app.addHandler(() => {\n return projectAppParams.pulumi!(app as WebsitePulumiApp);\n });\n }\n\n const productionEnvironments =\n app.params.create.productionEnvironments || DEFAULT_PROD_ENV_NAMES;\n const isProduction = productionEnvironments.includes(app.params.run.env);\n\n // Register core and api output as a module, to be available to all other modules.\n const core = app.addModule(CoreOutput);\n app.addModule(ApiOutput);\n\n // Register VPC config module to be available to other modules.\n const vpcEnabled = app.getParam(projectAppParams?.vpc) ?? isProduction;\n app.addModule(VpcConfig, { enabled: vpcEnabled });\n\n const appBucket = createPrivateAppBucket(app, \"app\");\n\n const appCloudfront = app.addResource(aws.cloudfront.Distribution, {\n name: \"app\",\n config: {\n enabled: true,\n waitForDeployment: true,\n origins: [appBucket.origin],\n defaultRootObject: \"index.html\",\n defaultCacheBehavior: {\n compress: true,\n targetOriginId: appBucket.origin.originId,\n viewerProtocolPolicy: \"redirect-to-https\",\n allowedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n cachedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n forwardedValues: {\n cookies: { forward: \"none\" },\n queryString: false\n },\n // MinTTL <= DefaultTTL <= MaxTTL\n minTtl: 0,\n defaultTtl: 0,\n maxTtl: 0\n },\n priceClass: \"PriceClass_100\",\n customErrorResponses: [\n { errorCode: 404, responseCode: 404, responsePagePath: \"/index.html\" }\n ],\n restrictions: {\n geoRestriction: {\n restrictionType: \"none\"\n }\n },\n viewerCertificate: {\n cloudfrontDefaultCertificate: true\n }\n },\n opts: {\n // We are ignoring changes to the \"staging\" property. This is because of the following.\n // With the 5.41.0 release of Webiny, we also upgraded Pulumi to v6. This introduced a change\n // with how Cloudfront distributions are deployed, where Pulumi now also controls the new\n // `staging` property.\n // If not set, Pulumi will default it to `false`. Which is fine, but, the problem is\n // that, because this property did not exist before, it will always be considered as a change\n // upon deployment.\n // We might think this is fine, but, the problem is that a change in this property causes\n // a full replacement of the Cloudfront distribution, which is not acceptable. Especially\n // if a custom domain has already been associated with the distribution. This then would\n // require the user to disassociate the domain, wait for the distribution to be replaced,\n // and then re-associate the domain. This is not a good experience.\n ignoreChanges: [\"staging\"]\n }\n });\n\n const deliveryBucket = createPrivateAppBucket(app, \"delivery\");\n\n /**\n * We need to have a Cloudfront Function to perform a simple request rewrite, so the request always includes\n * an \"/index.html\". This is necessary because our buckets are not \"website\" buckets, and we need to\n * have an exact object key when requesting page paths.\n */\n const viewerRequest = app.addResource(aws.cloudfront.Function, {\n name: \"cfViewerRequest\",\n config: {\n runtime: \"cloudfront-js-1.0\",\n publish: true,\n code: fs.readFileSync(__dirname + `/deliveryViewerRequest.js`, \"utf8\")\n }\n });\n\n const deliveryCloudfront = app.addResource(aws.cloudfront.Distribution, {\n name: \"delivery\",\n config: {\n enabled: true,\n waitForDeployment: true,\n origins: [deliveryBucket.origin, appBucket.origin],\n defaultRootObject: \"index.html\",\n defaultCacheBehavior: {\n compress: true,\n targetOriginId: deliveryBucket.origin.originId,\n viewerProtocolPolicy: \"redirect-to-https\",\n allowedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n cachedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n originRequestPolicyId: \"\",\n forwardedValues: {\n cookies: { forward: \"none\" },\n queryString: true\n },\n // MinTTL <= DefaultTTL <= MaxTTL\n minTtl: 0,\n defaultTtl: 30,\n maxTtl: 30,\n functionAssociations: [\n { functionArn: viewerRequest.output.arn, eventType: \"viewer-request\" }\n ]\n },\n orderedCacheBehaviors: [\n {\n compress: true,\n allowedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n cachedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n forwardedValues: {\n cookies: {\n forward: \"none\"\n },\n headers: [],\n queryString: false\n },\n pathPattern: \"/static/*\",\n viewerProtocolPolicy: \"allow-all\",\n targetOriginId: appBucket.origin.originId,\n // MinTTL <= DefaultTTL <= MaxTTL\n minTtl: 0,\n defaultTtl: 2592000, // 30 days\n maxTtl: 2592000\n },\n // This forward is necessary for non-WCP projects. For WCP projects, the\n // forwarding is performed by the `website-router` Lambda@Edge function.\n {\n compress: true,\n allowedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n cachedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n forwardedValues: {\n cookies: {\n forward: \"none\"\n },\n headers: [],\n queryString: false\n },\n pathPattern: \"/robots.txt\",\n viewerProtocolPolicy: \"allow-all\",\n targetOriginId: appBucket.origin.originId\n }\n ],\n customErrorResponses: [\n {\n errorCode: 404,\n responseCode: 404,\n responsePagePath: \"/_NOT_FOUND_PAGE_/index.html\"\n }\n ],\n priceClass: \"PriceClass_100\",\n restrictions: {\n geoRestriction: {\n restrictionType: \"none\"\n }\n },\n viewerCertificate: {\n cloudfrontDefaultCertificate: true\n }\n },\n opts: {\n // Check the comment in the `appCloudfront` resource above for more info.\n ignoreChanges: [\"staging\"]\n }\n });\n\n const prerendering = createPrerenderingService(app, {\n dbTableName: core.primaryDynamodbTableName,\n dbTableHashKey: core.primaryDynamodbTableHashKey,\n dbTableRangeKey: core.primaryDynamodbTableRangeKey,\n logDbTableName: core.logDynamodbTableName,\n appUrl: pulumi.interpolate`https://${appCloudfront.output.domainName}`,\n deliveryUrl: pulumi.interpolate`https://${deliveryCloudfront.output.domainName}`,\n bucket: deliveryBucket.bucket.output.bucket,\n cloudfrontId: deliveryCloudfront.output.id\n });\n\n const domains = app.getParam(projectAppParams.domains);\n if (domains) {\n applyCustomDomain(deliveryCloudfront, domains);\n }\n\n const previewDomains = app.getParam(projectAppParams.previewDomains);\n if (previewDomains) {\n applyCustomDomain(appCloudfront, previewDomains);\n }\n\n if (\n process.env.WCP_PROJECT_ENVIRONMENT ||\n process.env.WEBINY_MULTI_TENANCY === \"true\"\n ) {\n const { originLambda } = applyTenantRouter(app, deliveryCloudfront);\n\n app.addHandler(() => {\n app.addOutputs({\n websiteRouterOriginRequestFunction: originLambda.output.name\n });\n });\n }\n\n app.addOutputs({\n // Cloudfront and S3 bucket used to host the single-page application (SPA). The URL of the distribution is mainly\n // utilized by the Page Builder app's prerendering engine. Using this URL, it accesses the SPA and creates HTML snapshots.\n // The files that are generated in that process are stored in the `deliveryStorage` S3 bucket further below.\n appId: appCloudfront.output.id,\n appStorage: appBucket.bucket.output.id,\n\n // These are the Cloudfront and S3 bucket that will deliver static pages to the actual website visitors.\n // The static HTML snapshots delivered from them still rely on the app's S3 bucket\n // defined above, for serving static assets (JS, CSS, images).\n deliveryId: deliveryCloudfront.output.id,\n deliveryStorage: deliveryBucket.bucket.output.id\n });\n\n app.addHandler(() => {\n addDomainsUrlsOutputs({\n app,\n cloudfrontDistribution: appCloudfront,\n map: {\n distributionDomain: \"cloudfrontAppDomain\",\n distributionUrl: \"cloudfrontAppUrl\",\n usedDomain: \"appDomain\",\n usedUrl: \"appUrl\"\n }\n });\n\n addDomainsUrlsOutputs({\n app,\n cloudfrontDistribution: deliveryCloudfront,\n map: {\n distributionDomain: \"cloudfrontDeliveryDomain\",\n distributionUrl: \"cloudfrontDeliveryUrl\",\n usedDomain: \"deliveryDomain\",\n usedUrl: \"deliveryUrl\"\n }\n });\n });\n\n tagResources({\n WbyProjectName: getEnvVariableWebinyProjectName(),\n WbyEnvironment: getEnvVariableWebinyEnv(),\n WbyEnvironmentVariant: getEnvVariableWebinyVariant()\n });\n\n return {\n prerendering,\n\n // \"preview\" and \"app\" are the same.\n // We introduced \"preview\" just because it's the word we use when talking about\n // Page Builder and \"previewing\" pages. In other words, the \"preview\" property\n // contains all resources related to serving page previews, unlike \"delivery\",\n // which is used to serve published pages to actual website visitors.\n // The \"app\" property was still left here just for backwards compatibility.\n preview: {\n ...appBucket,\n cloudfront: appCloudfront\n },\n app: {\n ...appBucket,\n cloudfront: appCloudfront\n },\n\n delivery: {\n ...deliveryBucket,\n cloudfront: deliveryCloudfront\n }\n };\n }\n });\n\n const app = withServiceManifest(withCommonLambdaEnvVariables(baseApp));\n\n app.addHandler(() => {\n const preview = baseApp.resources.preview;\n const delivery = baseApp.resources.delivery;\n\n app.addServiceManifest({\n name: \"website\",\n manifest: {\n preview: {\n cloudfront: {\n distributionId: preview.cloudfront.output.id,\n domainName: preview.cloudfront.output.domainName\n },\n bucket: {\n name: preview.bucket.output.id,\n arn: preview.bucket.output.arn,\n bucketDomainName: preview.bucket.output.bucketDomainName,\n bucketRegionalDomainName: preview.bucket.output.bucketRegionalDomainName\n }\n },\n delivery: {\n cloudfront: {\n distributionId: delivery.cloudfront.output.id,\n domainName: delivery.cloudfront.output.domainName\n },\n bucket: {\n name: delivery.bucket.output.id,\n arn: delivery.bucket.output.arn,\n bucketDomainName: delivery.bucket.output.bucketDomainName,\n bucketRegionalDomainName: delivery.bucket.output.bucketRegionalDomainName\n }\n }\n }\n });\n });\n\n return app;\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,GAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,GAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AAEA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,oBAAA,GAAAP,OAAA;AACA,IAAAQ,CAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,aAAA,GAAAV,OAAA;AACA,IAAAW,oBAAA,GAAAX,OAAA;AACA,IAAAY,UAAA,GAAAZ,OAAA;AACA,IAAAa,QAAA,GAAAb,OAAA;AACA,IAAAc,IAAA,GAAAd,OAAA;AACA,IAAAe,YAAA,GAAAf,OAAA;AAwCO,MAAMgB,sBAAsB,GAAGA,CAACC,gBAA8C,GAAG,CAAC,CAAC,KAAK;EAC3F,MAAMC,OAAO,GAAG,IAAAC,wBAAe,EAAC;IAC5BC,IAAI,EAAE,SAAS;IACfC,IAAI,EAAE,cAAc;IACpBC,MAAM,EAAEL,gBAAgB;IACxBM,O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CAACpB,MAAM,CAAC4D;UACrD;QACJ;MACJ;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;EAEF,OAAOpI,GAAG;AACd,CAAC;AAACqI,OAAA,CAAA7I,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ApiPulumiApp } from "../../index";
|
|
1
|
+
import type { ApiPulumiApp } from "../../index";
|
|
2
2
|
export declare const handleGuardDutyEvents: (app: ApiPulumiApp) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["aws","_interopRequireWildcard","require","_","handleGuardDutyEvents","app","core","getModule","CoreOutput","graphql","resources","functions","baseConfig","config","clone","threatDetectionHandler","addResource","lambda","Function","name","memorySize","description","environment","variables","output","apply","env","WEBINY_FUNCTION_TYPE","eventRule","cloudwatch","EventRule","eventBusName","eventPattern","JSON","stringify","source","Permission","action","function","arn","principal","sourceArn","EventTarget","rule","exports"],"sources":["handleGuardDutyEvents.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport { ApiPulumiApp
|
|
1
|
+
{"version":3,"names":["aws","_interopRequireWildcard","require","_","handleGuardDutyEvents","app","core","getModule","CoreOutput","graphql","resources","functions","baseConfig","config","clone","threatDetectionHandler","addResource","lambda","Function","name","memorySize","description","environment","variables","output","apply","env","WEBINY_FUNCTION_TYPE","eventRule","cloudwatch","EventRule","eventBusName","eventPattern","JSON","stringify","source","Permission","action","function","arn","principal","sourceArn","EventTarget","rule","exports"],"sources":["handleGuardDutyEvents.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport type { ApiPulumiApp } from \"~/index\";\nimport { CoreOutput } from \"~/index\";\n\nexport const handleGuardDutyEvents = (app: ApiPulumiApp) => {\n const core = app.getModule(CoreOutput);\n const graphql = app.resources.graphql.functions.graphql;\n\n const baseConfig = graphql.config.clone();\n\n const threatDetectionHandler = app.addResource(aws.lambda.Function, {\n name: \"fm-threat-detection\",\n config: {\n ...baseConfig,\n memorySize: 1024,\n description: \"Handles Guard Duty threat scan results.\",\n environment: {\n variables: graphql.output.environment.apply(env => {\n return {\n WEBINY_FUNCTION_TYPE: \"threat-detection-event-handler\",\n ...env?.variables\n };\n })\n }\n }\n });\n\n const eventRule = app.addResource(aws.cloudwatch.EventRule, {\n name: `fm-bucket-malware-protection-event-rule`,\n config: {\n eventBusName: core.eventBusName,\n eventPattern: JSON.stringify({\n source: [\"aws.guardduty\"],\n \"detail-type\": [\"GuardDuty Malware Protection Object Scan Result\"]\n })\n }\n });\n\n app.addResource(aws.lambda.Permission, {\n name: \"fm-bucket-malware-protection-event-permission\",\n config: {\n action: \"lambda:InvokeFunction\",\n function: threatDetectionHandler.output.arn,\n principal: \"events.amazonaws.com\",\n sourceArn: eventRule.output.arn\n }\n });\n\n app.addResource(aws.cloudwatch.EventTarget, {\n name: `fm-bucket-malware-protection-event-target`,\n config: {\n rule: eventRule.output.name,\n arn: threatDetectionHandler.output.arn,\n eventBusName: core.eventBusName\n }\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,CAAA,GAAAD,OAAA;AAEO,MAAME,qBAAqB,GAAIC,GAAiB,IAAK;EACxD,MAAMC,IAAI,GAAGD,GAAG,CAACE,SAAS,CAACC,YAAU,CAAC;EACtC,MAAMC,OAAO,GAAGJ,GAAG,CAACK,SAAS,CAACD,OAAO,CAACE,SAAS,CAACF,OAAO;EAEvD,MAAMG,UAAU,GAAGH,OAAO,CAACI,MAAM,CAACC,KAAK,CAAC,CAAC;EAEzC,MAAMC,sBAAsB,GAAGV,GAAG,CAACW,WAAW,CAAChB,GAAG,CAACiB,MAAM,CAACC,QAAQ,EAAE;IAChEC,IAAI,EAAE,qBAAqB;IAC3BN,MAAM,EAAE;MACJ,GAAGD,UAAU;MACbQ,UAAU,EAAE,IAAI;MAChBC,WAAW,EAAE,yCAAyC;MACtDC,WAAW,EAAE;QACTC,SAAS,EAA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|
2
|
-
import { PulumiAppParam } from "@webiny/pulumi";
|
|
3
|
-
import { CreateApiPulumiAppParams as BaseCreateApiPulumiAppParams } from "../apps/api/createApiPulumiApp";
|
|
2
|
+
import type { PulumiAppParam } from "@webiny/pulumi";
|
|
3
|
+
import type { CreateApiPulumiAppParams as BaseCreateApiPulumiAppParams } from "../apps/api/createApiPulumiApp";
|
|
4
4
|
export type ApiPulumiApp = ReturnType<typeof createApiPulumiApp>;
|
|
5
5
|
export type ApiPulumiAppAdvancedVpcParams = Partial<{
|
|
6
6
|
useExistingVpc: {
|
|
@@ -12,6 +12,12 @@ export interface CreateApiPulumiAppParams extends Omit<BaseCreateApiPulumiAppPar
|
|
|
12
12
|
}
|
|
13
13
|
export declare function createApiPulumiApp(projectAppParams?: CreateApiPulumiAppParams): import("@webiny/pulumi").PulumiApp<{
|
|
14
14
|
fileManager: {
|
|
15
|
+
roles: {
|
|
16
|
+
manage: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
|
|
17
|
+
};
|
|
18
|
+
policies: {
|
|
19
|
+
manage: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/policy").Policy>;
|
|
20
|
+
};
|
|
15
21
|
functions: {
|
|
16
22
|
manage: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function").Function>;
|
|
17
23
|
download: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function").Function>;
|
|
@@ -74,4 +80,9 @@ export declare function createApiPulumiApp(projectAppParams?: CreateApiPulumiApp
|
|
|
74
80
|
eventRolePolicyAttachment: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/rolePolicyAttachment").RolePolicyAttachment>;
|
|
75
81
|
eventTarget: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudwatch/eventTarget").EventTarget>;
|
|
76
82
|
};
|
|
83
|
+
scheduler: {
|
|
84
|
+
invokeRole: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
|
|
85
|
+
invokePolicy: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/rolePolicy").RolePolicy>;
|
|
86
|
+
policyAttachment: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/rolePolicyAttachment").RolePolicyAttachment>;
|
|
87
|
+
};
|
|
77
88
|
}> & import("../utils/lambdaEnvVariables").WithCommonLambdaEnvVariables & import("../utils/withServiceManifest").WithServiceManifest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["aws","_interopRequireWildcard","require","_pulumi","_wcp","_createApiPulumiApp","_handleGuardDutyEvents","createApiPulumiApp","projectAppParams","baseCreateApiPulumiApp","vpc","getParam","usingAdvancedVpcParams","useExistingVpc","pulumi","app","license","License","fromEnvironment","canUseFileManagerThreatDetection","handleGuardDutyEvents","onResource","addResource","lambdaFunctionsVpcConfig","Error","resource","isResourceOfType","lambda","Function","canUseVpc","meta","config","vpcConfig","iam","Role","isLambdaFunctionRole","RolePolicyAttachment","name","role","output","policyArn","ManagedPolicy","AWSLambdaVPCAccessExecutionRole"],"sources":["createApiPulumiApp.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport {
|
|
1
|
+
{"version":3,"names":["aws","_interopRequireWildcard","require","_pulumi","_wcp","_createApiPulumiApp","_handleGuardDutyEvents","createApiPulumiApp","projectAppParams","baseCreateApiPulumiApp","vpc","getParam","usingAdvancedVpcParams","useExistingVpc","pulumi","app","license","License","fromEnvironment","canUseFileManagerThreatDetection","handleGuardDutyEvents","onResource","addResource","lambdaFunctionsVpcConfig","Error","resource","isResourceOfType","lambda","Function","canUseVpc","meta","config","vpcConfig","iam","Role","isLambdaFunctionRole","RolePolicyAttachment","name","role","output","policyArn","ManagedPolicy","AWSLambdaVPCAccessExecutionRole"],"sources":["createApiPulumiApp.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport type { PulumiAppParam } from \"@webiny/pulumi\";\nimport { isResourceOfType } from \"@webiny/pulumi\";\nimport { License } from \"@webiny/wcp\";\nimport type { CreateApiPulumiAppParams as BaseCreateApiPulumiAppParams } from \"~/apps/api/createApiPulumiApp\";\nimport { createApiPulumiApp as baseCreateApiPulumiApp } from \"~/apps/api/createApiPulumiApp\";\nimport { handleGuardDutyEvents } from \"~/enterprise/api/handleGuardDutyEvents\";\n\nexport type ApiPulumiApp = ReturnType<typeof createApiPulumiApp>;\n\nexport type ApiPulumiAppAdvancedVpcParams = Partial<{\n useExistingVpc: {\n lambdaFunctionsVpcConfig: aws.types.input.lambda.FunctionVpcConfig;\n };\n}>;\n\nexport interface CreateApiPulumiAppParams extends Omit<BaseCreateApiPulumiAppParams, \"vpc\"> {\n vpc?: PulumiAppParam<boolean | ApiPulumiAppAdvancedVpcParams>;\n}\n\nexport function createApiPulumiApp(projectAppParams: CreateApiPulumiAppParams = {}) {\n return baseCreateApiPulumiApp({\n ...projectAppParams,\n // If using existing VPC, we ensure `vpc` param is set to `false`.\n vpc: ({ getParam }) => {\n const vpc = getParam(projectAppParams.vpc);\n if (!vpc) {\n // This could be `false` or `undefined`. If `undefined`, down the line,\n // this means \"deploy into VPC if dealing with a production environment\".\n return vpc;\n }\n\n // If using an existing VPC, we ensure Webiny does not deploy its own VPC.\n const usingAdvancedVpcParams = typeof vpc !== \"boolean\";\n if (usingAdvancedVpcParams && vpc.useExistingVpc) {\n return false;\n }\n\n return true;\n },\n async pulumi(app) {\n const license = await License.fromEnvironment();\n\n const { getParam } = app;\n const vpc = getParam(projectAppParams.vpc);\n const usingAdvancedVpcParams = vpc && typeof vpc !== \"boolean\";\n\n if (license.canUseFileManagerThreatDetection()) {\n handleGuardDutyEvents(app);\n }\n\n // Not using advanced VPC params? Then immediately exit.\n if (!usingAdvancedVpcParams) {\n return projectAppParams.pulumi?.(app);\n }\n\n const { onResource, addResource } = app;\n const { useExistingVpc } = vpc;\n\n // 1. We first deal with \"existing VPC\" setup.\n if (useExistingVpc) {\n if (!useExistingVpc.lambdaFunctionsVpcConfig) {\n throw new Error(\n \"Cannot specify `useExistingVpc` parameter because the `lambdaFunctionsVpcConfig` parameter wasn't provided.\"\n );\n }\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.lambda.Function)) {\n const canUseVpc = resource.meta.canUseVpc !== false;\n if (canUseVpc) {\n resource.config.vpcConfig(useExistingVpc!.lambdaFunctionsVpcConfig);\n }\n }\n\n if (isResourceOfType(resource, aws.iam.Role)) {\n if (resource.meta.isLambdaFunctionRole) {\n addResource(aws.iam.RolePolicyAttachment, {\n name: `${resource.name}-vpc-access-execution-role`,\n config: {\n role: resource.output.name,\n policyArn: aws.iam.ManagedPolicy.AWSLambdaVPCAccessExecutionRole\n }\n });\n }\n }\n });\n }\n\n return projectAppParams.pulumi?.(app);\n }\n });\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AAEA,IAAAG,mBAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAJ,OAAA;AAcO,SAASK,kBAAkBA,CAACC,gBAA0C,GAAG,CAAC,CAAC,EAAE;EAChF,OAAO,IAAAC,sCAAsB,EAAC;IAC1B,GAAGD,gBAAgB;IACnB;IACAE,GAAG,EAAEA,CAAC;MAAEC;IAAS,CAAC,KAAK;MACnB,MAAMD,GAAG,GAAGC,QAAQ,CAACH,gBAAgB,CAACE,GAAG,CAAC;MAC1C,IAAI,CAACA,GAAG,EAAE;QACN;QACA;QACA,OAAOA,GAAG;MACd;;MAEA;MACA,MAAME,sBAAsB,GAAG,OAAOF,GAAG,KAAK,SAAS;MACvD,IAAIE,sBAAsB,IAAIF,GAAG,CAACG,cAAc,EAAE;QAC9C,OAAO,KAAK;MAChB;MAEA,OAAO,IAAI;IACf,CAAC;IACD,MAAMC,MAAMA,CAACC,GAAG,EAAE;MACd,MAAMC,OAA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MAAM,EAAE;kBACJO,IAAI,EAAEb,QAAQ,CAACc,MAAM,CAACF,IAAI;kBAC1BG,SAAS,EAAExC,GAAG,CAACiC,GAAG,CAACQ,aAAa,CAACC;gBACrC;cACJ,CAAC,CAAC;YACN;UACJ;QACJ,CAAC,CAAC;MACN;MAEA,OAAOlC,gBAAgB,CAACM,MAAM,GAAGC,GAAG,CAAC;IACzC;EACJ,CAAC,CAAC;AACN","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as aws from "@pulumi/aws";
|
|
2
|
-
import { CreateCorePulumiAppParams as BaseCreateCorePulumiAppParams } from "../apps/core/createCorePulumiApp";
|
|
3
|
-
import { PulumiAppParam } from "@webiny/pulumi";
|
|
2
|
+
import type { CreateCorePulumiAppParams as BaseCreateCorePulumiAppParams } from "../apps/core/createCorePulumiApp";
|
|
3
|
+
import type { PulumiAppParam } from "@webiny/pulumi";
|
|
4
4
|
export type CorePulumiApp = ReturnType<typeof createCorePulumiApp>;
|
|
5
5
|
export type CorePulumiAppAdvancedVpcParams = Partial<{
|
|
6
6
|
useVpcEndpoints: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["aws","_interopRequireWildcard","require","pulumi","_createCorePulumiApp","_pulumi2","_awsUtils","_configureS3BucketMalwareProtection","_wcp","createCorePulumiApp","projectAppParams","baseCreateCorePulumiApp","vpc","getParam","usingAdvancedVpcParams","useExistingVpc","args","app","license","License","fromEnvironment","canUseFileManagerThreatDetection","configureS3BucketMalwareProtection","resources","addResource","onResource","useVpcEndpoints","Error","elasticSearch","elasticSearchDomainVpcConfig","resource","isResourceOfType","elasticsearch","Domain","config","vpcOptions","openSearch","openSearchDomainVpcConfig","opensearch","lambdaFunctionsVpcConfig","lambda","Function","canUseVpc","meta","vpcConfig","iam","Role","isLambdaFunctionRole","RolePolicyAttachment","name","role","output","policyArn","ManagedPolicy","AWSLambdaVPCAccessExecutionRole","region","getAwsRegion","ec2","Vpc","enableDnsSupport","enableDnsHostnames","subnets","routeTables","VpcEndpoint","vpcId","id","serviceName","interpolate","routeTableIds","privateSubnets","vpcEndpointType","privateDnsEnabled","securityGroupIds","defaultSecurityGroupId","subnetIds","private","map","subNet"],"sources":["createCorePulumiApp.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport {\n createCorePulumiApp as baseCreateCorePulumiApp,\n CreateCorePulumiAppParams as BaseCreateCorePulumiAppParams\n} from \"~/apps/core/createCorePulumiApp\";\nimport { isResourceOfType, PulumiAppParam } from \"@webiny/pulumi\";\nimport { getAwsRegion } from \"~/apps/awsUtils\";\nimport { configureS3BucketMalwareProtection } from \"~/enterprise/core/configureS3BucketMalwareProtection\";\nimport { License } from \"@webiny/wcp\";\n\nexport type CorePulumiApp = ReturnType<typeof createCorePulumiApp>;\n\nexport type CorePulumiAppAdvancedVpcParams = Partial<{\n useVpcEndpoints: boolean;\n useExistingVpc: {\n elasticSearchDomainVpcConfig?: aws.types.input.elasticsearch.DomainVpcOptions;\n openSearchDomainVpcConfig?: aws.types.input.opensearch.DomainVpcOptions;\n lambdaFunctionsVpcConfig: aws.types.input.lambda.FunctionVpcConfig;\n };\n}>;\n\nexport interface CreateCorePulumiAppParams extends Omit<BaseCreateCorePulumiAppParams, \"vpc\"> {\n vpc?: PulumiAppParam<boolean | CorePulumiAppAdvancedVpcParams>;\n}\n\nexport function createCorePulumiApp(projectAppParams: CreateCorePulumiAppParams = {}) {\n return baseCreateCorePulumiApp({\n ...projectAppParams,\n // If using existing VPC, we ensure `vpc` param is set to `false`.\n vpc: ({ getParam }) => {\n const vpc = getParam(projectAppParams.vpc);\n if (!vpc) {\n // This could be `false` or `undefined`. If `undefined`, down the line,\n // this means \"deploy into VPC if dealing with a production environment\".\n return vpc;\n }\n\n // If using an existing VPC, we ensure Webiny does not deploy its own VPC.\n const usingAdvancedVpcParams = typeof vpc !== \"boolean\";\n if (usingAdvancedVpcParams && vpc.useExistingVpc) {\n return false;\n }\n\n return true;\n },\n async pulumi(...args) {\n const [app] = args;\n const { getParam } = app;\n const vpc = getParam(projectAppParams.vpc);\n const usingAdvancedVpcParams = vpc && typeof vpc !== \"boolean\";\n\n const license = await License.fromEnvironment();\n\n if (license.canUseFileManagerThreatDetection()) {\n configureS3BucketMalwareProtection(app);\n }\n\n // Not using advanced VPC params? Then immediately exit.\n if (!usingAdvancedVpcParams) {\n return projectAppParams.pulumi?.(...args);\n }\n\n const [{ resources, addResource, onResource }] = args;\n const { useExistingVpc, useVpcEndpoints } = vpc;\n\n // 1. We first deal with \"existing VPC\" setup.\n if (useExistingVpc) {\n if (\"useVpcEndpoints\" in vpc) {\n throw new Error(\n \"Cannot specify `useVpcEndpoints` parameter when using an existing VPC. The VPC endpoints configurations should be already defined within the existing VPC.\"\n );\n }\n\n if (projectAppParams.elasticSearch) {\n if (!useExistingVpc.elasticSearchDomainVpcConfig) {\n throw new Error(\n \"Cannot specify `useExistingVpc` parameter because the `elasticSearchDomainVpcConfig` parameter wasn't provided.\"\n );\n }\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.elasticsearch.Domain)) {\n resource.config.vpcOptions(\n useExistingVpc!.elasticSearchDomainVpcConfig\n );\n }\n });\n }\n\n if (projectAppParams.openSearch) {\n if (!useExistingVpc.openSearchDomainVpcConfig) {\n throw new Error(\n \"Cannot specify `useExistingVpc` parameter because the `openSearchDomainVpcConfig` parameter wasn't provided.\"\n );\n }\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.opensearch.Domain)) {\n resource.config.vpcOptions(useExistingVpc!.openSearchDomainVpcConfig);\n }\n });\n }\n\n if (!useExistingVpc.lambdaFunctionsVpcConfig) {\n throw new Error(\n \"Cannot specify `useExistingVpc` parameter because the `lambdaFunctionsVpcConfig` parameter wasn't provided.\"\n );\n }\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.lambda.Function)) {\n const canUseVpc = resource.meta.canUseVpc !== false;\n if (canUseVpc) {\n resource.config.vpcConfig(useExistingVpc!.lambdaFunctionsVpcConfig);\n }\n }\n\n if (isResourceOfType(resource, aws.iam.Role)) {\n if (resource.meta.isLambdaFunctionRole) {\n addResource(aws.iam.RolePolicyAttachment, {\n name: `${resource.name}-vpc-access-execution-role`,\n config: {\n role: resource.output.name,\n policyArn: aws.iam.ManagedPolicy.AWSLambdaVPCAccessExecutionRole\n }\n });\n }\n }\n });\n\n return projectAppParams.pulumi?.(...args);\n }\n\n // 2. Now we deal with \"non-existing VPC\" setup.\n if (useVpcEndpoints) {\n const region = getAwsRegion(app);\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.ec2.Vpc)) {\n resource.config.enableDnsSupport(true);\n resource.config.enableDnsHostnames(true);\n }\n });\n\n const { vpc, subnets, routeTables } = resources.vpc!;\n addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-s3-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.s3`,\n routeTableIds: [routeTables.privateSubnets.output.id]\n }\n });\n\n addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-dynamodb-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.dynamodb`,\n routeTableIds: [routeTables.privateSubnets.output.id]\n }\n });\n\n addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-sqs-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.sqs`,\n vpcEndpointType: \"Interface\",\n privateDnsEnabled: true,\n securityGroupIds: [vpc.output.defaultSecurityGroupId],\n subnetIds: subnets.private.map(subNet => subNet.output.id)\n }\n });\n\n addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-events-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.events`,\n vpcEndpointType: \"Interface\",\n privateDnsEnabled: true,\n securityGroupIds: [vpc.output.defaultSecurityGroupId],\n subnetIds: subnets.private.map(subNet => subNet.output.id)\n }\n });\n }\n\n return projectAppParams.pulumi?.(...args);\n }\n });\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AAIA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,mCAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AAiBO,SAASO,mBAAmBA,CAACC,gBAA2C,GAAG,CAAC,CAAC,EAAE;EAClF,OAAO,IAAAC,wCAAuB,EAAC;IAC3B,GAAGD,gBAAgB;IACnB;IACAE,GAAG,EAAEA,CAAC;MAAEC;IAAS,CAAC,KAAK;MACnB,MAAMD,GAAG,GAAGC,QAAQ,CAACH,gBAAgB,CAACE,GAAG,CAAC;MAC1C,IAAI,CAACA,GAAG,EAAE;QACN;QACA;QACA,OAAOA,GAAG;MACd;;MAEA;MACA,MAAME,sBAAsB,GAAG,OAAOF,GAAG,KAAK,SAAS;MACvD,IAAIE,sBAAsB,IAAIF,GAAG,CAACG,cAAc,EAAE;QAC9C,OAAO,KAAK;MAChB;MAEA,OAAO,IAAI;IACf,CAAC;IACD,MAAMZ,MAAMA,CAAC,GAAGa,IAAI,EAAE;MAClB,MAAM,CAACC,GAAG,CAAC,GAAGD,IAAI;MAClB,MAAM;QAAEH;MAAS,CAAC,GAAGI,GAAG;MACxB,MAAML,GAAG,GAAGC,QAAQ,CAACH,gBAAgB,CAACE,GAAG,CAAC;MAC1C,MAAME,sBAAsB,GAAGF,GAAG,IAAI,OAAOA,GAAG,KAAK,SAAS;MAE9D,MAAMM,OAAO,GAAG,MAAMC,YAAO,CAACC,eAAe,CAAC,CAAC;MAE/C,IAAIF,OAAO,CAACG,gCAAgC,CAAC,CAAC,EAAE;QAC5C,IAAAC,sEA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EAAE;UAC7Bd,IAAI,EAAE,yBAAyB;UAC/Bf,MAAM,EAAE;YACJ8B,KAAK,EAAEpD,GAAG,CAACuC,MAAM,CAACc,EAAE;YACpBC,WAAW,EAAE/D,MAAM,CAACgE,WAAW,iBAAiBZ,MAAM,SAAS;YAC/De,eAAe,EAAE,WAAW;YAC5BC,iBAAiB,EAAE,IAAI;YACvBC,gBAAgB,EAAE,CAAC5D,GAAG,CAACuC,MAAM,CAACsB,sBAAsB,CAAC;YACrDC,SAAS,EAAEb,OAAO,CAACc,OAAO,CAACC,GAAG,CAACC,MAAM,IAAIA,MAAM,CAAC1B,MAAM,CAACc,EAAE;UAC7D;QACJ,CAAC,CAAC;MACN;MAEA,OAAOvD,gBAAgB,CAACP,MAAM,GAAG,GAAGa,IAAI,CAAC;IAC7C;EACJ,CAAC,CAAC;AACN","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["aws","_interopRequireWildcard","require","pulumi","_createCorePulumiApp","_pulumi2","_awsUtils","_configureS3BucketMalwareProtection","_wcp","createCorePulumiApp","projectAppParams","baseCreateCorePulumiApp","vpc","getParam","usingAdvancedVpcParams","useExistingVpc","args","app","license","License","fromEnvironment","canUseFileManagerThreatDetection","configureS3BucketMalwareProtection","resources","addResource","onResource","useVpcEndpoints","Error","elasticSearch","elasticSearchDomainVpcConfig","resource","isResourceOfType","elasticsearch","Domain","config","vpcOptions","openSearch","openSearchDomainVpcConfig","opensearch","lambdaFunctionsVpcConfig","lambda","Function","canUseVpc","meta","vpcConfig","iam","Role","isLambdaFunctionRole","RolePolicyAttachment","name","role","output","policyArn","ManagedPolicy","AWSLambdaVPCAccessExecutionRole","region","getAwsRegion","ec2","Vpc","enableDnsSupport","enableDnsHostnames","subnets","routeTables","VpcEndpoint","vpcId","id","serviceName","interpolate","routeTableIds","privateSubnets","vpcEndpointType","privateDnsEnabled","securityGroupIds","defaultSecurityGroupId","subnetIds","private","map","subNet"],"sources":["createCorePulumiApp.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport type { CreateCorePulumiAppParams as BaseCreateCorePulumiAppParams } from \"~/apps/core/createCorePulumiApp\";\nimport { createCorePulumiApp as baseCreateCorePulumiApp } from \"~/apps/core/createCorePulumiApp\";\nimport type { PulumiAppParam } from \"@webiny/pulumi\";\nimport { isResourceOfType } from \"@webiny/pulumi\";\nimport { getAwsRegion } from \"~/apps/awsUtils\";\nimport { configureS3BucketMalwareProtection } from \"~/enterprise/core/configureS3BucketMalwareProtection\";\nimport { License } from \"@webiny/wcp\";\n\nexport type CorePulumiApp = ReturnType<typeof createCorePulumiApp>;\n\nexport type CorePulumiAppAdvancedVpcParams = Partial<{\n useVpcEndpoints: boolean;\n useExistingVpc: {\n elasticSearchDomainVpcConfig?: aws.types.input.elasticsearch.DomainVpcOptions;\n openSearchDomainVpcConfig?: aws.types.input.opensearch.DomainVpcOptions;\n lambdaFunctionsVpcConfig: aws.types.input.lambda.FunctionVpcConfig;\n };\n}>;\n\nexport interface CreateCorePulumiAppParams extends Omit<BaseCreateCorePulumiAppParams, \"vpc\"> {\n vpc?: PulumiAppParam<boolean | CorePulumiAppAdvancedVpcParams>;\n}\n\nexport function createCorePulumiApp(projectAppParams: CreateCorePulumiAppParams = {}) {\n return baseCreateCorePulumiApp({\n ...projectAppParams,\n // If using existing VPC, we ensure `vpc` param is set to `false`.\n vpc: ({ getParam }) => {\n const vpc = getParam(projectAppParams.vpc);\n if (!vpc) {\n // This could be `false` or `undefined`. If `undefined`, down the line,\n // this means \"deploy into VPC if dealing with a production environment\".\n return vpc;\n }\n\n // If using an existing VPC, we ensure Webiny does not deploy its own VPC.\n const usingAdvancedVpcParams = typeof vpc !== \"boolean\";\n if (usingAdvancedVpcParams && vpc.useExistingVpc) {\n return false;\n }\n\n return true;\n },\n async pulumi(...args) {\n const [app] = args;\n const { getParam } = app;\n const vpc = getParam(projectAppParams.vpc);\n const usingAdvancedVpcParams = vpc && typeof vpc !== \"boolean\";\n\n const license = await License.fromEnvironment();\n\n if (license.canUseFileManagerThreatDetection()) {\n configureS3BucketMalwareProtection(app);\n }\n\n // Not using advanced VPC params? Then immediately exit.\n if (!usingAdvancedVpcParams) {\n return projectAppParams.pulumi?.(...args);\n }\n\n const [{ resources, addResource, onResource }] = args;\n const { useExistingVpc, useVpcEndpoints } = vpc;\n\n // 1. We first deal with \"existing VPC\" setup.\n if (useExistingVpc) {\n if (\"useVpcEndpoints\" in vpc) {\n throw new Error(\n \"Cannot specify `useVpcEndpoints` parameter when using an existing VPC. The VPC endpoints configurations should be already defined within the existing VPC.\"\n );\n }\n\n if (projectAppParams.elasticSearch) {\n if (!useExistingVpc.elasticSearchDomainVpcConfig) {\n throw new Error(\n \"Cannot specify `useExistingVpc` parameter because the `elasticSearchDomainVpcConfig` parameter wasn't provided.\"\n );\n }\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.elasticsearch.Domain)) {\n resource.config.vpcOptions(\n useExistingVpc!.elasticSearchDomainVpcConfig\n );\n }\n });\n }\n\n if (projectAppParams.openSearch) {\n if (!useExistingVpc.openSearchDomainVpcConfig) {\n throw new Error(\n \"Cannot specify `useExistingVpc` parameter because the `openSearchDomainVpcConfig` parameter wasn't provided.\"\n );\n }\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.opensearch.Domain)) {\n resource.config.vpcOptions(useExistingVpc!.openSearchDomainVpcConfig);\n }\n });\n }\n\n if (!useExistingVpc.lambdaFunctionsVpcConfig) {\n throw new Error(\n \"Cannot specify `useExistingVpc` parameter because the `lambdaFunctionsVpcConfig` parameter wasn't provided.\"\n );\n }\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.lambda.Function)) {\n const canUseVpc = resource.meta.canUseVpc !== false;\n if (canUseVpc) {\n resource.config.vpcConfig(useExistingVpc!.lambdaFunctionsVpcConfig);\n }\n }\n\n if (isResourceOfType(resource, aws.iam.Role)) {\n if (resource.meta.isLambdaFunctionRole) {\n addResource(aws.iam.RolePolicyAttachment, {\n name: `${resource.name}-vpc-access-execution-role`,\n config: {\n role: resource.output.name,\n policyArn: aws.iam.ManagedPolicy.AWSLambdaVPCAccessExecutionRole\n }\n });\n }\n }\n });\n\n return projectAppParams.pulumi?.(...args);\n }\n\n // 2. Now we deal with \"non-existing VPC\" setup.\n if (useVpcEndpoints) {\n const region = getAwsRegion(app);\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.ec2.Vpc)) {\n resource.config.enableDnsSupport(true);\n resource.config.enableDnsHostnames(true);\n }\n });\n\n const { vpc, subnets, routeTables } = resources.vpc!;\n addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-s3-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.s3`,\n routeTableIds: [routeTables.privateSubnets.output.id]\n }\n });\n\n addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-dynamodb-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.dynamodb`,\n routeTableIds: [routeTables.privateSubnets.output.id]\n }\n });\n\n addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-sqs-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.sqs`,\n vpcEndpointType: \"Interface\",\n privateDnsEnabled: true,\n securityGroupIds: [vpc.output.defaultSecurityGroupId],\n subnetIds: subnets.private.map(subNet => subNet.output.id)\n }\n });\n\n addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-events-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.events`,\n vpcEndpointType: \"Interface\",\n privateDnsEnabled: true,\n securityGroupIds: [vpc.output.defaultSecurityGroupId],\n subnetIds: subnets.private.map(subNet => subNet.output.id)\n }\n });\n }\n\n return projectAppParams.pulumi?.(...args);\n }\n });\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,GAAA,GAAA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,MAAM,CAACgE,WAAW,iBAAiBZ,MAAM,SAAS;YAC/De,eAAe,EAAE,WAAW;YAC5BC,iBAAiB,EAAE,IAAI;YACvBC,gBAAgB,EAAE,CAAC5D,GAAG,CAACuC,MAAM,CAACsB,sBAAsB,CAAC;YACrDC,SAAS,EAAEb,OAAO,CAACc,OAAO,CAACC,GAAG,CAACC,MAAM,IAAIA,MAAM,CAAC1B,MAAM,CAACc,EAAE;UAC7D;QACJ,CAAC,CAAC;MACN;MAEA,OAAOvD,gBAAgB,CAACP,MAAM,GAAG,GAAGa,IAAI,CAAC;IAC7C;EACJ,CAAC,CAAC;AACN","ignoreList":[]}
|
|
@@ -13,14 +13,19 @@ export type SyncSystemPulumiAppAdvancedVpcParams = Partial<{
|
|
|
13
13
|
export interface CreateSyncSystemPulumiAppParams extends Omit<BaseCreateSyncSystemPulumiAppParams, "vpc"> {
|
|
14
14
|
vpc?: PulumiAppParam<boolean | SyncSystemPulumiAppAdvancedVpcParams>;
|
|
15
15
|
}
|
|
16
|
-
export declare function createSyncSystemPulumiApp(projectAppParams
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
export declare function createSyncSystemPulumiApp(projectAppParams: CreateSyncSystemPulumiAppParams): import("@webiny/pulumi").PulumiApp<{
|
|
17
|
+
sqs: import("@pulumi/pulumi").Output<import("@pulumi/aws/sqs/queue").Queue>;
|
|
18
|
+
dynamoDb: import("@pulumi/pulumi").Output<import("@pulumi/aws/dynamodb/table").Table>;
|
|
19
|
+
eventBus: import("@pulumi/pulumi").Output<import("@pulumi/aws/cloudwatch/eventBus").EventBus>;
|
|
20
|
+
eventBusRule: import("@pulumi/pulumi").Output<import("@pulumi/aws/cloudwatch/eventRule").EventRule>;
|
|
21
|
+
eventBusTarget: import("@pulumi/pulumi").Output<import("@pulumi/aws/cloudwatch/eventTarget").EventTarget>;
|
|
22
|
+
eventBusPolicy: import("@pulumi/pulumi").Output<import("@pulumi/aws/sqs/queuePolicy").QueuePolicy>;
|
|
23
|
+
workerLambda: import("@pulumi/pulumi").Output<import("@pulumi/aws/lambda/function").Function>;
|
|
24
|
+
workerLambdaRole: import("@pulumi/pulumi").Output<import("@pulumi/aws/iam/role").Role>;
|
|
25
|
+
resolverLambda: import("@pulumi/pulumi").Output<import("@pulumi/aws/lambda/function").Function>;
|
|
26
|
+
resolverLambdaRole: import("@pulumi/pulumi").Output<import("@pulumi/aws/iam/role").Role>;
|
|
27
|
+
resolverLambdaPolicy: import("@pulumi/pulumi").Output<import("@pulumi/aws/iam/policy").Policy>;
|
|
28
|
+
resolverLambdaEventSourceMapping: import("@pulumi/pulumi").Output<import("@pulumi/aws/lambda/eventSourceMapping").EventSourceMapping>;
|
|
24
29
|
primary: {};
|
|
25
30
|
secondary: {};
|
|
26
31
|
}>;
|
|
@@ -8,7 +8,7 @@ exports.createSyncSystemPulumiApp = createSyncSystemPulumiApp;
|
|
|
8
8
|
var aws = _interopRequireWildcard(require("@pulumi/aws"));
|
|
9
9
|
var _createSyncSystemPulumiApp = require("../apps/syncSystem/createSyncSystemPulumiApp");
|
|
10
10
|
var _pulumi = require("@webiny/pulumi");
|
|
11
|
-
function createSyncSystemPulumiApp(projectAppParams
|
|
11
|
+
function createSyncSystemPulumiApp(projectAppParams) {
|
|
12
12
|
return (0, _createSyncSystemPulumiApp.createSyncSystemPulumiApp)({
|
|
13
13
|
...projectAppParams,
|
|
14
14
|
// If using existing VPC, we ensure `vpc` param is set to `false`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["aws","_interopRequireWildcard","require","_createSyncSystemPulumiApp","_pulumi","createSyncSystemPulumiApp","projectAppParams","baseCreateSyncSystemPulumiApp","vpc","getParam","usingAdvancedVpcParams","useExistingVpc","Boolean","pulumi","args","onResource","addResource","lambdaFunctionsVpcConfig","Error","resource","isResourceOfType","lambda","Function","canUseVpc","meta","config","vpcConfig","iam","Role","isLambdaFunctionRole","RolePolicyAttachment","name","role","output","policyArn","ManagedPolicy","AWSLambdaVPCAccessExecutionRole"],"sources":["createSyncSystemPulumiApp.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport type { CreateSyncSystemPulumiAppParams as BaseCreateSyncSystemPulumiAppParams } from \"~/apps/syncSystem/createSyncSystemPulumiApp\";\nimport { createSyncSystemPulumiApp as baseCreateSyncSystemPulumiApp } from \"~/apps/syncSystem/createSyncSystemPulumiApp\";\nimport type { PulumiAppParam } from \"@webiny/pulumi\";\nimport { isResourceOfType } from \"@webiny/pulumi\";\n\nexport type SyncSystemPulumiApp = ReturnType<typeof createSyncSystemPulumiApp>;\n\nexport type SyncSystemPulumiAppAdvancedVpcParams = Partial<{\n useVpcEndpoints: boolean;\n useExistingVpc: {\n elasticSearchDomainVpcConfig?: aws.types.input.elasticsearch.DomainVpcOptions;\n openSearchDomainVpcConfig?: aws.types.input.opensearch.DomainVpcOptions;\n lambdaFunctionsVpcConfig: aws.types.input.lambda.FunctionVpcConfig;\n };\n}>;\n\nexport interface CreateSyncSystemPulumiAppParams\n extends Omit<BaseCreateSyncSystemPulumiAppParams, \"vpc\"> {\n vpc?: PulumiAppParam<boolean | SyncSystemPulumiAppAdvancedVpcParams>;\n}\n\nexport function createSyncSystemPulumiApp(projectAppParams: CreateSyncSystemPulumiAppParams
|
|
1
|
+
{"version":3,"names":["aws","_interopRequireWildcard","require","_createSyncSystemPulumiApp","_pulumi","createSyncSystemPulumiApp","projectAppParams","baseCreateSyncSystemPulumiApp","vpc","getParam","usingAdvancedVpcParams","useExistingVpc","Boolean","pulumi","args","onResource","addResource","lambdaFunctionsVpcConfig","Error","resource","isResourceOfType","lambda","Function","canUseVpc","meta","config","vpcConfig","iam","Role","isLambdaFunctionRole","RolePolicyAttachment","name","role","output","policyArn","ManagedPolicy","AWSLambdaVPCAccessExecutionRole"],"sources":["createSyncSystemPulumiApp.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport type { CreateSyncSystemPulumiAppParams as BaseCreateSyncSystemPulumiAppParams } from \"~/apps/syncSystem/createSyncSystemPulumiApp\";\nimport { createSyncSystemPulumiApp as baseCreateSyncSystemPulumiApp } from \"~/apps/syncSystem/createSyncSystemPulumiApp\";\nimport type { PulumiAppParam } from \"@webiny/pulumi\";\nimport { isResourceOfType } from \"@webiny/pulumi\";\n\nexport type SyncSystemPulumiApp = ReturnType<typeof createSyncSystemPulumiApp>;\n\nexport type SyncSystemPulumiAppAdvancedVpcParams = Partial<{\n useVpcEndpoints: boolean;\n useExistingVpc: {\n elasticSearchDomainVpcConfig?: aws.types.input.elasticsearch.DomainVpcOptions;\n openSearchDomainVpcConfig?: aws.types.input.opensearch.DomainVpcOptions;\n lambdaFunctionsVpcConfig: aws.types.input.lambda.FunctionVpcConfig;\n };\n}>;\n\nexport interface CreateSyncSystemPulumiAppParams\n extends Omit<BaseCreateSyncSystemPulumiAppParams, \"vpc\"> {\n vpc?: PulumiAppParam<boolean | SyncSystemPulumiAppAdvancedVpcParams>;\n}\n\nexport function createSyncSystemPulumiApp(projectAppParams: CreateSyncSystemPulumiAppParams) {\n return baseCreateSyncSystemPulumiApp({\n ...projectAppParams,\n // If using existing VPC, we ensure `vpc` param is set to `false`.\n vpc: ({ getParam }) => {\n const vpc = getParam(projectAppParams.vpc);\n const usingAdvancedVpcParams = vpc && typeof vpc !== \"boolean\";\n return usingAdvancedVpcParams && vpc.useExistingVpc ? false : Boolean(vpc);\n },\n pulumi(...args) {\n const [{ getParam }] = args;\n const vpc = getParam(projectAppParams.vpc);\n const usingAdvancedVpcParams = vpc && typeof vpc !== \"boolean\";\n\n // Not using advanced VPC params? Then immediately exit.\n if (!usingAdvancedVpcParams) {\n return projectAppParams.pulumi?.(...args);\n }\n\n const [{ onResource, addResource }] = args;\n const { useExistingVpc } = vpc;\n\n // 1. We first deal with \"existing VPC\" setup.\n if (useExistingVpc) {\n if (!useExistingVpc.lambdaFunctionsVpcConfig) {\n throw new Error(\n \"Cannot specify `useExistingVpc` parameter because the `lambdaFunctionsVpcConfig` parameter wasn't provided.\"\n );\n }\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.lambda.Function)) {\n const canUseVpc = resource.meta.canUseVpc !== false;\n if (canUseVpc) {\n resource.config.vpcConfig(useExistingVpc!.lambdaFunctionsVpcConfig);\n }\n }\n\n if (isResourceOfType(resource, aws.iam.Role)) {\n if (resource.meta.isLambdaFunctionRole) {\n addResource(aws.iam.RolePolicyAttachment, {\n name: `${resource.name}-vpc-access-execution-role`,\n config: {\n role: resource.output.name,\n policyArn: aws.iam.ManagedPolicy.AWSLambdaVPCAccessExecutionRole\n }\n });\n }\n }\n });\n }\n\n return projectAppParams.pulumi?.(...args);\n }\n });\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,0BAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAkBO,SAASG,yBAAyBA,CAACC,gBAAiD,EAAE;EACzF,OAAO,IAAAC,oDAA6B,EAAC;IACjC,GAAGD,gBAAgB;IACnB;IACAE,GAAG,EAAEA,CAAC;MAAEC;IAAS,CAAC,KAAK;MACnB,MAAMD,GAAG,GAAGC,QAAQ,CAACH,gBAAgB,CAACE,GAAG,CAAC;MAC1C,MAAME,sBAAsB,GAAGF,GAAG,IAAI,OAAOA,GAAG,KAAK,SAAS;MAC9D,OAAOE,sBAAsB,IAAIF,GAAG,CAACG,cAAc,GAAG,KAAK,GAAGC,OAAO,CAACJ,GAAG,CAAC;IAC9E,CAAC;IACDK,MAAMA,CAAC,GAAGC,IAAI,EAAE;MACZ,MAAM,CAAC;QAAEL;MAAS,CAAC,CAAC,GAAGK,IAAI;MAC3B,MAAMN,GAAG,GAAGC,QAAQ,CAACH,gBAAgB,CAACE,GAAG,CAAC;MAC1C,MAAME,sBAAsB,GAAGF,GAAG,IAAI,OAAOA,GAAG,KAAK,SAAS;;MAE9D;MACA,IAAI,CAAC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
import * as aws from "@pulumi/aws";
|
|
2
|
-
import { CreateWebsitePulumiAppParams as BaseCreateWebsitePulumiAppParams } from "../apps/website/createWebsitePulumiApp";
|
|
3
|
-
import { PulumiAppParam } from "@webiny/pulumi";
|
|
2
|
+
import type { CreateWebsitePulumiAppParams as BaseCreateWebsitePulumiAppParams } from "../apps/website/createWebsitePulumiApp";
|
|
3
|
+
import type { PulumiAppParam } from "@webiny/pulumi";
|
|
4
4
|
export type WebsitePulumiApp = ReturnType<typeof createWebsitePulumiApp>;
|
|
5
5
|
export type WebsitePulumiAppAdvancedVpcParams = Partial<{
|
|
6
6
|
useExistingVpc: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["aws","_interopRequireWildcard","require","_createWebsitePulumiApp","_pulumi","createWebsitePulumiApp","projectAppParams","baseCreateWebsitePulumiApp","vpc","getParam","usingAdvancedVpcParams","useExistingVpc","pulumi","args","onResource","addResource","lambdaFunctionsVpcConfig","Error","resource","isResourceOfType","lambda","Function","canUseVpc","meta","config","vpcConfig","iam","Role","isLambdaFunctionRole","RolePolicyAttachment","name","role","output","policyArn","ManagedPolicy","AWSLambdaVPCAccessExecutionRole"],"sources":["createWebsitePulumiApp.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport {\
|
|
1
|
+
{"version":3,"names":["aws","_interopRequireWildcard","require","_createWebsitePulumiApp","_pulumi","createWebsitePulumiApp","projectAppParams","baseCreateWebsitePulumiApp","vpc","getParam","usingAdvancedVpcParams","useExistingVpc","pulumi","args","onResource","addResource","lambdaFunctionsVpcConfig","Error","resource","isResourceOfType","lambda","Function","canUseVpc","meta","config","vpcConfig","iam","Role","isLambdaFunctionRole","RolePolicyAttachment","name","role","output","policyArn","ManagedPolicy","AWSLambdaVPCAccessExecutionRole"],"sources":["createWebsitePulumiApp.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport type { CreateWebsitePulumiAppParams as BaseCreateWebsitePulumiAppParams } from \"~/apps/website/createWebsitePulumiApp\";\nimport { createWebsitePulumiApp as baseCreateWebsitePulumiApp } from \"~/apps/website/createWebsitePulumiApp\";\nimport type { PulumiAppParam } from \"@webiny/pulumi\";\nimport { isResourceOfType } from \"@webiny/pulumi\";\n\nexport type WebsitePulumiApp = ReturnType<typeof createWebsitePulumiApp>;\n\nexport type WebsitePulumiAppAdvancedVpcParams = Partial<{\n useExistingVpc: {\n lambdaFunctionsVpcConfig: aws.types.input.lambda.FunctionVpcConfig;\n };\n}>;\n\nexport interface CreateWebsitePulumiAppParams\n extends Omit<BaseCreateWebsitePulumiAppParams, \"vpc\"> {\n vpc?: PulumiAppParam<boolean | WebsitePulumiAppAdvancedVpcParams>;\n}\n\nexport function createWebsitePulumiApp(projectAppParams: CreateWebsitePulumiAppParams = {}) {\n return baseCreateWebsitePulumiApp({\n ...projectAppParams,\n // If using existing VPC, we ensure `vpc` param is set to `false`.\n vpc: ({ getParam }) => {\n const vpc = getParam(projectAppParams.vpc);\n if (!vpc) {\n // This could be `false` or `undefined`. If `undefined`, down the line,\n // this means \"deploy into VPC if dealing with a production environment\".\n return vpc;\n }\n\n // If using an existing VPC, we ensure Webiny does not deploy its own VPC.\n const usingAdvancedVpcParams = typeof vpc !== \"boolean\";\n if (usingAdvancedVpcParams && vpc.useExistingVpc) {\n return false;\n }\n\n return true;\n },\n pulumi(...args) {\n const [{ getParam }] = args;\n const vpc = getParam(projectAppParams.vpc);\n const usingAdvancedVpcParams = vpc && typeof vpc !== \"boolean\";\n\n // Not using advanced VPC params? Then immediately exit.\n if (!usingAdvancedVpcParams) {\n return projectAppParams.pulumi?.(...args);\n }\n\n const [{ onResource, addResource }] = args;\n const { useExistingVpc } = vpc;\n\n if (useExistingVpc) {\n if (!useExistingVpc.lambdaFunctionsVpcConfig) {\n throw new Error(\n \"Cannot specify `useExistingVpc` parameter because the `lambdaFunctionsVpcConfig` parameter wasn't provided.\"\n );\n }\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.lambda.Function)) {\n const canUseVpc = resource.meta.canUseVpc !== false;\n if (canUseVpc) {\n resource.config.vpcConfig(useExistingVpc!.lambdaFunctionsVpcConfig);\n }\n }\n\n if (isResourceOfType(resource, aws.iam.Role)) {\n if (resource.meta.isLambdaFunctionRole) {\n addResource(aws.iam.RolePolicyAttachment, {\n name: `${resource.name}-vpc-access-execution-role`,\n config: {\n role: resource.output.name,\n policyArn: aws.iam.ManagedPolicy.AWSLambdaVPCAccessExecutionRole\n }\n });\n }\n }\n });\n }\n\n return projectAppParams.pulumi?.(...args);\n }\n });\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,uBAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAeO,SAASG,sBAAsBA,CAACC,gBAA8C,GAAG,CAAC,CAAC,EAAE;EACxF,OAAO,IAAAC,8CAA0B,EAAC;IAC9B,GAAGD,gBAAgB;IACnB;IACAE,GAAG,EAAEA,CAAC;MAAEC;IAAS,CAAC,KAAK;MACnB,MAAMD,GAAG,GAAGC,QAAQ,CAACH,gBAAgB,CAACE,GAAG,CAAC;MAC1C,IAAI,CAACA,GAAG,EAAE;QACN;QACA;QACA,OAAOA,GAAG;MACd;;MAEA;MACA,MAAME,sBAAsB,GAAG,OAAOF,GAAG,KAAK,SAAS;MACvD,IAAIE,sBAAsB,IAAIF,GAAG,CAACG,cAAc,EAAE;QAC9C,OAAO,KAAK;MAChB;MAEA,OAAO,IAAI;IACf,CAAC;IACDC,MAAMA,CAAC,GAAGC,IAAI,EAAE;MACZ,MAAM,CAAC;QAAEJ;MAAS,CAAC,CAAC,GAAGI,IAAI;MAC3B,MAAML,GAAG,GAAGC,QAAQ,CAACH,gBAAgB,CAACE,GAAG,CAAC;MAC1C,MAAME,sBAAsB,GAAGF,GAAG,IAAI,OAAOA,GAAG,KAAK,SAAS;;MAE9D;MACA,IAAI,CAACE,sBAAsB,EAAE;QACzB,OAAOJ,gBAAgB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