Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions kits/storage-resize-images/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ loads them at deploy time and prompts for any required values that are missing.
| Field | Env var | Required | Default | Description |
| ---------------------- | ------------------------ | -------- | ---------------------- | ------------------------------------------------------------------------------------------ |
| `bucketRegion` | `BUCKET_REGION` | yes | (prompted) | Cloud Storage bucket location; also places the function |
| (none) | `FUNCTION_DEFAULT_REGION` | yes | (prompted) | Function region when `BUCKET_REGION` is empty ([details](#bucket_region-decides-where-the-function-runs)) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Marking FUNCTION_DEFAULT_REGION as Required: yes and Default: (prompted) is misleading. Since it is not defined as a parameter in config.ts, the Firebase CLI will not prompt for it during a regular deploy if it is missing from .env. Additionally, it is only used as a fallback when BUCKET_REGION is empty, so it is not strictly required for the kit to function.

Suggested change
| (none) | `FUNCTION_DEFAULT_REGION` | yes | (prompted) | Function region when `BUCKET_REGION` is empty ([details](#bucket_region-decides-where-the-function-runs)) |
| (none) | <code>FUNCTION_DEFAULT_REGION</code> | no | (empty) | Function region when <code>BUCKET_REGION</code> is empty ([details](#bucket_region-decides-where-the-function-runs)) |

| `bucket` | `IMG_BUCKET` | no | default Storage bucket | Bucket to watch |
| `sizes` | `IMG_SIZES` | no | `200x200` | Comma-separated resize sizes |
| `deleteOriginal` | `DELETE_ORIGINAL_FILE` | no | `false` | Delete original after resize; omitted in code means `on_success` (see note below) |
Expand Down Expand Up @@ -282,21 +283,20 @@ places the function correctly. If you instead run `firebase deploy` with the
value still missing from `.env`, the prompt comes after discovery has already
chosen a region, so your answer only takes effect on the following deploy.

`firebase ext:migrate` also writes `FUNCTION_DEFAULT_REGION` to your `.env`,
recording where the extension's function ran. Nothing reads it: placement comes
from `BUCKET_REGION` alone, so if the two disagree your next deploy moves the
Projects created by `firebase functions:kits:install` or `firebase ext:migrate`
also require `FUNCTION_DEFAULT_REGION` in `.env`. `ext:migrate` sets it to the
region the extension's function ran in. A non-empty `BUCKET_REGION` overrides
it, so it only takes effect when `BUCKET_REGION` is empty.

With an explicit empty `BUCKET_REGION=` line in `.env`, the function deploys to
`FUNCTION_DEFAULT_REGION`, which must then match the bucket. If both are empty,
the deploy fails with `A function in region cannot listen to a bucket in
region <region>`. Omitting the `BUCKET_REGION` line is not the same as an empty
one: a non-interactive deploy fails with `In non-interactive mode but have no
value for the following environment variables: BUCKET_REGION`. Changing an
existing instance's region, through either variable, deletes and recreates the
function.

With an explicit empty `BUCKET_REGION=` line in `.env`, the function declares no
region and the Firebase CLI resolves one at deploy time: it keeps the region it
is already deployed in, and on a first deploy lands in `us-central1` unless you
set the `FIREBASE_FUNCTIONS_DEFAULT_REGION` environment variable when running
`firebase deploy`. Careful with that variable: it applies to every no-region
function in the deploy, not just this kit. Omitting the line is not the same as
an empty one: a non-interactive deploy fails with `In non-interactive mode but
have no value for the following environment variables: BUCKET_REGION`. Note that
changing an existing instance's region deletes and recreates the function.

## API surface

- **Main entry** (`@firebase-function-kits/storage-resize-images`): exports
Expand Down
Loading