{"id":17414,"library":"amplify-category-hosting","title":"AWS Amplify CLI Hosting Plugin","description":"This package is a core plugin for the AWS Amplify Command Line Interface (CLI), specifically designed to manage the hosting services for Amplify projects. It empowers developers to seamlessly add, update, push, and remove web hosting capabilities, primarily leveraging services like AWS Amplify Console (for full-stack deployments) or Amazon S3/CloudFront (for static site hosting). While the overall Amplify CLI is in its `v14.x` major version, this specific plugin (`amplify-category-hosting`) is at version `3.4.10`, indicating a stable and less frequently updated internal component. The Amplify CLI generally follows a frequent release cadence, often weekly or bi-weekly, for bug fixes and minor improvements across its various categories. Its key differentiator is deeply integrating hosting with other Amplify backend categories (Auth, API, Storage) and providing a streamlined CI/CD pipeline for frontend web applications, simplifying the deployment process for developers.","status":"active","version":"3.4.10","language":"javascript","source_language":"en","source_url":"https://github.com/aws-amplify/amplify-cli","tags":["javascript","amplify","aws"],"install":[{"cmd":"npm install amplify-category-hosting","lang":"bash","label":"npm"},{"cmd":"yarn add amplify-category-hosting","lang":"bash","label":"yarn"},{"cmd":"pnpm add amplify-category-hosting","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is an internal plugin of the Amplify CLI and is invoked through the `amplify` command-line tool. End-users interact with the CLI, not this package directly.","package":"@aws-amplify/cli","optional":false}],"imports":[{"note":"This package is a CLI plugin and not designed for programmatic import in client-side or server-side JavaScript/TypeScript applications. Its functionalities are accessed exclusively via `amplify` CLI commands.","wrong":"import { addHosting } from 'amplify-category-hosting'","symbol":"amplify hosting add","correct":"amplify hosting add"},{"note":"Amplify CLI plugins are invoked as subcommands of the `amplify` executable. Attempting to `import` or `require` this package directly will result in runtime errors.","wrong":"import { pushHostingChanges } from 'amplify-category-hosting'","symbol":"amplify hosting push","correct":"amplify hosting push"},{"note":"The primary interaction pattern is through the terminal, running commands like `amplify hosting remove` to manage cloud resources.","wrong":"import { removeHosting } from 'amplify-category-hosting'","symbol":"amplify hosting remove","correct":"amplify hosting remove"}],"quickstart":{"code":"npx amplify-cli init --amplify-config '{\"projectName\":\"myamplifyapp\",\"envName\":\"dev\",\"defaultEditor\":\"code\",\"frontend\":\"javascript\",\"framework\":\"react\",\"srcDir\":\"src\",\"distDir\":\"build\",\"buildCommand\":\"npm run-script build\",\"startCommand\":\"npm run-script start\"}' --force\ncd myamplifyapp\n# Add hosting for a Single Page App (SPA) or PWA\namplify hosting add\n# Choose 'Hosting with Amplify Console (Managed hosting and CI/CD)'\n# Choose 'Manual deployment'\n# Or integrate with a Git repository for continuous deployment.\n\n# After adding hosting and building your frontend, deploy it:\nnpm run build\namplify publish\n\n# To remove hosting later:\namplify hosting remove\n","lang":"bash","description":"Demonstrates initializing an Amplify project, adding Amplify Console hosting for manual deployment, building the frontend, and publishing it to the cloud. It also shows how to remove the hosting category."},"warnings":[{"fix":"Update Node.js to version 18 or higher in your local development environment and in your Amplify Console build settings. Configure the `runtime` in your build specification if necessary.","message":"The Amplify CLI introduced a major version `14.0.0` which updated the default Node.js runtime to Node.js 18 and removed support for .NET Core 3.1. Ensure your local environment and Amplify Console build settings match this requirement to avoid build failures.","severity":"breaking","affected_versions":">=14.0.0 (Amplify CLI)"},{"fix":"Always use the Amplify CLI or Amplify Studio to manage resources provisioned by Amplify. If drift occurs, a `amplify status` and `amplify push --force` might sometimes resolve it, but it's best to avoid manual changes. For complex cases, consider rolling back or recreating the environment.","message":"Modifying Amplify-managed cloud resources (e.g., S3 buckets, CloudFront distributions, IAM roles) directly through the AWS Console can cause 'drift' and lead to `amplify push` failures or unexpected behavior during subsequent deployments.","severity":"gotcha","affected_versions":">=1.0.0 (Amplify CLI)"},{"fix":"Regularly run `amplify pull --force` in each environment to synchronize local configurations with the backend. For CI/CD, ensure environment variables or IAM roles provide appropriate permissions to deploy to the target Amplify App ID and environment. Verify `platform` type in Amplify Hosting settings is correct for SSR (WEB_COMPUTE/WEB_DYNAMIC) vs static (WEB) apps.","message":"When migrating between Amplify CLI major versions or working in multi-account/multi-environment setups, ensure consistent `amplifyconfiguration.json` (or `aws-exports.js`) files across all environments and that build environments have correct credentials. Discrepancies can lead to deployment failures in CI/CD pipelines.","severity":"gotcha","affected_versions":">=1.0.0 (Amplify CLI)"},{"fix":"Check the build logs in the Amplify Console for specific error messages. Ensure your Node.js version is consistent (e.g., set `NVM_VERSION` environment variable). Increase the build compute type (Standard to Large) or build timeout in the Amplify Console. Optimize build artifacts to stay within size limits for SSR Lambda functions (e.g., remove dev dependencies from deployment package).","message":"Build failures in Amplify Hosting are common and can stem from various issues, including Node.js version mismatches, insufficient memory for large applications, exceeding artifact size limits (especially for SSR apps), or build timeouts.","severity":"gotcha","affected_versions":">=1.0.0 (Amplify CLI)"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Using the Amplify CLI, deploy the application specifically in the failing account/environment. Get the App ID from a working environment (e.g., 'dev') and then run `amplify pull --appId <APP_ID> --envName <FAILING_ENV_NAME>` followed by `amplify publish` or `amplify push` in the context of the failing environment.","cause":"Inconsistent deployments across environments, often in multi-account or CI/CD pipelines, where one environment fails to update.","error":"The Amplify Console displays the “build” step of one of your environments as failed and shows other environments as successfully deployed."},{"fix":"Avoid manual changes to Amplify-generated resources. If drift occurs, `amplify status` might indicate discrepancies. In some cases, `amplify push --force` may help synchronize, but for complex drift, manual intervention to revert changes in the AWS Console to match the CloudFormation template or even recreating the resource might be necessary as a last resort.","cause":"Amplify-managed cloud resources (e.g., DynamoDB tables, Cognito Roles, IAM policies) were modified outside of the Amplify CLI or Amplify Studio, leading to a mismatch between the CloudFormation stack and the actual AWS resources.","error":"Push failures from unmanaged changes to cloud resources - Drift"},{"fix":"Reduce the size of your deployment artifact. This often involves ensuring that development dependencies are not bundled into the production build, using external modules provided by the Lambda runtime where possible, or excluding large unnecessary files from the deployment package.","cause":"Your build artifact, particularly for Server-Side Rendered (SSR) applications using AWS Lambda, exceeds the maximum allowed deployment package size (e.g., 50MB for Lambda).","error":"Deployment failed due to build error: The request entity is too large."},{"fix":"In the Amplify Console, navigate to 'App settings' -> 'Build settings'. Increase the 'Build compute type' from 'Standard' to 'Large' to provide more memory. Also, increase the 'Build timeout' setting to 60 or 120 minutes.","cause":"The build process exhausted the memory allocated to the Amplify build container or exceeded the maximum build duration. This is common for large React/Next.js applications.","error":"Deployment failed due to build error: 'out of memory' or 'Build timed out'"}],"ecosystem":"npm","meta_description":null}