amplify-backend icon indicating copy to clipboard operation
amplify-backend copied to clipboard

Implement Real-Time Environment Variable Updates for Amplify Sandbox

Open amixedcolor opened this issue 9 months ago • 0 comments

Environment information

System:
  OS: macOS 15.3
  CPU: (8) arm64 Apple M2
  Memory: 142.13 MB / 16.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 20.9.0 - /usr/local/bin/node
  Yarn: 1.22.19 - /usr/local/bin/yarn
  npm: 10.1.0 - /usr/local/bin/npm
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/auth-construct: 1.6.0
  @aws-amplify/backend: 1.14.1
  @aws-amplify/backend-ai: Not Found
  @aws-amplify/backend-auth: 1.5.0
  @aws-amplify/backend-cli: 1.4.11
  @aws-amplify/backend-data: 1.4.0
  @aws-amplify/backend-deployer: 1.1.18
  @aws-amplify/backend-function: 1.12.2
  @aws-amplify/backend-output-schemas: 1.4.0
  @aws-amplify/backend-output-storage: 1.1.4
  @aws-amplify/backend-secret: 1.1.6
  @aws-amplify/backend-storage: 1.2.4
  @aws-amplify/cli-core: 1.3.0
  @aws-amplify/client-config: 1.5.7
  @aws-amplify/data-construct: 1.15.0
  @aws-amplify/data-schema: 1.18.0
  @aws-amplify/deployed-backend-client: 1.5.1
  @aws-amplify/form-generator: 1.0.4
  @aws-amplify/model-generator: 1.0.12
  @aws-amplify/platform-core: 1.6.3
  @aws-amplify/plugin-types: 1.8.0
  @aws-amplify/sandbox: 1.2.11
  @aws-amplify/schema-generator: 1.2.7
  aws-amplify: 6.13.2
  aws-cdk: 2.1001.0
  aws-cdk-lib: 2.181.0
  typescript: 5.7.3
No AWS environment variables
No CDK environment variables

Describe the feature

This feature request proposes implementing real-time updates for environment variables in the Amplify Sandbox environment. Currently, when using the command npx dotenvx run --env-file=.env.local -- ampx sandbox, environment variables are only loaded at initial execution. Subsequent changes to the .env file require manually stopping and restarting the sandbox to take effect.

The proposed enhancement would:

  1. Continuously monitor the .env file for changes.
  2. Automatically update the sandbox environment with new or modified variables without requiring a restart.
  3. Provide immediate reflection of environment variable changes in the running sandbox.

Implementation could involve integrating a file watcher for the .env file and a mechanism to safely update the sandbox's runtime environment without disrupting ongoing processes.

Use case

This feature would significantly improve the development workflow in several ways:

  1. Eliminating the need for manual sandbox restarts after .env file changes: Developers often need to adjust environment variables during development. Currently, each change requires stopping and restarting the sandbox, which interrupts the development flow.
  2. Enabling rapid iteration and testing of different environment configurations: With real-time updates, developers can quickly test various configurations without the delay of restarting the sandbox, speeding up the development and debugging process.
  3. Enhancing overall developer productivity: This feature is especially beneficial in scenarios requiring frequent environment variable adjustments. It allows developers to make changes on the fly and see immediate results, reducing downtime and improving efficiency.
  4. Streamlining local development processes: By aligning the local development experience more closely with the dynamic nature of cloud environments, this feature helps create a more seamless workflow between local and deployed environments.

amixedcolor avatar Feb 28 '25 05:02 amixedcolor