Pages
page entity helps abstract web pages (SPA, SSR, PWA etc). It provides a mechanism to orchestrate your app with edge and regular functions in a framework-agnostic way
Single Page Apps
Section titled “Single Page Apps”name: topology-name
pages: my-app: kind: SPA | PWA | Static dist: 'app/dist' <optional> dir: 'app' build: - npm install --quiet - npm run buildSee Examples
Dynamic Configuration
Section titled “Dynamic Configuration”tc injects secrets and configs dynamically for a sandbox during build time.
Let’s say you have frontend/.env or src/config.json file with the following template variables. tc will render the template variables and resolve the right URI.
APPSYNC__URL={{GRAPHQL_ENDPOINT}}APPSYNC_GRAPHQL_URL="{{GRAPHQL_WSS_ENDPOINT}}"REST_ENDPOINT="{{REST_ENDPOINT}}"GRAPHQL_API_KEY=ssm://path/to/my/keyMY_SECRET_KEY=ssm://path/to/my/keyDynamic config can be enabled by specifying the path to the config. Typically it is a dotenv file
pages: my-app: kind: SPA | PWA | Static dir: frontend config_template: .env build: - npm install --quiet - npm run buildThe following variables are available based on the entity defined:
| Entity | Variable |
|---|---|
| Mutation | GRAPHQL_ENDPOINT |
| Mutation | GRAPHQL_ID |
| Mutation | GRAPHQL_WSS_ENDPOINT |
| Mutation | GRAPHQL_API_KEY |
| Route | REST_ENDPOINT |
| Generic | REGION |
| Generic | ACCOUNT |
The config file rendered is specific to the sandbox and is created at the time of building the frontend page or app.
Entity URIs
Section titled “Entity URIs”We can also inject URLs from other namespaces in the .env file. For example, the following resolves the GRAPHQL_URL from a diferrent namespace:
GRAPHQL_ENDPOINT=mutation://OTHER-NAMESPACE_{{SANDBOX}}Customization
Section titled “Customization”Domains
Section titled “Domains”tc creates domains, certs and associates the aliases. Assuming you have created the domains to associate, for example foo.com , we can set them either in the topology file or correspoding infra dir.
pages: dashboard: dir: dir1 domains: stable: dashboard.foo.com onboarding: dir: dir2 domains: stable: onboarding.{{env}}.foo.comWe can also specify a more detailed mapping in infrastructure/tc/<namespace>/pages/<page>.json:
{ "bucket": "my-bucket-{{env}}", "domains": { "default": { "stable": "app.{{env}}.foo.com", "yoda": "app-yoda.{{env}}.foo.com", "test": "app-test.{{env}}.foo.com" }, "prod": { "stable": "app.foo.com" } }}Bucket
Section titled “Bucket”The S3 bucket to host the static assets can be configured in any of the following ways:
- Set bucket in topology (not recommended as it leaks infrastructure variables into topology definition)
pages: dashboard: dist: '.' bucket: 'my-bucket-{{env}}'- Set
TC_PAGES_BUCKETenv var
export TC_PAGES_BUCKET=my-bucket-prod- Set it in tc config (in path specified in TC_CONFIG_PATH env variable)
aws: cloudfront: bucket: 'my-bucket-{{env}}'Components
Section titled “Components”To update specific components
tc update -s sandbox -e profile -c pages/codetc update -s sandbox -e profile -c pages/buildtc update -s sandbox -e profile -c pages/domainstc update -s sandbox -e profile -c pages/configOr you can update a specific page
tc update -s sandbox -e profile -c pages/dashboard