0

Currently I have a lambda function that is created in a different Terrraform module. I need to create a Cloudwatch Logs trigger for that lambda function from a serperate repository. So far, I don't see any Terraform resources (that I know of) to do this. I have also looked into using Boto3 in local-exec through terraform. This doesn't look possible either. Are there any ways that I am missing, that can complete this using Terraform, AWS_CLI, or python.

Thanks

1 Answer 1

1

You need to define a aws_cloudwatch_log_subscription_filter with the Lambda function's ARN as the destination value. You could pass the Lambda function's ARN into the CloudWatch module, or you could have it lookup the function by name to get the ARN. You'll probably also need to create an aws_lambda_permission resource to give CloudWatch permission to invoke the Lambda function.

Sign up to request clarification or add additional context in comments.

3 Comments

How would I connect that to the specific logs in Cloudwatch from that Lambda function? I have one lambda function that needs the trigger from the cloudwatch logs so that it can forward those logs. The cloudwatch logs are ones from a seperate lambda function execution.
I just updated my answer, I had a typo in there with the wrong terraform resource name. The aws_cloudwatch_log_subscription_filter is the thing that creates a trigger to stream CloudWatch logs to a Lambda function. That resource is where you specify the log group, and the Lambda function the logs should stream to.
This ended up working. Thanks for the help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.