I am trying to run AWS Lambda function to fetch status of my instances. But I got the below error.
Response:
{
"errorMessage": "An error occurred (UnauthorizedOperation) when calling the DescribeInstanceStatus operation: You are not authorized to perform this operation.",
"errorType": "ClientError",
"stackTrace": [
" File \"/var/task/lambda_function.py\", line 7, in lambda_handler\n status = client.describe_instance_status(IncludeAllInstances = True)\n",
" File \"/var/runtime/botocore/client.py\", line 272, in _api_call\n return self._make_api_call(operation_name, kwargs)\n",
" File \"/var/runtime/botocore/client.py\", line 576, in _make_api_call\n raise error_class(parsed_response, operation_name)\n"
]
}
Request ID:
"6c94f062-dab7-421e-9d58-e0967741abe1"
Function Logs:
START RequestId: 6c94f062-dab7-421e-9d58-e0967741abe1 Version: $LATEST
[ERROR] ClientError: An error occurred (UnauthorizedOperation) when calling the DescribeInstanceStatus operation: You are not authorized to perform this operation.
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 7, in lambda_handler
status = client.describe_instance_status(IncludeAllInstances = True)
File "/var/runtime/botocore/client.py", line 272, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/var/runtime/botocore/client.py", line 576, in _make_api_call
raise error_class(parsed_response, operation_name)END RequestId: 6c94f062-dab7-421e-9d58-e0967741abe1
REPORT RequestId: 6c94f062-dab7-421e-9d58-e0967741abe1 Duration: 1683.86 ms Billed Duration: 1700 ms Memory Size: 128 MB Max Memory Used: 79 MB Init Duration: 243.28 ms
How can I solve this error?
Thank You