{"id":57086,"date":"2023-04-28T16:25:15","date_gmt":"2023-04-28T10:55:15","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=57086"},"modified":"2023-05-03T17:05:09","modified_gmt":"2023-05-03T11:35:09","slug":"connecting-aws-api-gateway-from-non-aws-environment-using-a-private-communication-channel","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/connecting-aws-api-gateway-from-non-aws-environment-using-a-private-communication-channel\/","title":{"rendered":"Connecting AWS API Gateway from Non AWS Environment using a private communication channel"},"content":{"rendered":"<h2>\u00a0<b>What is API Gateway<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">An API gateway is an API management tool between a client and a collection of backend services. An API gateway acts as a reverse proxy to accept all application programming interface (API) calls, aggregate the services required to fulfill them, and return the appropriate result.<\/span><\/p>\n<h2><b>Problem Statement<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">How to access a Private API endpoint URL hosted on AWS from a client hosted in a Non-AWS environment?<\/span><\/p>\n<h2><b>Solution<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Create a Site-to-Site VPN connection between the On Premise\/Other Cloud (Eg, Azure) and AWS environment and configure the tunnels between them.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">Steps to Create a Site-to-Site VPN Connection<\/span><\/h3>\n<p><b>(Taking Reference of Azure as Non-AWS env)<\/b><\/p>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Create Azure Virtual Network Gateway<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">This needs to be done by the Azure team (Client\/Requester end), and note the Public IP address which is used while performing this step.<\/span><\/p>\n<ol start=\"2\">\n<li><span style=\"font-weight: 400;\"> Create AWS Customer Gateways<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">While creating the AWS Customer Gateway, put the IP address which was copied in Step 1 in the below highlighted field.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-57079\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/04\/pasted-image-0-300x267.png\" alt=\"\" width=\"300\" height=\"267\" \/><\/p>\n<ol start=\"3\">\n<li><span style=\"font-weight: 400;\"> Create AWS Virtual Private Gateway<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0Create AWS Virtual Private Gateway and attach it to the VPC<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-57078\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/04\/pasted-image-0-1-300x259.png\" alt=\"\" width=\"300\" height=\"259\" \/><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-57077\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/04\/pasted-image-0-2-300x123.png\" alt=\"\" width=\"300\" height=\"123\" \/><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-57076\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/04\/pasted-image-0-3-300x151.png\" alt=\"\" width=\"300\" height=\"151\" \/><\/p>\n<ol start=\"4\">\n<li><span style=\"font-weight: 400;\"> Create AWS Site-to-Site VPN Connections<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Enter the details in the requested fields:<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">The target gateway type should be a Virtual private gateway, as selected in the above picture.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Choose the Virtual private gateway created in the above step.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Choose the Customer gateway created in the above step.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Choose Routing options as static and enter the IPs.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Put the values in Local and Remote IPv4 network CIDR.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Later update the tunnel configurations for both tunnels, like entering the Pre-shared key used on the Client side, selecting the algorithms that both the client and server support, can keep others values as default, and enabling logging if required.<\/span><\/li>\n<\/ul>\n<ol start=\"5\">\n<li><span style=\"font-weight: 400;\"> Once the tunnels are created, share the Outside IP Addresses of tunnels with the Azure team so that they can configure them in Azure Local Network Gateways.<br \/>\n<\/span><\/li>\n<li><span style=\"font-weight: 400;\">The next step is to Create Azure connections. While creating connections, kindly put similar configurations which were used while creating tunnels at the AWS end in the above step.\u00a0<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Once the setup is done correctly, Status will be connected at both AWS and Azure end.<\/span><\/p>\n<ol start=\"7\">\n<li><span style=\"font-weight: 400;\"> Add VPN Route table to AWS VM subnet. This step will redirect all traffic from the AWS VM subnet to Azure Network through VPN by configuring the AWS Route table.<\/span><\/li>\n<\/ol>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u00a0\u00a0Add Routes in the route table.<\/span><\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-57075\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/04\/pasted-image-0-4-300x167.png\" alt=\"\" width=\"300\" height=\"167\" \/><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Now add Static Routes.\u00a0<\/span><\/li>\n<\/ul>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-57074\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/04\/pasted-image-0-5-300x92.png\" alt=\"\" width=\"300\" height=\"92\" \/><\/p>\n<p><span style=\"font-weight: 400;\">After the above steps, Tunnels should be established between Azure and AWS.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Note: Both the tunnels should be UP in order to provide high availability.\u00a0\u00a0<\/span><\/p>\n<h2><b>Implementation Plan for Connectivity from a Non-AWS Environment<\/b><\/h2>\n<h2><b>Steps to connect AWS Private API Endpoint URL from Azure<\/b><\/h2>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-57073\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/04\/pasted-image-0-6-300x178.png\" alt=\"\" width=\"300\" height=\"178\" \/><\/p>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Create Azure Virtual Network Gateway (Takes about 30 &#8211; 45 mins)<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Create AWS Customer Gateways<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Create AWS Virtual Private Gateways<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Create AWS Site-to-Site VPN Connections<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Create Azure Local Network Gateways<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Create Azure Connections<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Add VPN route table to AWS VM Subnet<\/span><\/li>\n<\/ol>\n<p><b>Prerequisites:<\/b><\/p>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Site-to-Site VPN connection should be established between Azure and AWS environment, and tunnels should be up.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Source IPs should be allowed at Static routes in VPN, Route tables associated with VPC, and WAF if WAF is used.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">VPC Endpoint is created to access and invoke API service.<\/span><\/li>\n<\/ol>\n<h2><b>Steps to connect AWS Private API Endpoint URL from On Premise \/ DC<\/b><\/h2>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-57072\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/04\/Untitled-300x198.png\" alt=\"\" width=\"300\" height=\"198\" \/><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-57318\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/Pkblogpic-1-300x176.png\" alt=\"\" width=\"300\" height=\"176\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/Pkblogpic-1-300x176.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/Pkblogpic-1-1024x602.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/Pkblogpic-1-768x452.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/Pkblogpic-1-624x367.png 624w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/Pkblogpic-1.png 1143w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The client calls the private API endpoint URL (eg &#8211; GET https:\/\/abc123.execute-api.eu-west-1.amazonaws.com\/prod)<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The client asks the on-premises DNS server to resolve this (abc123.execute-api.eu-west-1.amazonaws.com).<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">You must configure the on-premises DNS server to forward DNS queries for the AWS-hosted domains to the IP addresses of the inbound resolver endpoint.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">After the client successfully resolves the API Gateway private DNS name, it receives the private IP address of the VPC Endpoint of the API Gateway.<\/span><\/li>\n<\/ol>\n<p><b>\u00a0\u00a0\u00a0<\/b><b>\u00a0Prerequisites:<\/b><\/p>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Site-to-Site VPN connection should be established between the DC and AWS environment, and tunnels should be up.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Source IPs should be allowed at Static routes in VPN, Route tables associated with VPC, and at WAF if WAF is used.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">VPC Endpoint is created to access and invoke API service<\/span><\/li>\n<\/ol>\n<p><strong>Conclusion\u00a0<\/strong><\/p>\n<p><span style=\"font-weight: 400;\">This blog demonstrates how to connect AWS API Gateway from a Non-AWS env like On-Premise\/DC or from Azure using VPC endpoints on a private network with all the security measures at different security layers. The benefits of using the API Gateway on a private network are that it reduces the attack surface and decreases the network latency.<\/span><\/p>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>\u00a0What is API Gateway An API gateway is an API management tool between a client and a collection of backend services. An API gateway acts as a reverse proxy to accept all application programming interface (API) calls, aggregate the services required to fulfill them, and return the appropriate result. Problem Statement How to access a [&hellip;]<\/p>\n","protected":false},"author":1575,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":73},"categories":[4682],"tags":[5180,5181,5183,5182],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/57086"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1575"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=57086"}],"version-history":[{"count":4,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/57086\/revisions"}],"predecessor-version":[{"id":57199,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/57086\/revisions\/57199"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=57086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=57086"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=57086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}