Closed duckbytes closed 6 months ago
Hey @duckbytes :wave: thanks for raising this! While this approach is not officially supported for adding environment variables, you can get away with manually modifying amplify/team-provider-info.json
and specifying key value pairs for your Function env vars. These will then be hydrated on init/checkout/pull and uploaded to SSM, which should resolve this issue.
Otherwise you can use amplify update function
to CRUD env vars/secrets for your Functions https://docs.amplify.aws/react/build-a-backend/functions/environment-variables/
Thanks @josefaidt .
Originally I had not committed team-provider-info.json because the project is open source and it only seemed to contain data about my development environment. I'm also not working in a team.
Is using amplify/backend/function/<something>/parameters.json
no longer a supported method?
Hey @duckbytes it is not an officially-supported method, but likely worked prior to the change of lifting those env-specific parameters to SSM Parameter Store (around CLI v9/v10). Those parameters/env vars are written to team-provider-info.json
per env, and hydrated to backend-config.json
as SSM Parameters on env checkout/pull. Those then flow to the Function on synth.
Despite the name, team-provider-info.json
holds information relevant to each environment. If this file does not exist or we create a new env the CLI should prompt for env var values for each Function.
Hey @josefaidt. How would you recommend I maintain the team-provider-info.json
file when working with multiple deployments? At the moment I have the Amplify console set to automatically create a deployment on new branches that match production/**
.
What this meant is that I could create a new branch from master, push it up and the new deployment would be created for me without any interventions.
It sounds like now I will need to generate a new team-provider-info.json
file every time I create a new deployment, which I guess means creating a new environment manually to put in those values, and then connecting the new environment to a branch afterwards. Or can I have one version of the file that is common to all branches and it'll pull those values? It seems like there is a lot of environment specific data held in that file, but those function parameters don't change between each deployment.
I'm just wondering how much of this I can automate, since it was working so well before.
@duckbytes if Amplify CLI is unable to find values from team-provider-info.json
file, it will fetch the values from SSM parameter store. Refer to the documentation providing this information.
on a new branch creation you should be able to run a script on hosting preBuild phase that creates the SSM parameters for the branch as Amplify CLI tries to retrieve parameters with format /amplify/<appId>/<environment-name>/AMPLIFY_<category-name>_<resource-name>_<parameter-name>
Thanks @ykethan
In the end I've hard coded the values into the lambda function, since they aren't secrets and don't often change between deployments this seemed like the simplest solution.
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.
How did you install the Amplify CLI?
No response
If applicable, what version of Node.js are you using?
No response
Amplify CLI Version
12.10.1
What operating system are you using?
Linux
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No manual changes made.
Describe the bug
I have several lambda functions with parameters provided in parameters.json. Parameters.json is in the root of the function, e.g.
amplify/backend/function/plateletAddNewTenant/parameters.json
and contains data like:In the past this is how I've provided environment variables to functions. Existing deployments and new deployments have worked with this setup.
Recently I updated my lambda functions to node 18 and also updates the build settings to use the latest image and CLI version:
However I receive this output on the Amplify console.
I'm triggering these builds with pushes to github.
This is my amplify.yml:
I am not committing team-provier-info.json and would rather these values are taken from the parameters.json file if that's possible.
Expected behavior
I would expect building to use the values in parameters.json for functions instead of saying they are missing.
Reproduction steps
Project Identifier
No response
Log output
Additional information
No response
Before submitting, please confirm: