Open bogris opened 1 month ago
Hey @bogris, thank you for taking the time in filing this issue with the details. Marking this as feature request to access resource context. Additionally, this may help elevate some the circular dependency issues being tracked on https://github.com/aws-amplify/amplify-backend/issues/1850
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.