Package Exports
- scf-deploy
- scf-deploy/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (scf-deploy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
scf-deploy - S3 + CloudFront Deployment CLI
Automate static website deployment to AWS S3 and CloudFront with a simple CLI tool.
Features
- Easy Setup: Interactive
initcommand with helpful post-install message - Simple Deployment: Deploy with a single command
npx scf-deploy deploy - TypeScript Configuration: Type-safe config files with
scf.config.ts - Multiple Templates: Pre-configured templates for React, Vue, Next.js
- Incremental Deployment: Only upload changed files (SHA-256 hash comparison)
- CloudFront Integration: Automatic cache invalidation after deployment
- Multi-Environment Support: Manage dev, staging, and prod environments
- AWS Credentials Integration: Supports AWS profiles, environment variables, and IAM roles
- State Management: Track deployed resources locally
- Progress Tracking: Real-time upload progress with visual feedback
Installation
Global Installation
npm install -g scf-deployDirect Execution with npx (Recommended)
npx scf-deploy deployQuick Start
1. Initialize Configuration
Run the init command to create scf.config.ts:
npx scf-deploy initThis will guide you through an interactive setup or you can use defaults:
npx scf-deploy init --yesOr manually create scf.config.ts in your project root:
import { defineConfig } from 'scf-deploy';
export default defineConfig({
app: 'my-static-site',
region: 'ap-northeast-2',
s3: {
bucketName: 'my-site-bucket',
buildDir: './dist',
indexDocument: 'index.html',
errorDocument: '404.html',
},
cloudfront: {
enabled: true,
priceClass: 'PriceClass_100',
},
});2. Build Your Site
# For React, Vue, etc.
npm run build
# For plain HTML
# Just make sure your files are in the buildDir3. Deploy
npx scf-deploy deployThat's it! Your site is now live on S3 and CloudFront.
Configuration
Basic Configuration
import { defineConfig } from 'scf-deploy';
export default defineConfig({
app: 'my-app', // Application name
region: 'us-east-1', // AWS region
s3: {
bucketName: 'my-bucket',
buildDir: './dist',
indexDocument: 'index.html',
errorDocument: '404.html',
},
cloudfront: {
enabled: true,
priceClass: 'PriceClass_100', // PriceClass_100, PriceClass_200, PriceClass_All
},
});Environment-Specific Configuration
export default defineConfig({
app: 'my-app',
region: 'ap-northeast-2',
s3: {
bucketName: 'my-site-prod',
buildDir: './dist',
},
cloudfront: {
enabled: true,
},
// Environment overrides
environments: {
dev: {
s3: { bucketName: 'my-site-dev' },
cloudfront: { enabled: false }, // Skip CloudFront in dev
},
staging: {
s3: { bucketName: 'my-site-staging' },
},
prod: {
cloudfront: { priceClass: 'PriceClass_All' },
},
},
});Custom Domain Configuration
export default defineConfig({
app: 'my-app',
region: 'us-east-1',
s3: {
bucketName: 'my-site',
buildDir: './dist',
},
cloudfront: {
enabled: true,
customDomain: {
domainName: 'example.com',
certificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/abc-def',
},
},
});Commands
init
Initialize scf.config.ts configuration file.
# Interactive mode (asks questions)
scf-deploy init
# Non-interactive mode (use defaults)
scf-deploy init --yes
# Use a template (react, vue, next, custom)
scf-deploy init --template react
# Overwrite existing config
scf-deploy init --forceOptions:
-f, --force- Overwrite existing config file-y, --yes- Skip prompts and use default values-t, --template <template>- Use template (custom, react, vue, next)
Templates:
custom- Custom configuration (default build dir:./dist)react- React/CRA configuration (build dir:./build)vue- Vue.js configuration (build dir:./dist)next- Next.js static export (build dir:./out)
deploy
Deploy your static site to S3 and CloudFront.
# Basic deployment
scf-deploy deploy
# Deploy to specific environment
scf-deploy deploy --env prod
# Use specific AWS profile
scf-deploy deploy --profile my-aws-profile
# Preview without uploading
scf-deploy deploy --dry-run
# Skip CloudFront (S3 only)
scf-deploy deploy --no-cloudfront
# Force full deployment (ignore cached state)
scf-deploy deploy --forceOptions:
-e, --env <environment>- Environment name (default: "default")-c, --config <path>- Config file path (default: "scf.config.ts")-p, --profile <profile>- AWS profile name--dry-run- Preview deployment without uploading--no-cloudfront- Skip CloudFront deployment--force- Force full deployment (ignore state)--skip-cache- Skip CloudFront cache invalidation
remove
Remove deployed AWS resources.
# Remove resources (with confirmation prompt)
scf-deploy remove
# Force remove without confirmation
scf-deploy remove --force
# Remove specific environment
scf-deploy remove --env dev
# Keep S3 bucket (only delete files)
scf-deploy remove --keep-bucket
# Keep CloudFront distribution
scf-deploy remove --keep-distributionOptions:
-e, --env <environment>- Environment name (default: "default")-c, --config <path>- Config file path (default: "scf.config.ts")-p, --profile <profile>- AWS profile name-f, --force- Skip confirmation prompt--keep-bucket- Keep S3 bucket (only delete files)--keep-distribution- Keep CloudFront distribution
status
Check current deployment status.
# Basic status
scf-deploy status
# Specific environment
scf-deploy status --env prod
# Detailed information
scf-deploy status --detailed
# JSON output
scf-deploy status --jsonOptions:
-e, --env <environment>- Environment name (default: "default")-d, --detailed- Show detailed information--json- Output as JSON
AWS Credentials
scf-deploy looks for AWS credentials in the following order:
- Command-line option:
--profileflag - Environment variables:
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY - AWS CLI profiles:
~/.aws/credentials - IAM Role: When running on EC2, ECS, etc.
Using AWS Profile
scf-deploy deploy --profile my-company-profileUsing Environment Variables
export AWS_ACCESS_KEY_ID=your_access_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
scf-deploy deployFeatures in Detail
Incremental Deployment
scf-deploy uses SHA-256 hashing to detect file changes:
- First deployment: All files are uploaded
- Subsequent deployments: Only changed files are uploaded
- Time savings: 80-95% faster deployment times
State is stored in .deploy/state.{env}.json (add to .gitignore).
CloudFront Cache Invalidation
After deployment, scf-deploy automatically:
- Creates or updates CloudFront distribution
- Invalidates cache for changed files
- Waits for distribution to be fully deployed
- Shows real-time progress
Multi-Environment Support
Manage multiple environments with ease:
scf-deploy deploy --env dev
scf-deploy deploy --env staging
scf-deploy deploy --env prodEach environment:
- Has its own state file
- Can override configuration
- Is completely isolated
Progress Tracking
Visual feedback during deployment:
- File scanning progress
- Upload progress bar
- Real-time status updates
- Detailed error messages
Examples
React Application
# Build your React app
npm run build
# Deploy to production
scf-deploy deploy --env prodConfiguration:
export default defineConfig({
app: 'my-react-app',
region: 'us-east-1',
s3: {
bucketName: 'my-react-app',
buildDir: './build', // React default
indexDocument: 'index.html',
},
cloudfront: {
enabled: true,
},
});Vue Application
# Build your Vue app
npm run build
# Deploy
scf-deploy deployConfiguration:
export default defineConfig({
app: 'my-vue-app',
region: 'eu-west-1',
s3: {
bucketName: 'my-vue-app',
buildDir: './dist', // Vue default
indexDocument: 'index.html',
},
cloudfront: {
enabled: true,
},
});Static HTML Site
export default defineConfig({
app: 'my-website',
region: 'ap-northeast-2',
s3: {
bucketName: 'my-website',
buildDir: './public',
indexDocument: 'index.html',
errorDocument: '404.html',
},
cloudfront: {
enabled: true,
},
});Troubleshooting
Command not found
# Check if installed
which scf-deploy
# Reinstall globally
npm uninstall -g scf-deploy
npm install -g scf-deploy
# Or use npx (recommended)
npx scf-deploy deployAWS Credentials Error
# Verify AWS credentials
aws sts get-caller-identity
# Use specific profile
scf-deploy deploy --profile my-profileConfig file not found
# Check if scf.config.ts exists
ls -la scf.config.ts
# Specify custom path
scf-deploy deploy --config ./config/scf.config.tsState file conflicts
# Check state files
ls -la .deploy/
# Force full redeployment
scf-deploy deploy --forceRequirements
- Node.js: >= 18.0.0
- AWS Account: With appropriate permissions
- AWS Credentials: Configured via CLI, environment, or IAM role
Required AWS Permissions
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:CreateBucket",
"s3:DeleteBucket",
"s3:ListBucket",
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject",
"s3:PutBucketWebsite",
"cloudfront:CreateDistribution",
"cloudfront:GetDistribution",
"cloudfront:UpdateDistribution",
"cloudfront:DeleteDistribution",
"cloudfront:CreateInvalidation"
],
"Resource": "*"
}
]
}Best Practices
- Add
.deploy/to.gitignore: Don't commit state files - Use environment-specific configs: Separate dev/staging/prod
- Test with
--dry-runfirst: Preview changes before deploying - Use IAM roles in CI/CD: Don't hardcode credentials
- Enable CloudFront in production: Better performance and HTTPS
- Set up custom domain with ACM certificate: Professional appearance
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT License - see LICENSE file for details
Links
- Homepage: https://github.com/SCF-org
- Issues: https://github.com/SCF-org/scf/issues
- NPM: https://www.npmjs.com/package/scf-deploy
Author
jeonghodong fire13764@gmail.com