How to craft a custom AWS CloudWatch Read-Only policy tailored for a specific log group, including permissions for Logs Insights?

0

I was use this code it's working in the log groups dashboard but the Logs insights dashboard i getting some error i was attached below code and screen shoot.

The code : { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "logs:DescribeLogGroups", "Resource": "" }, { "Effect": "Allow", "Action": [ "logs:DescribeLogStreams", "logs:GetLogEvents", "logs:StartQuery", "logs:StopQuery", "logs:GetQueryResults", "logs:GetLogGroupFields" ], "Resource": "arn:aws:logs:ap-south-1:744096931876:log-group:/aws/lambda/Password-generate:" }, { "Effect": "Allow", "Action": [ "cloudwatch:GetMetricData", "cloudwatch:GetMetricStatistics", "cloudwatch:ListMetrics" ], "Resource": "*" } ] }

Enter image description here

KARTHIK
asked 9 months ago261 views
1 Answer
1
Accepted Answer

Hello.

I modified the policy as follows.
I have included all the policies used by CloudWatch Logs Insights, so it will probably work.
https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncloudwatchlogs.html

{ 
    "Version": "2012-10-17", 
    "Statement": [ 
        { 
            "Effect": "Allow", 
            "Action": [
                "logs:DescribeLogGroups",
                "logs:DescribeQueryDefinitions",
                "logs:DescribeQueries"
                "logs:GetLogEvents", 
                "logs:StopQuery", 
            ], 
            "Resource": "*" 
        }, 
        { 
            "Effect": "Allow", 
            "Action": [ 
                "logs:DescribeLogStreams", 
                "logs:StartQuery", 
                "logs:GetQueryResults", 
                "logs:GetLogGroupFields" 
            ], 
            "Resource": "arn:aws:logs:ap-south-1:744096931876:log-group:/aws/lambda/Password-generate:*" 
        }, 
        { 
            "Effect": "Allow", 
            "Action": [ 
                "cloudwatch:GetMetricData", 
                "cloudwatch:GetMetricStatistics", 
                "cloudwatch:ListMetrics" 
            ], 
            "Resource": "*" 
        } 
    ] 
}
profile picture
EXPERT
answered 9 months ago
profile pictureAWS
EXPERT
reviewed 9 months ago
profile pictureAWS
EXPERT
reviewed 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions