@pwrdrvr/microapps-cdk 0.4.0-alpha.2 → 0.4.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/.jsii +113 -103
  2. package/API.md +39 -40
  3. package/README.md +59 -94
  4. package/changelog.md +1 -1
  5. package/lib/MicroApps.d.ts +0 -1
  6. package/lib/MicroApps.js +5 -5
  7. package/lib/MicroAppsAPIGwy.d.ts +0 -1
  8. package/lib/MicroAppsAPIGwy.js +1 -1
  9. package/lib/MicroAppsCF.d.ts +15 -33
  10. package/lib/MicroAppsCF.js +41 -51
  11. package/lib/MicroAppsChildDeployer.d.ts +0 -1
  12. package/lib/MicroAppsChildDeployer.js +1 -1
  13. package/lib/MicroAppsEdgeToOrigin.d.ts +0 -1
  14. package/lib/MicroAppsEdgeToOrigin.js +4 -6
  15. package/lib/MicroAppsS3.d.ts +15 -4
  16. package/lib/MicroAppsS3.js +18 -5
  17. package/lib/MicroAppsSvcs.d.ts +0 -1
  18. package/lib/MicroAppsSvcs.js +3 -4
  19. package/lib/MicroAppsTable.d.ts +0 -1
  20. package/lib/MicroAppsTable.js +3 -3
  21. package/lib/index.d.ts +0 -1
  22. package/lib/microapps-deployer/index.js +64 -65
  23. package/lib/microapps-deployer/index.js.map +4 -4
  24. package/lib/microapps-edge-to-origin/index.js +50 -57
  25. package/lib/microapps-edge-to-origin/index.js.map +4 -4
  26. package/lib/microapps-router/index.js +54 -55
  27. package/lib/microapps-router/index.js.map +4 -4
  28. package/lib/utils/ReverseDomain.d.ts +0 -1
  29. package/package.json +1 -1
  30. package/releasetag.txt +1 -1
  31. package/version.txt +1 -1
  32. package/lib/MicroApps.d.ts.map +0 -1
  33. package/lib/MicroAppsAPIGwy.d.ts.map +0 -1
  34. package/lib/MicroAppsCF.d.ts.map +0 -1
  35. package/lib/MicroAppsChildDeployer.d.ts.map +0 -1
  36. package/lib/MicroAppsEdgeToOrigin.d.ts.map +0 -1
  37. package/lib/MicroAppsS3.d.ts.map +0 -1
  38. package/lib/MicroAppsSvcs.d.ts.map +0 -1
  39. package/lib/MicroAppsTable.d.ts.map +0 -1
  40. package/lib/index.d.ts.map +0 -1
  41. package/lib/utils/ReverseDomain.d.ts.map +0 -1
package/.jsii CHANGED
@@ -3083,7 +3083,7 @@
3083
3083
  "stability": "experimental"
3084
3084
  },
3085
3085
  "homepage": "https://github.com/pwrdrvr/microapps-core",
3086
- "jsiiVersion": "1.59.0 (build eb02c92)",
3086
+ "jsiiVersion": "1.75.0 (build 63bb957)",
3087
3087
  "keywords": [
3088
3088
  "awscdk",
3089
3089
  "cdk",
@@ -3100,7 +3100,7 @@
3100
3100
  },
3101
3101
  "name": "@pwrdrvr/microapps-cdk",
