- Newest
- Most votes
- Most comments
From the point of view of your code in your Lambda function, you do not specify the domain name, so this should be some out of bound process.
I assume you could create some domain name and map it in the DNS to the IP addresses that you have assigned to the NAT Gateway. If for some reason it is not possible (because you do not own the IP address, but rather AWS does), you can also bring your own IPs to AWS and assign one of your IPs to the NAT Gateway.
Thanks! Understood it now. Really appreciate the help!
This might help you https://docs.aws.amazon.com/elasticloadbalancing/latest/network/network-load-balancers.html#dns-name
Thank you for sharing the article Tarun! However, I am not sure if this is what I am looking for. I will get a custom domain name associated with the NLB following this, but I need this name to be the origin of the API requests that I'll be making from the Lambda functions too.
It is not clear to me what you are trying to achieve. There are two options:
- You want to make outbound calls from a Lambda function to some external API and you want those calls to originate from a fixed IP (in this case it doesn't matter that the function is triggered by an API Gateway.
- You want some external party to make API calls to API gateway and you need a domain name, with maybe a fixed IP.
If it is the first option, you need to attach the Lambda function to a VPC, create a NAT gateway in the VPC and attache an Elastic IP address to the NAT Gateway. This way all traffic from the function will originate from that IP address.
If it is the second option you need to use custom domain names for the API. If you actually need the IP to be fixed as well, you will need to create a Private API (in this case you do not need custom domain names, which are actually not supported for private APIs anyway) and use something like a Global Accelerator as described in this blog.
Thank you for helping out!
I'd actually like both, inbound and outbound static IPs, however I can do without the inbound one i.e., static IP for the APIs that I will host. But for the outbound requests from Lambda, I definitely need at least one. The blog you shared is really helpful. Is there any way I can get the same custom domain name to appear as the origin of the API requests that I will be making from the Lambda functions?
I am not sure if the provider validates this too or not but they did ask me for the hostname, so I am assuming they do.
Relevant content
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
Could you try with CNAME defined in your DNS pointing to the NLB?
That may allow me to invoke the API with the custom name but what about the requests to external API provider that I will be making from Lambda? I need the said custom domain name to be the origin of that request too.