Amplify, AppSync and Cognito
Separate hosting, API and identity
Amplify Hosting publishes web front ends; AppSync can provide managed GraphQL APIs and event APIs; Cognito helps authenticate application users. They solve different problems and may be used independently. A bookstore can serve its public catalog from a static front end while its signed-in customers query private order records through an API. Hosting the front end does not grant authorization to read the orders.
Static builds and server-side rendering
A static build generates HTML, CSS and JavaScript files. A single-page application (SPA) may use browser-side routing; a direct visit to a route needs a matching hosting rewrite where appropriate. Server-side rendering (SSR) executes server code to create responses. Amplify supports eligible SSR frameworks and adapters, but manual file deployment is not supported for SSR apps. Verify framework/runtime support and the output directory, build commands and dependencies before selecting a deployment method.
Follow a private data request
A Cognito user pool authenticates app users and issues tokens. An identity pool can provide temporary AWS credentials to eligible identities through IAM roles; it is not the same as a user pool. An AppSync GraphQL API can use Cognito user pools as an authorization mode, among other supported modes. Token validation establishes a trusted caller context; enforce resource ownership at the resolver or backend as well. A valid user token must not permit reading another customer’s order simply by changing an identifier.
Example: an offline ownership rule
A mock backend receives a previously validated subject reader-a. Order order-7 belongs to reader-a and may be returned. Order order-8 belongs to reader-b and must be denied. Missing identity is denied too. The lab tests that rule without generating or decoding real tokens. It is not a Cognito or AppSync implementation; real APIs require signature, issuer, expiration, applicable audience/client and token-type checks plus service-specific authorization. Do not put credentials in the browser bundle.
Deployment and domains
Plan a build from a reviewed commit, verify the output directory and test a preview environment using synthetic data. Public API endpoint configuration may be visible to browser code; secrets must remain server-side. Connect a custom domain only if you control it, verify DNS and HTTPS, and test redirects and deep links. Check costs for builds, hosting, data transfer, API requests, logs and identity usage. Preview deployments can consume resources too.
Practice
Draw browser → hosting for files and browser → API → data store for orders, with Cognito providing authentication. Explain why a hidden button is not a permission check. Use the offline ownership tests and confirm that the public catalog does not need private order data.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Amplify, AppSync and Cognito — knowledge check
Apply hosting choices to fictional workloads.
What is Amplify Hosting primarily used for in this design?
An SSR app needs a deployment method. Which statement is correct?
Which service feature authenticates application users and issues tokens?
Reader A is authenticated but requests Reader B’s private order. What should the API do?
Where should an application’s private database credential be kept?