0.1.1 • Published 6 months ago

@hands-on-aws-cdk-book/custom-amplify-construct v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

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-construct

Usage

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

  1. Store your GitHub personal access token in AWS Secrets Manager
  2. 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 ci for clean installs
  • npm run build for production builds
  • Caches node_modules for faster builds
  • Serves from the build directory
  • Handles SPA routing with custom rules

Security

  • Uses Secrets Manager for GitHub token
  • HTTPS by default
  • Environment variables are encrypted at rest
0.1.1

6 months ago

0.1.0

7 months ago