CloudWatch Alarms is not authorized to perform: lambda:InvokeFunction on the resource because because no resource-based policy allows the lambda:InvokeFunction action

0

Hi,

I'm need to run a fargate task from CloudWatch when a specific alarm is fired. To to that I'm trying to call a lambda function that will run a fargate task. The lambda functiont runs fine in test mode, but when it's called from CloudWatch alarm I see the following error in alarm history:

  • CloudWatch Alarms is not authorized to perform: lambda:InvokeFunction on the resource because because no resource-based policy allows the lambda:InvokeFunction action.*

What I need to do to solve this problem? Thanks!

2개 답변
4

Just adding to what has been mentioned here earlier. First you need to add resource policy to your target lambda function through AWS CLI, catch here is, you can't add resource policy for Cloudwatch Alam through UI unlike other sources such as SNS, SQS etc, so you'll have to add resource policy through AWS CLI as mentioned in AWS Documentation:

aws lambda add-permission \
--function-name my-function-name \
--statement-id AlarmAction \
--action 'lambda:InvokeFunction' \
--principal lambda.alarms.cloudwatch.amazonaws.com \
--source-account 111122223333 \
--source-arn arn:aws:cloudwatch:us-east-1:111122223333:alarm:alarm-name

Once you add this to your target lambda function, CloudWatch Alarm should be able to invoke your lambda function.

Enter image description here

Reference Doc: Using Amazon CloudWatch alarms

profile pictureAWS
전문가
답변함 3달 전
2

That error is telling you that the cloudwatch service does not have permission to invoke the lambda. The easiest way is update the resource policy to allow cloudwatch to invoke the service. [1]

If you provide a bit more details on what you are looking to build, we may be able to offer a more detailed answer or recommend patterns that are resilient.

[1] https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html#alarms-and-actions-Lambda : Using Amazon CloudWatch alarms - Lambda alarm actions

profile pictureAWS
답변함 3달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