3102
3102
  "readme": {
3103
- "markdown": "[![CI](https://github.com/pwrdrvr/microapps-core/actions/workflows/ci.yml/badge.svg)](https://github.com/pwrdrvr/microapps-core/actions/workflows/ci.yml) [![Merge to Main Build](https://github.com/pwrdrvr/microapps-core/actions/workflows/main-build.yml/badge.svg)](https://github.com/pwrdrvr/microapps-core/actions/workflows/main-build.yml) [![Release Packages](https://github.com/pwrdrvr/microapps-core/actions/workflows/release.yml/badge.svg)](https://github.com/pwrdrvr/microapps-core/actions/workflows/release.yml)\n\n# Overview\n\nThe MicroApps project enables rapidly deploying many web apps to AWS on a single shared host name, fronted by a CloudFront Distribution, serving static assets from an S3 Bucket, and routing application requests via API Gateway. MicroApps is delivered as a CDK Construct for deployment, although alternative deployment methods can be used if desired and implemented.\n\nMicroApps allows many versions of an application to be deployed either as ephemeral deploys (e.g. for pull request builds) or as semi-permanent deploys. The `microapps-router` Lambda function handled routing requests to apps to the current version targeted for a particular application start request using rules as complex as one is interested in implementing (e.g. A/B testing integration, canary releases, per-user rules for logged in users, per-group, per-deparment, and default rules).\n\n2023-01-01 NOTE: The next paragraph is dated as the `iframe` is no longer required for frameworks that write absolute URLs for their static resources and API requests.\n\nUsers start applications via a URL such as `[/{prefix}]/{appname}/`, which hits the `microapps-router` that looks up the version of the application to be run, then renders a transparent `iframe` with a link to that version. The URL seen by the user in the browser (and available for bookmarking) has no version in it, so subsequent launches (e.g. the next day or just in another tab) will lookup the version again. All relative URL API requests (e.g. `some/api/path`) will go to the corresponding API version that matches the version of the loaded static files, eliminating issues of incompatibility between static files and API deployments.\n\nFor development / testing purposes only, each version of an applicaton can be accessed directly via a URL of the pattern `[/{prefix}]/{appname}/{semver}/`. These \"versioned\" URLs are not intended to be advertised to end users as they would cause a user to be stuck on a particular version of the app if the URL was bookmarked. Note that the system does not limit access to particular versions of an application, as of 2022-01-26, but that can be added as a feature.\n\n# Table of Contents <!-- omit in toc -->\n\n- [Overview](#overview)\n- [Request Dispatch Model for Multi-Account Deployments](#request-dispatch-model-for-multi-account-deployments)\n- [Video Preview of the Deploying CDK Construct](#video-preview-of-the-deploying-cdk-construct)\n- [Installation / CDK Constructs](#installation--cdk-constructs)\n- [Tutorial - Bootstrapping a Deploy](#tutorial---bootstrapping-a-deploy)\n- [Why MicroApps](#why-microapps)\n- [Limitations / Future Development](#limitations--future-development)\n- [Related Projects / Components](#related-projects--components)\n- [Architecure Diagram](#architecure-diagram)\n- [Project Layout](#project-layout)\n- [Creating a MicroApp Using Zip Lambda Functions](#creating-a-microapp-using-zip-lambda-functions)\n- [Creating a MicroApp Using Docker Lambda Functions](#creating-a-microapp-using-docker-lambda-functions)\n - [Next.js Apps](#nextjs-apps)\n - [Modify package.json](#modify-packagejson)\n - [Install Dependencies](#install-dependencies)\n - [Dockerfile](#dockerfile)\n - [next.config.js](#nextconfigjs)\n - [deploy.json](#deployjson)\n - [serverless.yaml](#serverlessyaml)\n- [Troubleshooting](#troubleshooting)\n - [CloudFront Requests to API Gateway are Rejected with 403 Forbidden](#cloudfront-requests-to-api-gateway-are-rejected-with-403-forbidden)\n - [SignatureV4 Headers](#signaturev4-headers)\n\n# Request Dispatch Model for Multi-Account Deployments\n\nNote: requests can also be dispatched into the same account, but this model is more likely to be used by organizations with many AWS accounts.\n\n![211132720-604510fa-de44-4ac6-a79b-c28c829d2490](https://user-images.githubusercontent.com/5617868/218237120-65b3ae44-31ba-4b6d-8722-4d3fb7da5577.png)\n\n# Video Preview of the Deploying CDK Construct\n\n![Video Preview of Deploying](https://raw.githubusercontent.com/pwrdrvr/microapps-core/main/assets/videos/microapps-core-demo-deploy.gif)\n\n# Installation / CDK Constructs\n\n- `npm i --save-dev @pwrdrvr/microapps-cdk`\n- Add `MicroApps` construct to your stack\n- The `MicroApps` construct does a \"turn-key\" deployment complete with the Release app\n- [Construct Hub](https://constructs.dev/packages/@pwrdrvr/microapps-cdk/)\n - CDK API docs\n - Python, DotNet, Java, JS/TS installation instructions\n\n# Tutorial - Bootstrapping a Deploy\n\n- `git clone https://github.com/pwrdrvr/microapps-core.git`\n - Note: the repo is only being for the example CDK Stack, it is not necessary to clone the repo when used in a custom CDK Stack\n- `cd microapps-core`\n- `npm i -g aws-cdk`\n - Install AWS CDK v2 CLI\n- `asp [my-sso-profile-name]`\n - Using the `aws` plugin from `oh-my-zsh` for AWS SSO\n - Of course, there are other methods of setting env vars\n- `aws sso login`\n - Establish an AWS SSO session\n- `cdk-sso-sync`\n - Using `npm i -g cdk-sso-sync`\n - Sets AWS SSO credentials in a way that CDK can use them\n - Not necessary if not using AWS SSO\n- `export AWS_REGION=us-east-2`\n - Region needs to be set for the Lambda invoke - This can be done other ways in `~/.aws/config` as well\n- `./deploy.sh`\n - Deploys the CDK Stack\n - Essentially runs two commands along with extraction of outputs:\n - `npx cdk deploy --context @pwrdrvr/microapps:deployReleaseApp=true microapps-basic`\n - `npx microapps-publish publish -a release -n ${RELEASE_APP_PACKAGE_VERSION} -d ${DEPLOYER_LAMBDA_NAME} -l ${RELEASE_APP_LAMBDA_NAME} -s node_modules/@pwrdrvr/microapps-app-release-cdk/lib/.static_files/release/${RELEASE_APP_PACKAGE_VERSION}/ --overwrite --noCache`\n - URL will be printed as last output\n\n# Why MicroApps\n\nMicroApps are like micro services, but for Web UIs. A MicroApp allows a single functional site to be developed by many independent teams within an organization. Teams must coordinate deployments and agree upon one implementation technology and framework when building a monolithic, or even a monorepo, web application.\n\nTeams using MicroApps can deploy independently of each other with coordination being required only at points of intentional integration (e.g. adding a feature to pass context from one MicroApp to another or coordination of a major feature release to users) and sharing UI styles, if desired (it is possible to build styles that look the same across many different UI frameworks).\n\nMicroApps also allow each team to use a UI framework and backend language that is most appropriate for their solving their business problem. Not every app has to use React or Next.js or even Node on the backend, but instead they can use whatever framework they want and Java, Go, C#, Python, etc. for UI API calls.\n\nFor internal sites, or logged-in-customer sites, different tools or products can be hosted in entirely independent MicroApps. A menuing system / toolbar application can be created as a MicroApp and that menu app can open the apps in the system within a transparent iframe. For externally facing sites, such as for an e-commerce site, it is possible to have a MicroApp serving `/product/...`, another serving `/search/...`, another serving `/`, etc.\n\n# Limitations / Future Development\n\n- `iframes`\n - Yeah, yeah: `iframes` are not framesets and most of the hate about iframes is probably better directed at framesets\n - The iframe serves a purpose but it stinks that it is there, primarily because it will cause issues with search bot indexing (SEO)\n - There are other options available to implement that have their own drabacks:\n - Using the `microapps-router` to proxy the \"app start\" request to a particular version of an app that then renders all of it's API resource requests to versioned URLs\n - Works only with frameworks that support hashing filenams for each deploy to unique names\n - This page would need to be marked as non-cachable\n - This may work well with Next.js which wants to know the explicit path that it will be running at (it writes that path into all resource and API requests)\n - Possible issue: the app would need to work ok being displayed at `[/{prefix}]/{appname}` when it may think that it's being displayed at `[/{prefix}]/{appname}/{semver}`\n - Disadvantage: requires some level of UI framework features (e.g. writing the absolute resource paths) to work correctly - may not work as easily for all UI frameworks\n - HTML5 added features to allow setting the relative path of all subsequent requests to be different than that displayed in the address bar\n - Gotta see if this works in modern browsers\n - Option to ditch the multiple-versions feature\n - Works only with frameworks that support hashing filenams for each deploy to unique names\n - Allows usage of the deploy and routing tooling without advantages and disadvantages of multiple-versions support\n- AWS Only\n - For the time being this has only been implemented for AWS technologies and APIs\n - It is possible that Azure and GCP have sufficient support to enable porting the framework\n - CDK would have to be replaced as well (unless it's made available for Azure and GCP in the near future)\n- `microapps-publish` only supports Lambda function apps\n - There is no technical reason for the apps to only run as Lambda functions\n - Web apps could just as easily run on EC2, Kubernetes, EKS, ECS, etc\n - Anything that API Gateway can route to can work for serving a MicroApp\n - The publish tool needs to provide additional options for setting up the API Gateway route to the app\n- Authentication\n - Authentication requires rolling your own API Gateway and CloudFront deployment at the moment\n - The \"turn key\" CDK Construct should provide options to show an example of how authentication can be integrated\n- Release Rules\n - Currently only a Default rule is supported\n - Need to evaluate if a generic implementation can be made, possibly allowing plugins or webhooks to support arbitrary rules\n - If not possible to make it perfectly generic, consider providing a more complete reference implementation of examples\n\n# Related Projects / Components\n\n- Release App\n - The Release app is an initial, rudimentary, release control console for setting the default version of an application\n - Built with Next.js\n - [pwrdrvr/microapps-app-release](https://github.com/pwrdrvr/microapps-app-release)\n- Next.js Demo App\n - The Next.js Tutorial application deployed as a MicroApp\n - [pwrdrvr/serverless-nextjs-demo](https://github.com/pwrdrvr/serverless-nextjs-demo)\n- Serverless Next.js Router\n - [pwrdrvr/serverless-nextjs-router](https://github.com/pwrdrvr/serverless-nextjs-router)\n - Complementary to [@sls-next/serverless-component](https://github.com/serverless-nextjs/serverless-next.js)\n - Allows Next.js apps to run as Lambda @ Origin for speed and cost improvements vs Lambda@Edge\n - Essentially the router translates CloudFront Lambda events to API Gateway Lambda events and vice versa for responses\n - The `serverless-nextjs` project allows Next.js apps to run as Lambda functions without Express, but there was a design change to make the Lambda functions run at Edge (note: need to recheck if this changed after early 2021)\n - Lambda@Edge is _at least_ 3x more expensive than Lambda at the origin:\n - In US East 1, the price per GB-Second is $0.00005001 for Lambda@Edge vs $0.0000166667 for Lambda at the origin\n - Additionally, any DB or services calls from Lambda@Edge back to the origin will pay that 3x higher per GB-Second cost for any time spent waiting to send the request and get a response. Example:\n - Lambda@Edge\n - 0.250s Round Trip Time (RTT) for EU-zone edge request to hit US-East 1 Origin\n - 0.200s DB lookup time\n - 0.050s CPU usage to process the DB response\n - 0.500s total billed time @ $0.00005001 @ 128 MB\n - $0.000003125625 total charge\n - Lambda at Origin\n - RTT does not apply (it's effectively 1-2 ms to hit a DB in the same region)\n - 0.200s DB lookup time\n - 0.050s CPU usage to process the DB response\n - 0.250s total billed time @ $0.0000166667 @ 128 MB\n - Half the billed time of running on Lambda@Edge\n - 1/6th the cost of running on Lambda@Edge:\n - $0.000000520834375 total charge (assuming no CPU time to process the response)\n - $0.000003125625 / $0.000000520834375 = 6x more expensive in Lambda@Edge\n\n# Architecure Diagram\n\n![Architecure Diagram](https://raw.githubusercontent.com/pwrdrvr/microapps-core/main/assets/images/architecture-diagram.png)\n\n# Project Layout\n\n- [packages/cdk](https://github.com/pwrdrvr/microapps-core/tree/main/packages/cdk)\n - Example CDK Stack\n - Deploys MicroApps CDK stack for the GitHub Workflows\n - Can be used as an example of how to use the MicroApps CDK Construct\n- [packages/demo-app](https://github.com/pwrdrvr/microapps-core/tree/main/packages/demo-app)\n - Example app with static resources and a Lambda function\n - Does not use any Web UI framework at all\n- [packages/microapps-cdk](https://github.com/pwrdrvr/microapps-core/tree/main/packages/microapps-cdk)\n - MicroApps\n - \"Turn key\" CDK Construct that creates all assets needed for a working MicroApps deployment\n - MicroAppsAPIGwy\n - Create APIGateway HTTP API\n - Creates domain names to point to the edge (Cloudfront) and origin (API Gateway)\n - MicroAppsCF\n - Creates Cloudfront distribution\n - MicroAppsS3\n - Creates S3 buckets\n - MicroAppsSvcs\n - Create DynamoDB table\n - Create Deployer Lambda function\n - Create Router Lambda function\n- [packages/microapps-datalib](https://github.com/pwrdrvr/microapps-core/tree/main/packages/microapps-datalib)\n - Installed from `npm`:\n - `npm i -g @pwrdrvr/microapps-datalib`\n - APIs for access to the DynamoDB Table used by `microapps-publish`, `microapps-deployer`, and `@pwrdrvr/microapps-app-release-cdk`\n- [packages/microapps-deployer](https://github.com/pwrdrvr/microapps-core/tree/main/packages/microapps-deployer)\n - Lambda service invoked by `microapps-publish` to record new app/version in the DynamoDB table, create API Gateway integrations, copy S3 assets from staging to prod bucket, etc.\n - Returns a temporary S3 token with restricted access to the staging S3 bucket for upload of the static files for one app/semver\n- [packages/microapps-publish](https://github.com/pwrdrvr/microapps-core/tree/main/packages/microapps-publish)\n - Installed from `npm`:\n - `npm i -g @pwrdrvr/microapps-publish`\n - Node executable that updates versions in config files, deploys static assets to the S3 staging bucket, optionally compiles and deploys a new Lambda function version, and invokes `microapps-deployer`\n - AWS IAM permissions required:\n - `lambda:InvokeFunction`\n- [packages/microapps-router](https://github.com/pwrdrvr/microapps-core/tree/main/packages/microapps-router)\n - Lambda function that determines which version of an app to point a user to on a particular invocation\n\n# Creating a MicroApp Using Zip Lambda Functions\n\n[TBC]\n\n# Creating a MicroApp Using Docker Lambda Functions\n\nNote: semi-deprecated as of 2022-01-27. Zip Lambda functions are better supported.\n\n## Next.js Apps\n\nCreate a Next.js app then follow the steps in this section to set it up for publishing to AWS Lambda @ Origin as a MicroApp. To publish new versions of the app use `npx microapps-publish --new-version x.y.z` when logged in to the target AWS account.\n\n### Modify package.json\n\nReplace the version with `0.0.0` so it can be modified by the `microapps-publish` tool.\n\n### Install Dependencies\n\n```\nnpm i --save-dev @sls-next/serverless-component@1.19.0 @pwrdrvr/serverless-nextjs-router @pwrdrvr/microapps-publish\n```\n\n### Dockerfile\n\nAdd this file to the root of the app.\n\n```Dockerfile\nFROM node:15-slim as base\n\nWORKDIR /app\n\n# Download the sharp libs once to save time\n# Do this before copying anything else in\nRUN mkdir -p image-lambda-npms && \\\n cd image-lambda-npms && npm i sharp && \\\n rm -rf node_modules/sharp/vendor/*/include/\n\n# Copy in the build output from `npx serverless`\nCOPY .serverless_nextjs .\nCOPY config.json .\n\n# Move the sharp libs into place\nRUN rm -rf image-lambda/node_modules/ && \\\n mv image-lambda-npms/node_modules image-labmda/ && \\\n rm -rf image-lambda-npms\n\nFROM public.ecr.aws/lambda/nodejs:14 AS final\n\n# Copy in the munged code\nCOPY --from=base /app .\n\nCMD [ \"./index.handler\" ]\n```\n\n### next.config.js\n\nAdd this file to the root of the app.\n\nReplace `appname` with your URL path-compatible application name.\n\n```js\nconst appRoot = '/appname/0.0.0';\n\n// eslint-disable-next-line no-undef\nmodule.exports = {\n target: 'serverless',\n webpack: (config, _options) => {\n return config;\n },\n basePath: appRoot,\n publicRuntimeConfig: {\n // Will be available on both server and client\n staticFolder: appRoot,\n },\n};\n```\n\n### deploy.json\n\nAdd this file to the root of the app.\n\nReplace `appname` with your URL path-compatible application name.\n\n```json\n{\n \"AppName\": \"appname\",\n \"SemVer\": \"0.0.0\",\n \"DefaultFile\": \"\",\n \"StaticAssetsPath\": \"./.serverless_nextjs/assets/appname/0.0.0/\",\n \"LambdaARN\": \"arn:aws:lambda:us-east-1:123456789012:function:appname:v0_0_0\",\n \"AWSAccountID\": \"123456789012\",\n \"AWSRegion\": \"us-east-2\",\n \"ServerlessNextRouterPath\": \"./node_modules/@pwrdrvr/serverless-nextjs-router/dist/index.js\"\n}\n```\n\n### serverless.yaml\n\nAdd this file to the root of the app.\n\n```yaml\nnextApp:\n component: './node_modules/@sls-next/serverless-component'\n inputs:\n deploy: false\n uploadStaticAssetsFromBuild: false\n```\n\n# Troubleshooting\n\n## CloudFront Requests to API Gateway are Rejected with 403 Forbidden\n\nRequests to the API Gateway origin can be rejected with a 403 Forbidden error if the signed request headers are not sent to the origin by CloudFront.\n\nThe error in the API Gateway CloudWatch logs will show up as:\n\n```log\n\"authorizerError\": \"The request for the IAM Authorizer doesn't match the format that API Gateway expects.\"\n```\n\nThis can be simulated by simply running `curl [api-gateway-url]`, with no headers.\n\nTo confirm that API Gateway is allowing signed requests when the IAM Authorizer is configured, establish credentials as a user that is allowed to execute the API Gateay, install `awscurl` with `pip3 install awscurl`, then then use `awscurl --service execute-api --region [api-gateway-region] [api-gateway-url]`.\n\nSignature headers will not be sent from CloudFront to API Gateway unless the `OriginRequestPolicy` is set to specifically include those headers on requests to the origin, or the `headersBehavior` is set to `cfront.OriginRequestHeaderBehavior.all()`.\n\nSimilarly, if `presign` is used, the `OriginRequestPolicy` must be set to `cfront.OriginRequestQueryStringBehavior.all()` or to specifically forward the query string parameters used by the presigned URL.\n\n### SignatureV4 Headers\n- `authorization`\n- `x-amz-date`\n- `x-amz-security-token`\n- `x-amz-content-sha256`\n"
3103
+ "markdown": "[![CI](https://github.com/pwrdrvr/microapps-core/actions/workflows/ci.yml/badge.svg)](https://github.com/pwrdrvr/microapps-core/actions/workflows/ci.yml) [![Merge to Main Build](https://github.com/pwrdrvr/microapps-core/actions/workflows/main-build.yml/badge.svg)](https://github.com/pwrdrvr/microapps-core/actions/workflows/main-build.yml) [![Release Packages](https://github.com/pwrdrvr/microapps-core/actions/workflows/release.yml/badge.svg)](https://github.com/pwrdrvr/microapps-core/actions/workflows/release.yml)\n\n# Overview\n\nThe MicroApps project enables rapidly deploying many web apps to AWS on a single shared host name, fronted by a CloudFront Distribution, serving static assets from an S3 Bucket, and routing application requests via API Gateway. MicroApps is delivered as a CDK Construct for deployment, although alternative deployment methods can be used if desired and implemented.\n\nMicroApps allows many versions of an application to be deployed either as ephemeral deploys (e.g. for pull request builds) or as semi-permanent deploys. The `microapps-router` Lambda function handled routing requests to apps to the current version targeted for a particular application start request using rules as complex as one is interested in implementing (e.g. A/B testing integration, canary releases, per-user rules for logged in users, per-group, per-deparment, and default rules).\n\nUsers start applications via a URL such as `[/{prefix}]/{appname}/`, which hits the `microapps-router` Lambda@Edge OriginRequest handler that looks up the version of the application to be run, and either forwards the request to the target Lambda Function URL (`--startupType direct` invoke mode) or returns a transparent `iframe` (`--startupType iframe`) with a link to that version. `direct` mode works with frameworks, like Next.js, that can return pages that have build-time computed relative URLs to static resources and API calls. `iframe` mode works with frameworks that do not write computed relative URLs at build time and/or that do not use URLs that are completely relative to wherever the applications is rooted at runtime; this mode is primarily for quick prototyping as it has other complications (such as indirect access to query strings). The URL seen by the user in the browser (and available for bookmarking) has no version in it, so subsequent launches (e.g. the next day or just in another tab) will lookup the version again. All relative URL API requests (e.g. `some/api/path`) will go to the corresponding API version that matches the version of the loaded static files, eliminating issues of incompatibility between static files and API deployments.\n\nFor development / testing purposes only, each version of an applicaton can be accessed directly via a URL of the patterns `[/{prefix}]/{appname}?appver={semver}` for `direct` mode or `[/{prefix}]/{appname}/{semver}/` for `iframe` mode. These \"versioned\" URLs are not intended to be advertised to end users as they would cause a user to be stuck on a particular version of the app if the URL was bookmarked. Note that the system does not limit access to particular versions of an application, as of 2023-03-04, but that can be added as a feature.\n\n# Table of Contents <!-- omit in toc -->\n\n- [Overview](#overview)\n- [Why MicroApps](#why-microapps)\n- [Request Routing for Static Assets / App - Diagram](#request-routing-for-static-assets--app---diagram)\n- [Request Dispatch Model for Multi-Account Deployments](#request-dispatch-model-for-multi-account-deployments)\n- [Video Preview of the Deploying CDK Construct](#video-preview-of-the-deploying-cdk-construct)\n- [Installation / CDK Constructs](#installation--cdk-constructs)\n- [Tutorial - Bootstrapping a Deploy](#tutorial---bootstrapping-a-deploy)\n- [Limitations / Future Development](#limitations--future-development)\n- [Related Projects / Components](#related-projects--components)\n- [Why Lambda @ Origin and Not Lambda @ Edge for Apps](#why-lambda--origin-and-not-lambda--edge-for-apps)\n- [Architecure Diagram](#architecure-diagram)\n- [Project Layout](#project-layout)\n- [Creating a MicroApp Using Zip Lambda Functions](#creating-a-microapp-using-zip-lambda-functions)\n- [Creating a MicroApp Using Docker Lambda Functions](#creating-a-microapp-using-docker-lambda-functions)\n - [Next.js Apps](#nextjs-apps)\n - [Modify package.json](#modify-packagejson)\n - [Install Dependencies](#install-dependencies)\n - [Dockerfile](#dockerfile)\n - [next.config.js](#nextconfigjs)\n- [Troubleshooting](#troubleshooting)\n - [CloudFront Requests to API Gateway are Rejected with 403 Forbidden](#cloudfront-requests-to-api-gateway-are-rejected-with-403-forbidden)\n - [SignatureV4 Headers](#signaturev4-headers)\n\n# Why MicroApps\n\nMicroApps are like micro services, but for Web UIs. A MicroApp allows a single functional site to be developed by many independent teams within an organization. Teams must coordinate deployments and agree upon one implementation technology and framework when building a monolithic, or even a monorepo, web application.\n\nTeams using MicroApps can deploy independently of each other with coordination being required only at points of intentional integration (e.g. adding a feature to pass context from one MicroApp to another or coordination of a major feature release to users) and sharing UI styles, if desired (it is possible to build styles that look the same across many different UI frameworks).\n\nMicroApps also allow each team to use a UI framework and backend language that is most appropriate for their solving their business problem. Not every app has to use React or Next.js or even Node on the backend, but instead they can use whatever framework they want and Java, Go, C#, Python, etc. for UI API calls.\n\nFor internal sites, or logged-in-customer sites, different tools or products can be hosted in entirely independent MicroApps. A menuing system / toolbar application can be created as a MicroApp and that menu app can open the apps in the system within a transparent iframe. For externally facing sites, such as for an e-commerce site, it is possible to have a MicroApp serving `/product/...`, another serving `/search/...`, another serving `/`, etc.\n\n# Request Routing for Static Assets / App - Diagram\n\n![Request Routing for Static Assets and App](https://user-images.githubusercontent.com/5617868/222913451-0e6ed906-b6ee-461f-99a7-61db13135ce1.png)\n\n# Request Dispatch Model for Multi-Account Deployments\n\nNote: requests can also be dispatched into the same account, but this model is more likely to be used by organizations with many AWS accounts.\n\n![Request Dispatch Model for Mulit-Account Deployments](https://user-images.githubusercontent.com/5617868/218237120-65b3ae44-31ba-4b6d-8722-4d3fb7da5577.png)\n\n# Video Preview of the Deploying CDK Construct\n\n![Video Preview of Deploying](https://raw.githubusercontent.com/pwrdrvr/microapps-core/main/assets/videos/microapps-core-demo-deploy.gif)\n\n# Installation / CDK Constructs\n\n- `npm i --save-dev @pwrdrvr/microapps-cdk`\n- Add `MicroApps` construct to your stack\n- The `MicroApps` construct does a \"turn-key\" deployment complete with the Release app\n- [Construct Hub](https://constructs.dev/packages/@pwrdrvr/microapps-cdk/)\n - CDK API docs\n - Python, DotNet, Java, JS/TS installation instructions\n\n# Tutorial - Bootstrapping a Deploy\n\n- `git clone https://github.com/pwrdrvr/microapps-core.git`\n - Note: the repo is only being for the example CDK Stack, it is not necessary to clone the repo when used in a custom CDK Stack\n- `cd microapps-core`\n- `npm i -g aws-cdk`\n - Install AWS CDK v2 CLI\n- `asp [my-sso-profile-name]`\n - Using the `aws` plugin from `oh-my-zsh` for AWS SSO\n - Of course, there are other methods of setting env vars\n- `aws sso login`\n - Establish an AWS SSO session\n- `export AWS_REGION=us-east-2`\n - Region needs to be set for the Lambda invoke - This can be done other ways in `~/.aws/config` as well\n- `./deploy.sh`\n - Deploys the CDK Stack\n - Essentially runs two commands along with extraction of outputs:\n - `npx cdk deploy --context @pwrdrvr/microapps:deployReleaseApp=true microapps-basic`\n - `npx microapps-publish publish --app-name release --new-version ${RELEASE_APP_PACKAGE_VERSION} --deployer-lambda-name ${DEPLOYER_LAMBDA_NAME} --app-lambda-name ${RELEASE_APP_LAMBDA_NAME} --static-assets-path node_modules/@pwrdrvr/microapps-app-release-cdk/lib/static_files/release/${RELEASE_APP_PACKAGE_VERSION}/ --overwrite --no-cache`\n - URL will be printed as last output\n\n# Limitations / Future Development\n\n- AWS Only\n - For the time being this has only been implemented for AWS technologies and APIs\n - It is possible that Azure and GCP have sufficient support to enable porting the framework\n - CDK would have to be replaced as well (unless it's made available for Azure and GCP in the near future)\n- `microapps-publish` only supports Lambda function apps\n - There is no technical reason for the apps to only run as Lambda functions\n - Web apps could just as easily run on EC2, Kubernetes, EKS, ECS, etc\n - Anything that API Gateway can route to can work for serving a MicroApp\n - The publish tool needs to provide additional options for setting up the API Gateway route to the app\n- Authentication\n - Authentication requires rolling your own API Gateway and CloudFront deployment at the moment\n - The \"turn key\" CDK Construct should provide options to show an example of how authentication can be integrated\n- Release Rules\n - Currently only a Default rule is supported\n - Need to evaluate if a generic implementation can be made, possibly allowing plugins or webhooks to support arbitrary rules\n - If not possible to make it perfectly generic, consider providing a more complete reference implementation of examples\n\n# Related Projects / Components\n\n- Release App\n - The Release app is an initial, rudimentary, release control console for setting the default version of an application\n - Built with Next.js\n - [pwrdrvr/microapps-app-release](https://github.com/pwrdrvr/microapps-app-release)\n- Next.js Demo App\n - The Next.js Tutorial application deployed as a MicroApp\n - [pwrdrvr/serverless-nextjs-demo](https://github.com/pwrdrvr/serverless-nextjs-demo)\n\n\n# Why Lambda @ Origin and Not Lambda @ Edge for Apps\n\nCalling resources (DBs and other services) and waiting for a long synchronous response is an anti-pattern in Lambda as the Lambda function will be billed for the time spent waiting for the response. This is especially true for Lambda@Edge as the cost is 3x higher than Lambda at the origin.\n\nWith Lambda@Edge (even with Origin Requests) the cost is 3x higher per GB-second and the time spent waiting for a 1 ms service response from an origin that is 250 ms away is 750x higher (250 ms / 1ms * 3x higher cost) than making that same request within the region where the resource resides.\n\n- Lambda@Edge is _at least_ 3x more expensive than Lambda at the origin:\n - In US East 1, the price per GB-Second is $0.00005001 for Lambda@Edge\n - Source: https://aws.amazon.com/lambda/pricing/ (bottom of page)\n - Updated: 2023-03-04\n - In US East 1, the price per GB-Second is $0.0000166667 for Lambda at the origin on x86\n - Source: https://aws.amazon.com/lambda/pricing/\n - Updated: 2023-03-04\n - Ratio\n - Lambda@Edge / Lambda@Origin = $0.00005001 / $0.0000166667 = 3.0006x\n- Any DB or services calls from Lambda@Edge back to the origin will pay that 3x higher per GB-Second cost for any time spent waiting to send the request and get a response. Example:\n - Lambda@Edge\n - 0.250s Round Trip Time (RTT) for EU-zone edge request to hit US-East 1 Origin\n - 0.200s DB lookup time\n - 0.050s CPU usage to process the DB response\n - 0.500s total billed time @ $0.00005001 @ 128 MB\n - $0.000003125625 total charge\n - Lambda at Origin\n - RTT does not apply (it's effectively 1-2 ms to hit a DB in the same region)\n - 0.200s DB lookup time\n - 0.050s CPU usage to process the DB response\n - 0.250s total billed time @ $0.0000166667 @ 128 MB\n - Half the billed time of running on Lambda@Edge\n - 1/6th the cost of running on Lambda@Edge:\n - $0.000000520834375 total charge (assuming no CPU time to process the response)\n - $0.000003125625 / $0.000000520834375 = 6x more expensive in Lambda@Edge\n\n# Architecure Diagram\n\n![Architecure Diagram](https://raw.githubusercontent.com/pwrdrvr/microapps-core/main/assets/images/architecture-diagram.png)\n\n# Project Layout\n\n- [packages/cdk](https://github.com/pwrdrvr/microapps-core/tree/main/packages/cdk)\n - Example CDK Stack\n - Deploys MicroApps CDK stack for the GitHub Workflows\n - Can be used as an example of how to use the MicroApps CDK Construct\n- [packages/demo-app](https://github.com/pwrdrvr/microapps-core/tree/main/packages/demo-app)\n - Example app with static resources and a Lambda function\n - Does not use any Web UI framework at all\n- [packages/microapps-cdk](https://github.com/pwrdrvr/microapps-core/tree/main/packages/microapps-cdk)\n - MicroApps\n - \"Turn key\" CDK Construct that creates all assets needed for a working MicroApps deployment\n - MicroAppsAPIGwy\n - Create APIGateway HTTP API\n - Creates domain names to point to the edge (Cloudfront) and origin (API Gateway)\n - MicroAppsCF\n - Creates Cloudfront distribution\n - MicroAppsS3\n - Creates S3 buckets\n - MicroAppsSvcs\n - Create DynamoDB table\n - Create Deployer Lambda function\n - Create Router Lambda function\n- [packages/microapps-datalib](https://github.com/pwrdrvr/microapps-core/tree/main/packages/microapps-datalib)\n - Installed from `npm`:\n - `npm i -g @pwrdrvr/microapps-datalib`\n - APIs for access to the DynamoDB Table used by `microapps-publish`, `microapps-deployer`, and `@pwrdrvr/microapps-app-release-cdk`\n- [packages/microapps-deployer](https://github.com/pwrdrvr/microapps-core/tree/main/packages/microapps-deployer)\n - Lambda service invoked by `microapps-publish` to record new app/version in the DynamoDB table, create API Gateway integrations, copy S3 assets from staging to prod bucket, etc.\n - Returns a temporary S3 token with restricted access to the staging S3 bucket for upload of the static files for one app/semver\n- [packages/microapps-publish](https://github.com/pwrdrvr/microapps-core/tree/main/packages/microapps-publish)\n - Installed from `npm`:\n - `npm i -g @pwrdrvr/microapps-publish`\n - Node executable that updates versions in config files, deploys static assets to the S3 staging bucket, optionally compiles and deploys a new Lambda function version, and invokes `microapps-deployer`\n - AWS IAM permissions required:\n - `lambda:InvokeFunction`\n- [packages/microapps-router](https://github.com/pwrdrvr/microapps-core/tree/main/packages/microapps-router)\n - Lambda function that determines which version of an app to point a user to on a particular invocation\n\n# Creating a MicroApp Using Zip Lambda Functions\n\n[TBC]\n\n# Creating a MicroApp Using Docker Lambda Functions\n\nNote: semi-deprecated as of 2022-01-27. Zip Lambda functions are better supported.\n\n## Next.js Apps\n\nCreate a Next.js app then follow the steps in this section to set it up for publishing to AWS Lambda @ Origin as a MicroApp. To publish new versions of the app use `npx microapps-publish --new-version x.y.z` when logged in to the target AWS account.\n\n### Modify package.json\n\nReplace the version with `0.0.0` so it can be modified by the `microapps-publish` tool.\n\n### Install Dependencies\n\n```\nnpm i --save-dev @pwrdrvr/microapps-publish\n```\n\n### Dockerfile\n\nFIXME: Out of date 2023-03-04\n\nAdd this file to the root of the app.\n\n```Dockerfile\nFROM node:15-slim as base\n\nWORKDIR /app\n\n# Download the sharp libs once to save time\n# Do this before copying anything else in\nRUN mkdir -p image-lambda-npms && \\\n cd image-lambda-npms && npm i sharp && \\\n rm -rf node_modules/sharp/vendor/*/include/\n\n# Copy in the build output from `npx serverless`\nCOPY .serverless_nextjs .\nCOPY config.json .\n\n# Move the sharp libs into place\nRUN rm -rf image-lambda/node_modules/ && \\\n mv image-lambda-npms/node_modules image-labmda/ && \\\n rm -rf image-lambda-npms\n\nFROM public.ecr.aws/lambda/nodejs:14 AS final\n\n# Copy in the munged code\nCOPY --from=base /app .\n\nCMD [ \"./index.handler\" ]\n```\n\n### next.config.js\n\nFIXME: Out of date 2023-03-04\n\nAdd this file to the root of the app.\n\nReplace `appname` with your URL path-compatible application name.\n\n```js\nconst appRoot = '/appname/0.0.0';\n\n// eslint-disable-next-line no-undef\nmodule.exports = {\n target: 'serverless',\n webpack: (config, _options) => {\n return config;\n },\n basePath: appRoot,\n publicRuntimeConfig: {\n // Will be available on both server and client\n staticFolder: appRoot,\n },\n};\n```\n\n# Troubleshooting\n\n## CloudFront Requests to API Gateway are Rejected with 403 Forbidden\n\nRequests to the API Gateway origin can be rejected with a 403 Forbidden error if the signed request headers are not sent to the origin by CloudFront.\n\nThe error in the API Gateway CloudWatch logs will show up as:\n\n```log\n\"authorizerError\": \"The request for the IAM Authorizer doesn't match the format that API Gateway expects.\"\n```\n\nThis can be simulated by simply running `curl [api-gateway-url]`, with no headers.\n\nTo confirm that API Gateway is allowing signed requests when the IAM Authorizer is configured, establish credentials as a user that is allowed to execute the API Gateay, install `awscurl` with `pip3 install awscurl`, then then use `awscurl --service execute-api --region [api-gateway-region] [api-gateway-url]`.\n\nSignature headers will not be sent from CloudFront to API Gateway unless the `OriginRequestPolicy` is set to specifically include those headers on requests to the origin, or the `headersBehavior` is set to `cfront.OriginRequestHeaderBehavior.all()`.\n\nSimilarly, if `presign` is used, the `OriginRequestPolicy` must be set to `cfront.OriginRequestQueryStringBehavior.all()` or to specifically forward the query string parameters used by the presigned URL.\n\n### SignatureV4 Headers\n- `authorization`\n- `x-amz-date`\n- `x-amz-security-token`\n- `x-amz-content-sha256`\n"
3104
3104
  },
