aws / aws/apprunner-roadmap

Environment variables defined in the web console are not available during build phase

Open
#182 1 comment 21 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
301
Forks
15
PR merge metrics
No merged PRs in 30d

Description

We would like to run migrations during the build phase and would need the database credentials for that. However, environment variables defined in the web console don't seem to be available during the build phase.

[Here's a minimal reproduction of the issue](https://github.com/TuureKaunisto/app-runner-minimal/tree/env-during-build)

Runtime: Nodejs 16
Port: 8080
Build command: npm run build
Start command: npm run start

Environment variables:
SUPER_SECRET_MIGRATION_ENV_VARIABLE: foo

Expected output:
```
Build:
[Build] > app-runner-minimal@1.0.0 migrate
[Build] > ./migrate.sh build
[Build] Running migrate with the following arguments: "build"
[Build] Secret environment variable required for migrations: "foo"

Application:
> app-runner-minimal@1.0.0 start
> npm run migrate start && node index.js
> app-runner-minimal@1.0.0 migrate
> ./migrate.sh start
Running migrate with the following arguments: "start"
Secret environment variable required for migrations: "foo"
```

Got output:
```
Build:
[Build] > app-runner-minimal@1.0.0 migrate
[Build] > ./migrate.sh build
[Build] Running migrate with the following arguments: "build"
[Build] Secret environment variable required for migrations: ""

Application:
> app-runner-minimal@1.0.0 start
> npm run migrate start && node index.js
> app-runner-minimal@1.0.0 migrate
> ./migrate.sh start
Running migrate with the following arguments: "start"
Secret environment variable required for migrations: "foo"
```

We ended up working around this issue by moving the migration to be run during the start command, which of course is not ideal.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.