Netlify prod with --alias does not seem to import environment variables

I have database credentials stored as environment variables for a lambda functions server.

If I run netlify prod I get a temporary URL that my client can connect to and database transactions work. However, if I use the --alias option, those credentials are not picked up.

The vars are all set up for Deploy Previews; is there something special about aliased previews I need to know about?

link to config:

I’m assuming you mean you’re running netlify deploy --build? There’s no netlify prod that I’m aware of. Have you tried setting the variables for branch deploys when using the alias flag?

Sorry, should have read netlify deploy. To clarify:

netlify deploy

Creates a temporary site with a hash prefix. Environment variables that contain credentials are accessible.

netlify deploy --alias foo

Creates a site with a “foo” prefix, but it’s apparently not getting the site’s env vars because I see credential errors.

Did you try what I suggested?

I just tried setting the variables for branch deploy and it works. I don’t understand why that is necessary for alias prefixes but not for auto-generated hash prefixes.

From docs:

“…If you created a deploy using the Netlify CLI’s --alias flag, be aware that this isn’t a branch deploy and isn’t supported for Split Testing.”

I’m aware what the docs say, I was simply asking you to try. Since it’s working, there’s some kind of a bug at play, which I’ll file for the devs. However, I won’t expect any activity on it any time soon as it’s a low priority issue.