3105
3105
  "repository": {
3106
3106
  "type": "git",
@@ -3139,23 +3139,23 @@
3139
3139
  "kind": "interface",
3140
3140
  "locationInModule": {
3141
3141
  "filename": "src/MicroAppsCF.ts",
3142
- "line": 177
3142
+ "line": 184
3143
3143
  },
3144
3144
  "name": "AddRoutesOptions",
3145
3145
  "properties": [
3146
3146
  {
3147
3147
  "abstract": true,
3148
3148
  "docs": {
3149
- "default": "invalid URL (never used)",
3149
+ "remarks": "Typically an S3 bucket with a `x-microapps-origin: app` custom header\n\nThe request never actually falls through to the S3 bucket.",
3150
3150
  "stability": "experimental",
3151
- "summary": "Default origin (invalid URL or API Gateway)."
3151
+ "summary": "Application origin."
3152
3152
  },
3153
3153
  "immutable": true,
3154
3154
  "locationInModule": {
3155
3155
  "filename": "src/MicroAppsCF.ts",
3156
- "line": 183
3156
+ "line": 192
3157
3157
  },
3158
- "name": "appOrigin",
3158
+ "name": "appOnlyOrigin",
3159
3159
  "type": {
3160
3160
  "fqn": "aws-cdk-lib.aws_cloudfront.IOrigin"
3161
3161
  }
@@ -3169,7 +3169,7 @@
3169
3169
  "immutable": true,
3170
3170
  "locationInModule": {
3171
3171
  "filename": "src/MicroAppsCF.ts",
3172
- "line": 198
3172
+ "line": 208
3173
3173
  },
3174
3174
  "name": "appOriginRequestPolicy",
3175
3175
  "type": {
@@ -3180,16 +3180,16 @@
3180
3180
  "abstract": true,
3181
3181
  "docs": {
3182
3182
  "stability": "experimental",
3183
- "summary": "S3 Bucket CloudFront Origin for static assets."
3183
+ "summary": "Origin Group with Primary of S3 bucket with `x-microapps-origin: s3` custom header and Fallback of `appOnlyOrigin`."
3184
3184
  },
3185
3185
  "immutable": true,
3186
3186
  "locationInModule": {
3187
3187
  "filename": "src/MicroAppsCF.ts",
3188
- "line": 188
3188
+ "line": 198
3189
3189
  },
3190
- "name": "bucketAppsOrigin",
3190
+ "name": "bucketOriginFallbackToApp",
3191
3191
  "type": {
3192
- "fqn": "aws-cdk-lib.aws_cloudfront_origins.S3Origin"
3192
+ "fqn": "aws-cdk-lib.aws_cloudfront_origins.OriginGroup"
3193
3193
  }
3194
3194
  },
3195
3195
  {
@@ -3201,51 +3201,13 @@
3201
3201
  "immutable": true,
3202
3202
  "locationInModule": {
3203
3203
  "filename": "src/MicroAppsCF.ts",
3204
- "line": 193
3204
+ "line": 203
3205
3205
  },
3206
3206
  "name": "distro",
3207
3207
  "type": {
3208
3208
  "fqn": "aws-cdk-lib.aws_cloudfront.Distribution"
3209
3209
  }
3210
3210
  },
3211
- {
3212
- "abstract": true,
3213
- "docs": {
3214
- "default": "false",
3215
- "remarks": "When false API routes with a period in the path will get routed to S3.\n\nWhen true API routes that contain /api/ in the path will get routed to API Gateway\neven if they have a period in the path.",
3216
- "stability": "experimental",
3217
- "summary": "Create an extra Behavior (Route) for /api/ that allows API routes to have a period in them."
3218
- },
3219
- "immutable": true,
3220
- "locationInModule": {
3221
- "filename": "src/MicroAppsCF.ts",
3222
- "line": 218
3223
- },
3224
- "name": "createAPIPathRoute",
3225
- "optional": true,
3226
- "type": {
3227
- "primitive": "boolean"
3228
- }
3229
- },
3230
- {
3231
- "abstract": true,
3232
- "docs": {
3233
- "default": "false",
3234
- "remarks": "When false API routes with a period in the path will get routed to S3.\n\nWhen true API routes that contain /_next/data/ in the path will get routed to API Gateway\neven if they have a period in the path.",
3235
- "stability": "experimental",
3236
- "summary": "Create an extra Behavior (Route) for /_next/data/ This route is used by Next.js to load data from the API Gateway on `getServerSideProps` calls. The requests can end in `.json`, which would cause them to be routed to S3 if this route is not created."
3237
- },
3238
- "immutable": true,
3239
- "locationInModule": {
3240
- "filename": "src/MicroAppsCF.ts",
3241
- "line": 233
3242
- },
3243
- "name": "createNextDataPathRoute",
3244
- "optional": true,
3245
- "type": {
3246
- "primitive": "boolean"
3247
- }
3248
- },
3249
3211
  {
3250
3212
  "abstract": true,
3251
3213
  "docs": {
@@ -3255,7 +3217,7 @@
3255
3217
  "immutable": true,
3256
3218
  "locationInModule": {
3257
3219
  "filename": "src/MicroAppsCF.ts",
3258
- "line": 238
3220
+ "line": 220
3259
3221
  },
3260
3222
  "name": "edgeLambdas",
3261
3223
  "optional": true,
@@ -3278,7 +3240,7 @@
3278
3240
  "immutable": true,
3279
3241
  "locationInModule": {
3280
3242
  "filename": "src/MicroAppsCF.ts",
3281
- "line": 205
3243
+ "line": 215
3282
3244
  },
3283
3245
  "name": "rootPathPrefix",
3284
3246
  "optional": true,
@@ -3300,7 +3262,7 @@
3300
3262
  "kind": "interface",
3301
3263
  "locationInModule": {
3302
3264
  "filename": "src/MicroAppsCF.ts",
3303
- "line": 149
3265
+ "line": 156
3304
3266
  },
3305
3267
  "name": "CreateAPIOriginPolicyOptions",
3306
3268
  "properties": [
@@ -3315,7 +3277,7 @@
3315
3277
  "immutable": true,
3316
3278
  "locationInModule": {
3317
3279
  "filename": "src/MicroAppsCF.ts",
3318
- "line": 156
3280
+ "line": 163
3319
3281
  },
3320
3282
  "name": "assetNameRoot",
3321
3283
  "optional": true,
@@ -3334,7 +3296,7 @@
3334
3296
  "immutable": true,
3335
3297
  "locationInModule": {
3336
3298
  "filename": "src/MicroAppsCF.ts",
3337
- "line": 164
3299
+ "line": 171
3338
3300
  },
3339
3301
  "name": "assetNameSuffix",
3340
3302
  "optional": true,
@@ -3351,7 +3313,7 @@
3351
3313
  "immutable": true,
3352
3314
  "locationInModule": {
3353
3315
  "filename": "src/MicroAppsCF.ts",
3354
- "line": 171
3316
+ "line": 178
3355
3317
  },
3356
3318
  "name": "domainNameEdge",
3357
3319
  "optional": true,
@@ -3816,14 +3778,30 @@
3816
3778
  "abstract": true,
3817
3779
  "docs": {
3818
3780
  "stability": "experimental",
3819
- "summary": "CloudFront Origin for the deployed applications bucket."
3781
+ "summary": "CloudFront Origin for the deployed applications bucket Marked with `x-microapps-origin: app` so the OriginRequest function knows to send the request to the application origin first, if configured for a particular application."
3820
3782
  },
3821
3783
  "immutable": true,
3822
3784
  "locationInModule": {
3823
3785
  "filename": "src/MicroAppsS3.ts",
3824
- "line": 24
3786
+ "line": 27
3825
3787
  },
3826
- "name": "bucketAppsOrigin",
3788
+ "name": "bucketAppsOriginApp",
3789
+ "type": {
3790
+ "fqn": "aws-cdk-lib.aws_cloudfront_origins.S3Origin"
3791
+ }
3792
+ },
3793
+ {
3794
+ "abstract": true,
3795
+ "docs": {
3796
+ "stability": "experimental",
3797
+ "summary": "CloudFront Origin for the deployed applications bucket Marked with `x-microapps-origin: s3` so the OriginRequest function knows to NOT send the request to the application origin and instead let it fall through to the S3 bucket."
3798
+ },
3799
+ "immutable": true,
3800
+ "locationInModule": {
3801
+ "filename": "src/MicroAppsS3.ts",
3802
+ "line": 35
3803
+ },
3804
+ "name": "bucketAppsOriginS3",
3827
3805
  "type": {
3828
3806
  "fqn": "aws-cdk-lib.aws_cloudfront_origins.S3Origin"
3829
3807
  }
@@ -3837,7 +3815,7 @@
3837
3815
  "immutable": true,
3838
3816
  "locationInModule": {
3839
3817
  "filename": "src/MicroAppsS3.ts",
3840
- "line": 29
3818
+ "line": 40
3841
3819
  },
3842
3820
  "name": "bucketAppsStaging",
3843
3821
  "type": {
@@ -3853,7 +3831,7 @@
3853
3831
  "immutable": true,
3854
3832
  "locationInModule": {
3855
3833
  "filename": "src/MicroAppsS3.ts",
3856
- "line": 34
3834
+ "line": 45
3857
3835
  },
3858
3836
  "name": "bucketLogs",
3859
3837
  "type": {
@@ -4382,7 +4360,7 @@
4382
4360
  },
4383
4361
  "locationInModule": {
4384
4362
  "filename": "src/MicroAppsCF.ts",
4385
- "line": 409
4363
+ "line": 356
4386
4364
  },
4387
4365
  "parameters": [
4388
4366
  {
@@ -4411,7 +4389,7 @@
4411
4389
  "kind": "class",
4412
4390
  "locationInModule": {
4413
4391
  "filename": "src/MicroAppsCF.ts",
4414
- "line": 244
4392
+ "line": 226
4415
4393
  },
4416
4394
  "methods": [
4417
4395
  {
@@ -4421,7 +4399,7 @@
4421
4399
  },
4422
4400
  "locationInModule": {
4423
4401
  "filename": "src/MicroAppsCF.ts",
4424
- "line": 303
4402
+ "line": 285
4425
4403
  },
4426
4404
  "name": "addRoutes",
4427
4405
  "parameters": [
@@ -4448,7 +4426,7 @@
4448
4426
  },
4449
4427
  "locationInModule": {
4450
4428
  "filename": "src/MicroAppsCF.ts",
4451
- "line": 258
4429
+ "line": 240
4452
4430
  },
4453
4431
  "name": "createAPIOriginPolicy",
4454
4432
  "parameters": [
@@ -4483,7 +4461,7 @@
4483
4461
  "immutable": true,
4484
4462
  "locationInModule": {
4485
4463
  "filename": "src/MicroAppsCF.ts",
4486
- "line": 405
4464
+ "line": 352
4487
4465
  },
4488
4466
  "name": "cloudFrontDistro",
4489
4467
  "overrides": "@pwrdrvr/microapps-cdk.IMicroAppsCF",
@@ -4513,14 +4491,30 @@
4513
4491
  "abstract": true,
4514
4492
  "docs": {
4515
4493
  "stability": "experimental",
4516
- "summary": "S3 bucket origin for deployed applications."
4494
+ "summary": "S3 bucket origin for deployed applications Marked with `x-microapps-origin: app`."
4517
4495
  },
4518
4496
  "immutable": true,
4519
4497
  "locationInModule": {
4520
4498
  "filename": "src/MicroAppsCF.ts",
4521
- "line": 39
4499
+ "line": 46
4500
+ },
4501
+ "name": "bucketAppsOriginApp",
4502
+ "type": {
4503
+ "fqn": "aws-cdk-lib.aws_cloudfront_origins.S3Origin"
4504
+ }
4505
+ },
4506
+ {
4507
+ "abstract": true,
4508
+ "docs": {
4509
+ "stability": "experimental",
4510
+ "summary": "S3 bucket origin for deployed applications Marked with `x-microapps-origin: s3`."
4511
+ },
4512
+ "immutable": true,
4513
+ "locationInModule": {
4514
+ "filename": "src/MicroAppsCF.ts",
4515
+ "line": 40
4522
4516
  },
4523
- "name": "bucketAppsOrigin",
4517
+ "name": "bucketAppsOriginS3",
4524
4518
  "type": {
4525
4519
  "fqn": "aws-cdk-lib.aws_cloudfront_origins.S3Origin"
4526
4520
  }
@@ -4536,7 +4530,7 @@
4536
4530
  "immutable": true,
4537
4531
  "locationInModule": {
4538
4532
  "filename": "src/MicroAppsCF.ts",
4539
- "line": 73
4533
+ "line": 80
4540
4534
  },
4541
4535
  "name": "assetNameRoot",
4542
4536
  "optional": true,
@@ -4555,7 +4549,7 @@
4555
4549
  "immutable": true,
4556
4550
  "locationInModule": {
4557
4551
  "filename": "src/MicroAppsCF.ts",
4558
- "line": 81
4552
+ "line": 88
4559
4553
  },
4560
4554
  "name": "assetNameSuffix",
4561
4555
  "optional": true,
@@ -4572,7 +4566,7 @@
4572
4566
  "immutable": true,
4573
4567
  "locationInModule": {
4574
4568
  "filename": "src/MicroAppsCF.ts",
4575
- "line": 44
4569
+ "line": 51
4576
4570
  },
4577
4571
  "name": "bucketLogs",
4578
4572
  "optional": true,
@@ -4589,7 +4583,7 @@
4589
4583
  "immutable": true,
4590
4584
  "locationInModule": {
4591
4585
  "filename": "src/MicroAppsCF.ts",
4592
- "line": 86
4586
+ "line": 93
4593
4587
  },
4594
4588
  "name": "certEdge",
4595
4589
  "optional": true,
@@ -4608,7 +4602,7 @@
4608
4602
  "immutable": true,
4609
4603
  "locationInModule": {
4610
4604
  "filename": "src/MicroAppsCF.ts",
4611
- "line": 111
4605
+ "line": 118
4612
4606
  },
4613
4607
  "name": "createAPIPathRoute",
4614
4608
  "optional": true,
@@ -4627,7 +4621,7 @@
4627
4621
  "immutable": true,
4628
4622
  "locationInModule": {
4629
4623
  "filename": "src/MicroAppsCF.ts",
4630
- "line": 126
4624
+ "line": 133
4631
4625
  },
4632
4626
  "name": "createNextDataPathRoute",
4633
4627
  "optional": true,
@@ -4646,7 +4640,7 @@
4646
4640
  "immutable": true,
4647
4641
  "locationInModule": {
4648
4642
  "filename": "src/MicroAppsCF.ts",
4649
- "line": 52
4643
+ "line": 59
4650
4644
  },
4651
4645
  "name": "domainNameEdge",
4652
4646
  "optional": true,
@@ -4665,7 +4659,7 @@
4665
4659
  "immutable": true,
4666
4660
  "locationInModule": {
4667
4661
  "filename": "src/MicroAppsCF.ts",
4668
- "line": 60
4662
+ "line": 67
4669
4663
  },
4670
4664
  "name": "domainNameOrigin",
4671
4665
  "optional": true,
@@ -4683,7 +4677,7 @@
4683
4677
  "immutable": true,
4684
4678
  "locationInModule": {
4685
4679
  "filename": "src/MicroAppsCF.ts",
4686
- "line": 133
4680
+ "line": 140
4687
4681
  },
4688
4682
  "name": "edgeLambdas",
4689
4683
  "optional": true,
@@ -4705,7 +4699,7 @@
4705
4699
  "immutable": true,
4706
4700
  "locationInModule": {
4707
4701
  "filename": "src/MicroAppsCF.ts",
4708
- "line": 65
4702
+ "line": 72
4709
4703
  },
4710
4704
  "name": "httpApi",
4711
4705
  "optional": true,
@@ -4724,7 +4718,7 @@
4724
4718
  "immutable": true,
4725
4719
  "locationInModule": {
4726
4720
  "filename": "src/MicroAppsCF.ts",
4727
- "line": 143
4721
+ "line": 150
4728
4722
  },
4729
4723
  "name": "originShieldRegion",
4730
4724
  "optional": true,
@@ -4741,7 +4735,7 @@
4741
4735
  "immutable": true,
4742
4736
  "locationInModule": {
4743
4737
  "filename": "src/MicroAppsCF.ts",
4744
- "line": 91
4738
+ "line": 98
4745
4739
  },
4746
4740
  "name": "r53Zone",
4747
4741
  "optional": true,
@@ -4778,7 +4772,7 @@
4778
4772
  "immutable": true,
4779
4773
  "locationInModule": {
4780
4774
  "filename": "src/MicroAppsCF.ts",
4781
- "line": 98
4775
+ "line": 105
4782
4776
  },
4783
4777
  "name": "rootPathPrefix",
4784
4778
  "optional": true,
@@ -5884,7 +5878,7 @@
5884
5878
  },
5885
5879
  "locationInModule": {
5886
5880
  "filename": "src/MicroAppsS3.ts",
5887
- "line": 130
5881
+ "line": 146
5888
5882
  },
5889
5883
  "parameters": [
5890
5884
  {
@@ -5914,7 +5908,7 @@
5914
5908
  "kind": "class",
5915
5909
  "locationInModule": {
5916
5910
  "filename": "src/MicroAppsS3.ts",
5917
- "line": 104
5911
+ "line": 115
5918
5912
  },
5919
5913
  "name": "MicroAppsS3",
5920
5914
  "properties": [
@@ -5926,7 +5920,7 @@
5926
5920
  "immutable": true,
5927
5921
  "locationInModule": {
5928
5922
  "filename": "src/MicroAppsS3.ts",
5929
- "line": 106
5923
+ "line": 117
5930
5924
  },
5931
5925
  "name": "bucketApps",
5932
5926
  "overrides": "@pwrdrvr/microapps-cdk.IMicroAppsS3",
@@ -5942,7 +5936,7 @@
5942
5936
  "immutable": true,
5943
5937
  "locationInModule": {
5944
5938
  "filename": "src/MicroAppsS3.ts",
5945
- "line": 111
5939
+ "line": 122
5946
5940
  },
5947
5941
  "name": "bucketAppsOAI",
5948
5942
  "overrides": "@pwrdrvr/microapps-cdk.IMicroAppsS3",
@@ -5953,14 +5947,30 @@
5953
5947
  {
5954
5948
  "docs": {
5955
5949
  "stability": "experimental",
5956
- "summary": "CloudFront Origin for the deployed applications bucket."
5950
+ "summary": "CloudFront Origin for the deployed applications bucket Marked with `x-microapps-origin: app` so the OriginRequest function knows to send the request to the application origin first, if configured for a particular application."
5957
5951
  },
5958
5952
  "immutable": true,
5959
5953
  "locationInModule": {
5960
5954
  "filename": "src/MicroAppsS3.ts",
5961
- "line": 116
5955
+ "line": 127
5962
5956
  },
5963
- "name": "bucketAppsOrigin",
5957
+ "name": "bucketAppsOriginApp",
5958
+ "overrides": "@pwrdrvr/microapps-cdk.IMicroAppsS3",
5959
+ "type": {
5960
+ "fqn": "aws-cdk-lib.aws_cloudfront_origins.S3Origin"
5961
+ }
5962
+ },
5963
+ {
5964
+ "docs": {
5965
+ "stability": "experimental",
5966
+ "summary": "CloudFront Origin for the deployed applications bucket Marked with `x-microapps-origin: s3` so the OriginRequest function knows to NOT send the request to the application origin and instead let it fall through to the S3 bucket."
5967
+ },
5968
+ "immutable": true,
5969
+ "locationInModule": {
5970
+ "filename": "src/MicroAppsS3.ts",
5971
+ "line": 132
5972
+ },
5973
+ "name": "bucketAppsOriginS3",
5964
5974
  "overrides": "@pwrdrvr/microapps-cdk.IMicroAppsS3",
5965
5975
  "type": {
5966
5976
  "fqn": "aws-cdk-lib.aws_cloudfront_origins.S3Origin"
@@ -5974,7 +5984,7 @@
5974
5984
  "immutable": true,
5975
5985
  "locationInModule": {
5976
5986
  "filename": "src/MicroAppsS3.ts",
5977
- "line": 121
5987
+ "line": 137
5978
5988
  },
5979
5989
  "name": "bucketAppsStaging",
5980
5990
  "overrides": "@pwrdrvr/microapps-cdk.IMicroAppsS3",
@@ -5990,7 +6000,7 @@
5990
6000
  "immutable": true,
5991
6001
  "locationInModule": {
5992
6002
  "filename": "src/MicroAppsS3.ts",
5993
- "line": 126
6003
+ "line": 142
5994
6004
  },
5995
6005
  "name": "bucketLogs",
5996
6006
  "overrides": "@pwrdrvr/microapps-cdk.IMicroAppsS3",
@@ -6012,7 +6022,7 @@
6012
6022
  "kind": "interface",
6013
6023
  "locationInModule": {
6014
6024
  "filename": "src/MicroAppsS3.ts",
6015
- "line": 40
6025
+ "line": 51
6016
6026
  },
6017
6027
  "name": "MicroAppsS3Props",
6018
6028
  "properties": [
@@ -6027,7 +6037,7 @@
6027
6037
  "immutable": true,
6028
6038
  "locationInModule": {
6029
6039
  "filename": "src/MicroAppsS3.ts",
6030
- "line": 77
6040
+ "line": 88
6031
6041
  },
6032
6042
  "name": "assetNameRoot",
6033
6043
  "optional": true,
@@ -6046,7 +6056,7 @@
6046
6056
  "immutable": true,
6047
6057
  "locationInModule": {
6048
6058
  "filename": "src/MicroAppsS3.ts",
6049
- "line": 85
6059
+ "line": 96
6050
6060
  },
6051
6061
  "name": "assetNameSuffix",
6052
6062
  "optional": true,
@@ -6064,7 +6074,7 @@
6064
6074
  "immutable": true,
6065
6075
  "locationInModule": {
6066
6076
  "filename": "src/MicroAppsS3.ts",
6067
- "line": 55
6077
+ "line": 66
6068
6078
  },
6069
6079
  "name": "bucketAppsName",
6070
6080
  "optional": true,
@@ -6082,7 +6092,7 @@
6082
6092
  "immutable": true,
6083
6093
  "locationInModule": {
6084
6094
  "filename": "src/MicroAppsS3.ts",
6085
- "line": 62
6095
+ "line": 73
6086
6096
  },
6087
6097
  "name": "bucketAppsStagingName",
6088
6098
  "optional": true,
@@ -6100,7 +6110,7 @@
6100
6110
  "immutable": true,
6101
6111
  "locationInModule": {
6102
6112
  "filename": "src/MicroAppsS3.ts",
6103
- "line": 69
6113
+ "line": 80
6104
6114
  },
6105
6115
  "name": "bucketLogsName",
6106
6116
  "optional": true,
@@ -6119,7 +6129,7 @@
6119
6129
  "immutable": true,
6120
6130
  "locationInModule": {
6121
6131
  "filename": "src/MicroAppsS3.ts",
6122
- "line": 95
6132
+ "line": 106
6123
6133
  },
6124
6134
  "name": "originShieldRegion",
6125
6135
  "optional": true,
@@ -6138,7 +6148,7 @@
6138
6148
  "immutable": true,
6139
6149
  "locationInModule": {
6140
6150
  "filename": "src/MicroAppsS3.ts",
6141
- "line": 48
6151
+ "line": 59
6142
6152
  },
6143
6153
  "name": "removalPolicy",
6144
6154
  "optional": true,
@@ -6697,6 +6707,6 @@
6697
6707
  "symbolId": "src/MicroAppsTable:MicroAppsTableProps"
6698
6708
  }
6699
6709
  },
6700
- "version": "0.4.0-alpha.2",
6701
- "fingerprint": "0Kb7UTrQ1yRkY0t35HVLxFH5LtIPezO5oYCW2PSdDmY="
6702
- }
6710
+ "version": "0.4.0-alpha.4",
6711
+ "fingerprint": "SOdmU+Snnw3InbZKuEVbvXJjsCEBMjjWlkNVCLk1m8c="
6712
+ }