Unable to hit AWS SQS api from postman - postman

I am trying to create a queue in SQS by hitting at their api using Postman. I have already created IAM account and generated the key corresponding to the user. Still, I am getting the access denied error. following is the post request that I am trying to hit
https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue/
?Action=CreateQueue
&QueueName=MyQueue
&Attribute.1.Name=DelaySeconds
&Attribute.1.Value=45
&Expires=2020-12-20T22%3A52%3A43PST
&Version=2012-11-05
&AUTHPARAMS
I have entered a proper combination of accessKey and secretKey and all other required field. I am getting the error
<AccessDeniedException>
<Message>Unable to determine service/operation name to be
authorized</Message>
</AccessDeniedException>
Their is no way to make the queue public on SQS. Same response is coming on trying any different method. Any leads will be helpful. Thanks in advance

I think you should remove "MyQueue/" from URL. The right code should like the following:
https://sqs.us-east-2.amazonaws.com/
?Action=CreateQueue
&QueueName=MyQueue
&Attribute.1.Name=VisibilityTimeout
&Attribute.1.Value=40
&Expires=2020-10-18T22%3A52%3A43PST
&Version=2012-11-05
&AUTHPARAMS
For more info:
https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_CreateQueue.html

Related

Mapping request when Wrapping graphQL(appsync) with GET REST API using Amazon api gateway

I want to create a GET endpoint as a wrapper over an existing App Sync api for a specific query using AWS Service integration in API Gateway.
Eg. /employee/{id}/residenceCountry
In the mapping template I put the query as
{"query":"query MyQuery {getEmployeeDetails(id: \"$method.request.path.id\") {address {country}}}"}
However, I am getting a 500 Internal server error with no proper logs.
When I create a POST endpoint such that I pass the above body as request body to my rest api with passthrough, it works.
In the execution logs I see the exact same content for Endpoint request body after transformations:
In order to get the proper logs I tried getting $context.error.message and $context.integrationErrorMessage but I do not get any details.
Could someone please tell what I could be doing wrong or how to debug this better?
It turned out to be a very silly mistake of selecting App Sync as AWS Service in GET vs App Sync Data Plane in POST. It was only made apparent via another set of eyes. Thanks to my colleague Albert Hoxha.

AWS Upload file to S3 REST API - Missing required header for this request: x-amz-content-sha256

Unfortunately i cannot use AWS SDK and i must use REST API AWS services(i am working with Flutter WEB).
So i start to do research on aws docs and this is what i did:
Create bucket.
make all permission to be public(for test only)
open access point
Then at the postman i am using at "Auth" aws signature and added current keys,
except session token(my bucket is open and i understood that i dont need it, if i am mistaking pls correct me).
when i am sending the request i am getting an error:
Missing required header for this request: x-amz-content-sha256
Here is attachment images:
AWS Signautre
Body Request
Error message
Just ran into this issue too - the Service Name must be 's3' vs 'S3'.
advanced authorization settings
According to the AWS documentation, you need to send the x-amz-content-sha256 header in the request:
The x-amz-content-sha256 header is required for all AWS Signature Version 4 requests. It provides a hash of the request payload. If there is no payload, you must provide the hash of an empty string.
Seems like Postman is not adding it for some reason. You should check the Headers and add manually then.
try replacing S3 with s3 for the service name.
I too faced this issue and after adding session token parameter it got resolved. Postman has the provision to generate the below parameters,
X-Amz-Content-Sha256
Authorization
x-amz-security-token
X-Amz-Date

Amazon Web Service Recognition error in POSTMAN

I am IAM user and trying to hit API RekognitionService.CreateCOllection for the testing in POSTMAN, but getting this
<InvalidSignatureException>
<Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.</Message>
</InvalidSignatureException>
My header request is
https://rekognition.us-east-2.amazonaws.com/
Content-Type:application/x-www-form-urlencoded
Host:rekognition.us-east-2.amazonaws.com
Accept-Encoding:identity
X-Amz-Target:RekognitionService.CreateCollections
Content-Length:30
Authorization:AWS4-HMAC-SHA256 Credential=AKIAJCWZHWIIW7BH5HPA/20180202/us-east-2/rekognition/aws4_request, SignedHeaders=accept-encoding;content-length;content-type;host;x-amz-date;x-amz-target, Signature=847d47d4e323fed46020c9fb2ac32882a01edd6efa179ed241d36d038712469e
X-Amz-Date:20180202T121035Z
Content-Type:application/x-www-form-urlencoded
Though it works with same Access Key Id and Secret Key using CLI(Command Line Interface).
Can anyone help me to solve this problem.
First clear all your headers that you have manually added.
Use your Accesskey,SecretKey and service name as rekognition in AWS singature
Add your collectionId in body as raw type.
After updating your request header look like this
Add new header X-Amz-Target value as RekognitionService.CreateCollection and Content-Type as application/x-amz-json-1.1

Missing Authentication Token while accessing API Gateway?

