astro-aws-amplify adapter to deploy seamlessly to AWS Amplify. This adapter automatically configures your Astro application for Amplify’s serverless infrastructure.
Prerequisites
Before deploying, ensure you have:- An AWS account with Amplify access
- Your application code in a Git repository (GitHub, GitLab, Bitbucket, or AWS CodeCommit)
- AWS credentials configured for your Bedrock Agent (see Environment Variables)
Adapter Configuration
The application is pre-configured with the AWS Amplify adapter inastro.config.mjs:
astro.config.mjs
The
output: "server" mode enables server-side rendering (SSR), which is required for the chat API endpoints to function properly.Deployment Steps
Connect Your Repository
- Sign in to the AWS Amplify Console
- Click New app → Host web app
- Select your Git provider and authorize AWS Amplify
- Choose the repository containing your Workshop Cloud Chat code
- Select the branch you want to deploy (e.g.,
mainorproduction)
Configure Build Settings
Amplify should automatically detect the Astro framework. Verify the build settings:
amplify.yml
The
astro-aws-amplify adapter automatically generates the .amplify-hosting directory during the build process with the correct structure for Amplify deployment.Set Environment Variables
While Workshop Cloud Chat accepts AWS credentials through the UI, you may want to set other environment variables:
- In the Amplify Console, navigate to your app
- Go to App settings → Environment variables
- Add any required variables (see Environment Variables)
Build Configuration Details
How the Adapter Works
Theastro-aws-amplify adapter:
- Converts SSR Routes: Transforms your Astro API endpoints (like
/api/chat) into Lambda-compatible functions - Optimizes Static Assets: Bundles static files for efficient delivery through Amplify’s CDN
- Generates Amplify Structure: Creates the
.amplify-hostingdirectory with:compute/default/- Lambda function code for SSR routesstatic/- Static assets (CSS, JS, images)deploy-manifest.json- Routing and deployment configuration
Package Manager
Workshop Cloud Chat uses Yarn 1.22.22 as specified inpackage.json. Amplify will automatically detect this and use Yarn for dependency installation.
Continuous Deployment
Once configured, AWS Amplify automatically:- Builds and deploys on every push to your connected branch
- Provides preview URLs for pull requests (if enabled)
- Rolls back to previous versions if a build fails
Monitoring and Logs
Access deployment and runtime logs:- Build Logs: Available in the Amplify Console under Build history
- Function Logs: View Lambda logs in CloudWatch (linked from the Amplify Console)
- Access Logs: Monitor traffic patterns in the Monitoring tab
Custom Domain
To use a custom domain:Troubleshooting
Build Failures
If your build fails:- Check the build logs in the Amplify Console
- Verify all dependencies are listed in
package.json - Ensure the
astro-aws-amplifyadapter version is compatible (currently0.2.4)
API Endpoint Errors
If the/api/chat endpoint returns errors:
- Verify the Lambda function has sufficient timeout (default is 10 seconds, increase if needed)
- Check CloudWatch logs for detailed error messages
- Ensure users are providing valid AWS credentials through the UI
Cold Start Performance
Lambda functions may experience cold starts:- First request after idle period may take 1-3 seconds
- Consider AWS Lambda Provisioned Concurrency for high-traffic applications
- The adapter automatically optimizes bundle size to minimize cold start time
Next Steps
- Configure Environment Variables for your production environment
- Set up monitoring and alerting in AWS CloudWatch
- Review AWS Amplify pricing to understand costs