@hands-on-aws-cdk-book/custom-amplify-construct
v0.1.1
Published
Custom Amplify construct from Hands-on AWS CDK Book
Maintainers
Readme
Custom Amplify CDK Construct
A simple AWS CDK construct for creating Amplify applications with configurable environment variables.
Installation
npm install @hands-on-aws-cdk-book/custom-amplify-constructUsage
import { CustomAmplifyConstruct } from "@hands-on-aws-cdk-book/custom-amplify-construct";
// Basic usage
const basicApp = new CustomAmplifyConstruct(this, "BasicApp", {
appName: "MyApp",
githubRepositoryUrl: "https://github.com/username/repo",
githubTokenSecretName: "github-token",
});
// With environment variables
const appWithEnv = new CustomAmplifyConstruct(this, "AppWithEnv", {
appName: "MyApp",
githubRepositoryUrl: "https://github.com/username/repo",
githubTokenSecretName: "github-token",
environmentVariables: {
VITE_API_ENDPOINT: api.url,
VITE_USER_POOL_ID: userPool.userPoolId,
},
});Prerequisites
- Store your GitHub personal access token in AWS Secrets Manager
- Have a GitHub repository with your Vite application
Environment Variables
All environment variables will be prefixed with VITE_ to work with Vite applications.
The construct automatically adds:
VITE_REGION: AWS Region
Add any additional environment variables through the environmentVariables prop.
Build Settings
The construct uses the following build settings:
- Node.js environment
npm cifor clean installsnpm run buildfor production builds- Caches node_modules for faster builds
- Serves from the
builddirectory - Handles SPA routing with custom rules
Security
- Uses Secrets Manager for GitHub token
- HTTPS by default
- Environment variables are encrypted at rest
