I'm trying to write a CloudFormation template that subscribes a Lambda function to a CloudWatch Logs LogGroup. This Lambda function should then parse the logs and put them in to an Amazon ES cluster.
The subscription etc. is all working nicely, but the one bit I can't get my head around is how to pass in the Amazon ES cluster endpoint to the Lambda function. The template that AWS provides when you walk through the console includes a line:
var endpoint = 'my-aws-es-endpoint.amazonaws.com';
I'll obviously need to update this each time the CloudFormation template runs, as each time I'll get a different cluster with a different end point. I don't want to manually update this, but want to be able to use CloudFormation functions like 'Fn::GetAtt' to get the end point and pass it in to Lambda. I just can't figure out how.
You can pass ES cluster endpoint to Lambda function as an environment variable. Here is a snippet of CloudFormation template for such function: