amplify-hosting
amplify-hosting copied to clipboard
PR Preview env can't be created with env variables
Before opening, please confirm:
- [X] I have checked to see if my question is addressed in the FAQ.
- [X] I have searched for duplicate or closed issues.
- [X] I have read the guide for submitting bug reports.
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
App Id
d3pwsdrqmxpguf
Region
eu-west-2
Amplify Hosting feature
Backend builds, Environment variables
Describe the bug
I'm using the amplifyPush --simple command to build/create my backend env for Preview environments.
The build fails because of env variables and --yes flag - known issue
CREATE_FAILED functiongetOpenViduToken AWS::CloudFormation::Stack Tue Apr 19 2022 09:25:45 GMT+0000 (Coordinated Universal Time) Parameters: [openviduUrl] must have values
However, according to documentation to fix the issue you have to checkout the env and push it manually from local machine.
- I copy the command from Amplify console
amplify pull --appId d3pwsdrqmxpguf --envName prcjb - an empty env is pulled from cloud
- I can't update the function nor push it back to cloud (because there're no categories)
Expected behavior
I'd be great if the amplifyPush --simple (amplify push -y) command did carry over the env variables and secrets from target or current env without prompting).
Also I don't know why the failing env is empty why I pull it. Without it there's no way how to fix the env variables.
Reproduction steps
- Create lambda function that uses some env variable.
- Define value for current environment and push to cloud - check if value is included in
team-provider-info.json - Setup PR Previews for current branch in Amplify Console - Create new backend environment for every Pull Request
- Create new branch from current branch
- Make some changes, add dummy file etc.
- Push changes to remote and create PR for the new branch.
- PR env build should fail - try to pull the env from cloud.
Build Settings
version: 1
backend:
phases:
build:
commands:
- amplifyPush -e "${AWS_BRANCH}" --simple
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build-prod
artifacts:
baseDirectory: dist/stardio-pro
files:
- "**/*"
cache:
paths:
- node_modules/**/*
Additional information
No response
I'd also be good if the parameter -e "${AWS_BRANCH}" was actually respected and used for the new env name. Right now there's USER_BRANCH variable for each PR env that's overriding the -e input.
I know amplify env name has a strict naming conditions (no dashes, no uppercase, 10 chars) but that can be stripped out from the input.
I'd make more sense to have the envs named after git branches or PR numbers.
Hi @vojtech-simko 👋🏽 thanks for providing details and reproduction steps. We're taking a look into this issue.
any update on this ??
I guess that for now as soon we have environment variables or secrets on lambda functions the preview won't work? 😢 It would be great to understand if this is something the AWS team has ideas on how to fix it, although seems like a pretty heavy lift