I am trying to call a Lambda Function through AWS API Gateway.
When I mention Authentication type NONE it works fine but API become public and anyone with url can access my API.
To make API call secure, I am using Authentication type AWS_IAM and
also attached AmazonAPIGatewayInvokeFullAccess policy to my user but getting this error:
{ message: "Missing Authentication Token"}
I don't know what I am missing here.
I've lost some time for a silly reason:
When you create a stage, the link displayed does not contain the resource part of the URL:
API URL:
https://1111.execute-api.us-east-1.amazonaws.com/dev
API + RESOURCE URL
https://1111.execute-api.us-east-1.amazonaws.com/dev/get-list
The /get-list was missing
And of course, you need to check that the method configuration looks like this:
I think you are directly trying to access API link, this won't work because API is secured using IAM role and you must provide AWS authentication i.e Access key and Secret key.
Use the Postman Chrome extension to test your API:
http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-use-postman-to-call-api.html
I just had the same issue and it seems it also shows this message if the resource cannot be found.
In my case I had updated the API, but forgotten to redeploy. The issue was resolved after deploying the updated API to my stage.
Make sure you are clicking on the specific Resource first in the Stages tree, as that will populate a URL with the full path to the resource (rather than just the root path):
For other causes, see http://www.awslessons.com/2017/aws-api-gateway-missing-authentication-token/
Looks like (as of April 2019) AWS API Gateway throws this exception for a variety of reasons - mostly when you are hitting an endpoint that API Gateway is not able to reach, either because it is not deployed, or also in cases where that particular HTTP method is not supported.
I wish the gateway sends more appropriate error codes like HTTP 405 Method not supported or HTTP 404 not found, instead of a generic HTTP 403 Forbidden.
Found this in the docs:
If the AWS_IAM authorization were used, you would sign the request using the Signature Version 4 protocols.
Signing request with Signature Version 4
You can also generate an SDK for your API.
How to generate an SDK for an API in API Gateway
Once you've generated the SDK for the platform of your choice, step 6 mentions that if you're using AWS credentials, the request to the API will be signed:
To initialize the API Gateway-generated SDK with AWS credentials, use code similar to the following. If you use AWS credentials, all requests to the API will be signed. This means you must set the appropriate CORS Accept headers for each request:
var apigClient = apigClientFactory.newClient({
accessKey: 'ACCESS_KEY',
secretKey: 'SECRET_KEY',
});
I try all the above, if you did all steps in the above answers, and you not solve the problem, then:
on the left menu, hit the "Resources"
in the right to "Resources", hit the api method that you want to test, like "POST/GET etc)
hit the "ACTION" list (it's above to the API method in step 2
select "DEPLOY API" (please do it, even you already deploy yours api)
in "deployment stage" select "prod" or what ever you write in yours previous deploy (it will override yours previous deploy
hit deploy
I thing that because of, when I create the "METHOD REQUEST" (see step 2 how to go to this menu) , in "Authorization" I select "AWS_IAM"
after testing api, in aws test option, I try it in "postman"
then I understand the in "METHOD REQUEST" , in "Authorization", I should select "none"
I change it to none, but I thing the AWS, need to deploy it again, as I explain
Make sure you create Resource and then create method inside it. That was the issue for me. Thanks
In my case I missed adding '/' forward slash at the end of api.
Such a silly mistake.
https://le9dq5l9.execute-api.eu-west-1.amazonaws.com/v1/putdoctorinfo/
If you enable AWS_IAM authentication you must sign your request with AWS credentials using AWS Signature Version 4.
Note: signing into the AWS console does not automatically sign your browser's requests to your API.
sometimes this message shown when you are calling a wrong api
check your api endpoint
In my case it was quite a stupid thing.
I've get used that new entities are created using POST and it was failing with "Missing Authentication Token". I've missed that for some reason it was defined as PUT which is working fine.
This error mostly come when you call wrong api end point.
Check your api end point that you are calling and verify this on api gateway.
If you are using an API with endpoint of type PRIVATE, be sure of:
You are invoking the API from within your AWS account (example: from an EC2 instance created in your account)
Put necessary credential (access and secret keys) in the EC2 instance in route ~/.aws/credentials (this route is for linux instances) If IAM user use MFA aws_session_token value will be required too.
Use vpce (vpc endpoint) based URL. Example: curl https://vpce-0c0471b7test-jkznizi5.execute-api.us-east-1.vpce.amazonaws.com/dev/api/v1/status
Your EC2 instance have a security group than allow outbound traffic to another security group owned by the vpce like:
Your vpce security group allow inbound traffic from another security group (previous sg from ec2 instance) owned by the EC2 instance like:
See: https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-private-apis.html
I had the same problem which I solved the following way:
GET Method test
https://54wtstq8d2.execute-api.ap-southeast-2.amazonaws.com/dev/echo/hello
Authorization tab ->
• select type(AWS signature)
• Add AccessKey and SecretKey
You must be using Invoke Url to trigger Lambda Function from your browser or POSTMAN... Instead, use the API end point which will be listed in:
select yourLambdaFuntion >> Configuration >> Triggers.
There you can see API end point.
For the record, if you wouldn't be using credentials, this error also shows when you are setting the request validator in your POST/PUT method to "validate body, query string parameters and HEADERS", or the other option "validate query string parameters and HEADERS"....in that case it will look for the credentials on the header and reject the request. To sum it up, if you don't intend to send credentials and want to keep it open you should not set that option in request validator(set it to either NONE or to validate body)
I had the same issue, and fixed it by removing the /dev/ and just put: https://1111.execute-api.us-east-1.amazonaws.com/get-list
I had same issue today because I was using GET instead of POST. Fixed the issues by changing method to POST in postman.
First of all, check whether the API you created in the lamda function is registered with your AWS project or not. For that, go to the API gateway in your AWS console. If it is not registered, register it. This is the main cause of this issue.
You can even see in your aws.export.js file, that there are paths corresponding to your API ['/items'].
Your API must be present there, otherwise it will not append the security token to requests. Just register it in your project cloud-logic in your console for this.
If it's there, then use the above mentioned solution
http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-use-postman-to-call-api.html
To contribute:
I had a similar error because my return response did not contain the 'body' like this:
return {
'statusCode': 200,
'body': "must contain the body tag if you replace it won't work"
}
If you set up an IAM role for your server that has the AmazonAPIGatewayInvokeFullAccess permission, you still need to pass headers on each request. You can do this in python with the aws-requests-auth library like so:
import requests
from aws_requests_auth.boto_utils import BotoAWSRequestsAuth
auth = BotoAWSRequestsAuth(
aws_host="API_ID.execute-api.us-east-1.amazonaws.com",
aws_region="us-east-1",
aws_service="execute-api"
)
response = requests.get("https://API_ID.execute-api.us-east-1.amazonaws.com/STAGE/RESOURCE", auth=auth)
Well for anyone still having the problem and I really feel very dumb after realizing this, but I passed in the url of /items the default one while adding API. But I kept calling the endpoint with /api. Special thanks to Carlos Alberto Schneider, as I realized my problem after reading your post.
According to my experience, please check the following steps:
On API gateway side, make sure you add the correct path and publish the resource at the stage you want. For some url pattern like path parameter(/user/{user_id}) need more attention to have a check.
Make sure you configure the correct options method for this resource, because sometimes it is the CORS that cause this problem.
On Lambda side, make sure you specify the correct handler name as the entrypoint.
Please always check cloudwatch logs of your lambda that can help u identify the problems on your lambda side.
In my case I was trying to do an UPDATE type request but in my AWS SAM template I had a PATCH type request:
Resources:
LambdaFunction:
Type: AWS::Serverless::Function # More info about Function Resource:
# https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: src/
Handler: app.lambda_handler
Runtime: python3.8
MemorySize: 128
Events:
UpdateItem:
Type: Api
Properties:
Path: /my-endpoint
Method: patch
Things to check:
1. In resources, check for Authorization and API Key if these are required.
2. Redeploy the API, new changes might not reflected.
3. Get the url from stages, directly by clicking on the actions like GET, POST, These will contain the full path urls.
I had the same issue even if my access was regional and not private, no authorization on my method neither API. It's turned out that I was calling the root endpoint "https://azerty.execute-api.eu-west-3.amazonaws.com/dev/", which in local return me a json but raised an error. Be sure to call a proper endpoint, such as "https://azerty.execute-api.eu-west-3.amazonaws.com/dev/hello"

Alexa API: Not working

Documentation here:
http://docs.amazonwebservices.com/AlexaWebInfoService/latest/
http://awis.amazonaws.com/?
Action=UrlInfo
&AWSAccessKeyId=[Your AWS Access Key ID]
&Signature=[signature calculated from request]
&SignatureMethod=[HmacSha1 or HmacSha256]
&SignatureVersion=2
&Timestamp=[timestamp used in signature]
&Url=[Valid URL]
&ResponseGroup=[Valid Response Group]
I don't understand this...
&Signature=[signature calculated from request]
&SignatureMethod=[HmacSha1 or HmacSha256]
How do you calculate the signature?
&AWSAccessKeyId=[Your AWS Access Key ID]
This does not work as well! There's no AWS secret key required here here, but it simple doesn't recognize the Access Key ID, in my account.
AWS was not able to authenticate the request: access credentials are missing
I can't do something as simple as:
http://awis.amazonaws.com/?Action=UrlInfo&AWSAccessKeyId=AKIAISCXZCPDLPUDDAVA&SignatureVersion=2&Url=http://www.google.com&ResponseGroup=TrafficData
Have you checked following things, its given in Documentation Under Authentication Errors Section:
If you get an authentication error then one of the following is probably true:
You are not signed up for the Alexa Web Information service. Even if you already have an Amazon Web Services account, you must separately sign up for the Alexa Web Information service at Amazon AWS.
Your credit card is invalid or expired.
You have not URL encoded your Timestamp and Signature values.
If you are seeing intermittent authorization errors, this is the most
likely problem. You should not see any "+" signs in your Signature, for example.
You are not generating the Signature correctly. Please see the code samples.
The clock on the computer making the requests is not set correctly.