Hi I have a cloudformation stack which creates a couple of ec2 instances. And I'm planing to use aws lambda to ssh into those ec2 instance to manage them.
I need to provide my aws lambda function with the ip address of those ec2 instance. I need to delete the stack and re-run for testing purpose. So the instances' ip address are different every time when I re-run the cloudformation stack. I can't hardcode or set those ip address as environment variable for my aws lambda function.
The stack's name will be the same. And I set up the cloudformation stack to output the ip address of each ec2 instance. Thus, I think I can use the stack name as the reference to let my aws lambda function to access and load its output to achieve this goal.
I found a similar post: AWS lambda read parameter or outputs from CloudFormation saying this.
But he only described "Grant your Lambda function cloudformation:DescribeStacks permission to read outputs of your CloudFormation stack and load this output in your code at runtime".
Could someone provide me more specific steps about how to load in aws lambda? I can't find any aws docs about this so could someone please help me?
Thanks a lot!