Amazon API Gateway - Not authorized error as admin user when trying to get all api keys programmatically or using postman - amazon-web-services

I have been struggling all day, trying to to programmatically create/delete/get apikeys created in the amazon api gateway UI. The weird thing is I am getting a forbidden error even when I got all permissions an account in aws can get.
I am passing everything correctly, the accessKey, secretKey, region and service name from postman to the following url: https://apigateway.eu-west-1.amazonaws.com/apikeys [GET REQUEST] and nothing worked so far.
I've been given admin permissions for the entire aws account and no change. In the aws UI I get do all the actions I'm trying to do from postman/programmatically.

Related

Getting "oversizeFields":["REQUEST_BODY"] on AWS WAF logs when trying to upload document to API POST endpoint

Iam getting 504 error on my app when trying to upload a document(nearly 10mb) to API POST endpoint.
I've already tried creating custom rules to allow the URI path of the API and also created condition within a size limit for body as well as http method.
The WAF log is showing ALLOW for the request but document is not getting uploaded and getting error.
when I disassociate the API from WAF, everything is working fine.

Getting error while invoking API using AWS Lambda. (AWS Lambda + AWS API Gateway+ Postman)

I get an error while invoking the AWS SageMaker endpoint API from a Lambda function. When I call this using Postman, I am getting an error like:
{
"errorMessage": "module initialization error"
}
Just to make it clear, you can't call SageMaker endpoints directly using PostMan (even if it is, it would not be straightforward).
You may need to use AWS SDK (i.e. boto) for that.
Ref : https://aws.amazon.com/blogs/machine-learning/call-an-amazon-sagemaker-model-endpoint-using-amazon-api-gateway-and-aws-lambda/
What I would suggest is to create a small HTTP server with Flask and use the AWS SDK (Boto) to call the endpoint. Then you can call your Flask endpoint using PostMan.
We recommend using AWS SDK to invoke your endpoint. AWS SDK clients handle the serialization for you as well as request signing, etc. It would be really hard to get it right manually with postman.
We have the SDK client available in many languages, including Java, Python, JS, etc.
https://docs.aws.amazon.com/sagemaker/latest/dg/API_runtime_InvokeEndpoint.html#API_runtime_InvokeEndpoint_SeeAlso
Next time please include more details in your question. eg. POST request data, Headers etc.
Anyways, to help you out in calling Sagemaker endpoint using Postman -
In 'Authorization' tab, select type as 'AWS Signature'.
Enter your Access and Secret key of the IAM user which has permission to Sagemaker resources.
Enter the AWS region. eg.us-east-1
Enter 'Service Name' as 'sagemaker'
Select the right content type. Some ML algorithms only accept 'text/csv'.
Select request type as 'POST'
Enter the Sagemaker Invocation url. eg:'https://runtime.sagemaker.us-east-1.amazonaws.com/endpoints/xgboost-xxxx-xx-xx-xx-xx-xx-xxx/invocations'
Try it out and let me know if you have any issues.
Here is how your Postman should look -

How do I authorize CognitoIdentityCredentials for my API?

I have a Serverless backend that implements AWS_IAM authorizer using the serverless framework.
My client is a React application. I am using AWS Cognito to authenticate users and AWS Federated Identities to retrieve temporary credentials for the user.
The user is assuming an IAM Role that has APIGatewayInvokeFullAccess policy attached. I then sign my request using aws4 and make my request using Axios.
To my understanding, I am doing everything right. But, I am still receiving a 403 error on my client request. I even logged the tokens that are being retrieved to the console and used those tokens in postman. When I use postman, the error message says "The security token included in the request is invalid". I have read every doc and tried every possible solution, but I am still unable to debug this error. Any help at all would be incredible.
I am following this guide for the application flow.

AWS API Gateway + Lambda: No Auth Header -> Error Message; Auth Header -> No Response

I'm trying to set up a very basic API, before taking the additional step of integrating Cognito. Testing the API endpoint within the AWS console works fine. However, I'm not able to get things working in Postman.
In API Gateway, I've connected an endpoint with no parameters to a Lambda function. The Lambda function returns a hard-coded, static JavaScript object. Clicking the test button here works as expected.
In the Method Execution screen, I've selected AWS_IAM for authorization and don't require an API key.
In IAM I created a user named postman and attached the AmazonAPIGatewayInvokeFullAccess policy (covering all ExecuteAPI resources, for now).
The API seems to be published correctly, since it complains when I try to access it without an Authorization header.
But when I use the AWS Signature Authoriztion type and enter postman's AccessKey and SecretKey, I get no response at all.
I'm trying to find access logs to debug, but I'm new to this part of AWS and haven't found anything yet... What am I missing? Thanks in advance.

How to make request to AWS API Gateway from Postman using temporary credentials

I followed the steps mentioned in this repo and created an API for users and pets.
I am able to get the temporary credentials after login and signup.
But for "/pets" (both POST and GET), I am getting "Internal Server Error".
I tested the functionality of pets API from AWS API Gateway test interface and was able to create and list pets.
Want to know about the parameters and headers that need to be set in Postman for an authorized request.
Based on the error message ("Execution failed due to configuration error: Invalid permissions on Lambda function".), it seems policy attached to your Lambda function is not correct. Make sure you have proper policies configured on Lambda