OculusCyber Logo

OculusCyber

Home

Browse Topics


AWS Amplify: Auto-Deploy & Test Without Affecting Live Domain

By oculus

October 22, 2025


How It Works

Short answer: It depends on which backend you want to connect to.

Option 1: Connect to Production/Deployed Backend

If you deployed yesterday and want to test against that **production backend**, you can:

npm run dev

Your frontend will connect to whatever backend is specified in your `amplify_outputs.json` file. If that file was generated from your production deployment, you'll be using the production backend resources (database, auth, etc.).

Option 2: Use a Sandbox (Personal Dev Backend)

If you want to:

- Test backend changes before deploying

- Have an isolated development environment

- Avoid affecting production data

Then run:

npx ampx sandbox

This command:

1. Creates/updates a **personal cloud sandbox** in AWS (with its own database, auth, etc.)

2. Watches for backend code changes in the `amplify/` folder

3. Automatically updates `amplify_outputs.json` to point to your sandbox

4. Keeps running until you stop it (Ctrl+C)

Then in a **separate terminal**, run:

npm run dev

Key Points

- amplify_outputs.json` determines which backend you're connected to

- Sandbox is a real AWS environment, not local - it deploys lightweight versions of your resources

- You can have both running: sandbox in one terminal, Next.js dev server in another

- Sandbox environments are temporary - they're meant for development

- Each developer can have their own sandbox without conflicts

Recommended Workflow

For frontend-only changes: Just `npm run dev`

For backend changes:

1. Terminal 1: `npx ampx sandbox` (keep it running)

2. Terminal 2: `npm run dev`