Can AWS API Gateway automatically add correlation (request) ID - amazon-web-services

I have a set of microservices running on ECS which are deployed behind the API Gateway which forwards the client calls to the service endpoints.
I would like to use correlation (request) IDs in my services so that I can easier relate the events and everything that happens on the backend and the client requests.
Is there a possibility to configure AWS API Gateway to automatically add auto-generated (unique) correlation ID as a header of the request before it's forwarded to my backend services?

Related

Identify request handler for API Gateway endpoint using AWS web console

If i make a POST request to API gateway endpoint (configured to handle POST calls), by using AWS console how can i identify which AWS service (lambda/fargate/etc) is configured as request handler for that endpoint.
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-basic-concept.html
suggest For Integrations, choose Add integration.
But how can i find handlers/integration for an existing endpoint.
I am only able to identify Invoke URL and lambda service used as authenticator. OR do i need to manually check each Application load balancer ?
If you would like to add Integrate with ALB, you could select the HTTP in Integration Request > Integration Type and input the ALB DNS into Endpoint URL.
Check out this image: Integration Request

How to deploy spring boot rest project to private AWS API GATEWAY?

I have a spring boot rest project which is running successfully, and I am getting success response on http://localhost:8080/students. How can I expose this SpringBoot REST API into a private AWS API GATEWAY? I have to expose the REST API service, and I have to give the endpoints to the client, to access this service. I have no idea how to present and create endpoints in AWS API GATEWAY!
API Gateway will work as mediator between clients and your application. So in the first place your application should be exposed so AWS Gateway could make a call to it.
If you are running application on your local pc you need to expose it to Internet by setting static IP and openning corresponding ports in firewall if you have one. This may works for debug/testing purpose, but in general it is bad because you will expose your application to Internet and client services would have possibility to connect to it directly, instead of gateway.
Other and more proper on my opinion would be to run your application in AWS EC2 instance or in AWS beanstalk. In this case you can configure private endpoint for your application and make it available only through API Gateway. Here you can find more details https://aws.amazon.com/blogs/compute/introducing-amazon-api-gateway-private-endpoints/
So let's suppose you have your application up and running and available for API Gateway. In this case you will need to perform :
Create API in API Gateway
Create resources, i.e. path /user would be user resource
For each resource create a method, i.e. GET, POST, etc. Select integration type HTTP for your methods and set the endpoint it will use
Deploy API to staging

Secure HTTP Connection to AWS Lambda (using API Gateway)

I need to make a secure HTTP callout from Salesforce (using Apex) to AWS Lambda and I build my first version using AWS API Gateway. I realized I can get a client certificate from API Gateway (.crt) but this looks like it is only for AWS backend and is not meant to be for the HTTP request sent to API Gateway. What are my alternatives to establish a secure connection from outside AWS (Salesforce) to a Lambda function?
So far I've found this, which is a disappointing dead-end for now.
Like the link you posted says, API Gateway does not currently support MTLS. Other options for you to add security to the calls at the moment are:
IAM permissions, and here.
API Gateway custom authorizers.
Cognito User Pools.
If you need a custom domain associated with the API Gateway:
Go to Route53 and add your domain (new Hosted Zone), if you haven't done it already.
On AWS Certificate Manager, import or request a certificat for the custom domain you intend to use in your API Gateway endpoints.
Open the API Gateway dashboard and go to "Custom Domain Names". Click "Create a custom domain name" and, in the option "ACM Certificate (region)", select the certificate you generated/imported in item 2 above.
That's it, now you should be able to trigger your Lambda functions using API Gateway from a secure connection (HTTPS). Please note that, if you do this, API Gateway will refuse connections over insecure HTTP protocol.

How to use API gateway to call another service running on an EC2

I have a confusing scenario. I am new to AWS. I have some available services written in java jersy and I have them deployed on an Ec2 instance.
I am asked to use API gateway to call these services rather than calling them directly. So for instance if I have a service as follows:
http://domainname/article/2
I want the front end to first call the following endpoint of API gateway:
https://my-api-id.execute-api.region-id.amazonaws.com/stage-name/article
and then the above API Gateway end point call the my service.
What I am thinking is there is a http proxy in integration type when I try to create the API gateway resource. I assume this can fit my purpose but I am not sure about it and I am totally confused.
Can anyone shed light on how I can achieve that?
In the API Gateway Console, create a resource (eg. /v1/user/info) and method (eg. GET/POST etc).
Select Integration Request
You can then configure a an HTTP Proxy or a Lambda function any other AWS Resource. In your case, you want this to be pointing to your EC2 hosted URL.

AWS API Gateway and AWS Lambda - handling client certificate

I am looking to build an API orchestration layer using API Gateway and Lambda.
For my basic use case I want to have a Python script in Lambda that will just relay the request received at the API Gateway from the client (mobile app in this case) and call an external HTTPS service as the backend.
My question is:
Our mobile client uses client certificates to talk to our HTTPS endpoint today.
How do I go about intercepting that client certificate in my new API Gateway + Lambda setup?
Responded here. Copying the answer below for StackOverflow audience-
===
Unfortunately, API Gateway does not support client certificate validation from clients to API Gateway at the moment. We do, however, support client side SSL certificates for authentication by the backends.
Depending on your use-case, you can use various other options in API Gateway to authenticate/authorize your calls from the mobile client; eg API Keys, Custom Authorizers etc. The request from API Gateway to Lambda should already be encrypted.
Hope that helps,
Ritisha.