- Newest
- Most votes
- Most comments
To resolve the "not authorized to perform: ec2:DescribeInstances" error, you need to update the IAM permissions for the Lambda function's execution role. The error message indicates that the current role (SecurityHubTopIssuesReport-role-1j5t9plr) does not have the necessary permissions to perform the ec2:DescribeInstances action.
Here's how you can resolve this issue:
-
Open the IAM console in AWS.
-
Locate the role associated with your Lambda function (SecurityHubTopIssuesReport-role-1j5t9plr).
-
In the Permissions tab for this role, you need to add a policy that allows the ec2:DescribeInstances action. You can either edit an existing policy or create a new one.
-
If creating a new policy, you can use a policy similar to this:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "ec2:DescribeInstances", "Resource": "*" } ] }
-
After adding or updating the policy, save the changes.
-
Redeploy your Lambda function to ensure it picks up the new permissions.
If you want to limit the scope of the permissions, you can replace the "*" in the "Resource" field with specific ARNs of the EC2 instances you want to describe.
Remember, it's a best practice to follow the principle of least privilege and only grant the minimum permissions necessary for your function to operate.
If you continue to experience issues after updating the policy, you may want to use the AWS CLI command "aws sts get-caller-identity" to verify that your Lambda function is using the correct role, and double-check that the policy has been correctly applied and saved.
If the problem persists, you might want to check if there are any permission boundaries or service control policies in place that could be restricting access, as these can override identity-based policies.
Sources
Resolve IAM permission errors in CloudFormation | AWS re:Post
AWS was not able to validate the provided access credentials | AWS re:Post
Troubleshoot EC2 instance profile errors for IAM roles | AWS re:Post
Relevant content
- asked 10 months ago
- AWS OFFICIALUpdated 8 months ago
