Skip to content
Advertisement

AWS Lambda function with placeholders

I am working on AWS Lambda function for my python function. I have a python function that calls an IAM policy form a file and populates it using the function. This is my function, name of the file is template_utils.py”:

JavaScript

This is my policy file named “meta_templates.py”

JavaScript

I want to create a lambda handler that does the same thing with the function “template_utils.py”.I’m new to this not sure how to proceed with it.I am getting this error:

JavaScript

Advertisement

Answer

This should work, providing that you are passing the correct data in the event.

JavaScript

This example uses only Python (no third party libraries) it’s not the most elegant solution but its simple. If you want to create additional replacements, just add some additional tags “{{some_text}}” and replace it as shown below.

Here is a test event that works from the lambda console. Test Event

And here is an example of a working invocation working invocation returning json

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement