Figure out a scalable way to reference backend artefact IDs into custom lambda code #2065
Labels
backend-cli
Issue is related to Amplify backend CLI
feature-request
New feature or request
sandbox
Related to the sandbox experience
Environment information
Describe the feature
get in code amplify generated resource ids like:
Use case
When writing custom lambda code, a lot of time we need direct access to resources in order to accomplish advanced tasks.
In my current iteration, I managed to encapsulate this logic in a way that it works in multiple branches, including sandboxes even in the same account.
I took the ideea behind the backend "secret" logic.
I defiend a custom type to give me the published "short names" for the ids.
i create the ssm params:
and in the code, I have a helper function that queries ssm:
in order for the function to know what to get, i add 2 env vars to the handler:
and now in the source code i get a types function that returns my info:
I tried to use the amplify JSON in the function Env param to define the list of available params, but I don;t have acces to that without a circular dependency.
This is where you guys can complete the loop in my mind.
I think this can be an extension of the way you publish GRAPQL params for the functions that are auth in the schema to query it.
to make this work, I also published 2 env params before starting my sandbox. This can also be formalised so that sandboxes can behave more like branches to adhere to a formalised naming convention for ssm params.
this is my package.json where I start the sandbox:
I did not put in here all the imports and authorizations to get params etc. I tried to stick to the core code.
The text was updated successfully, but these errors were encountered: