title: Using AWS API Gateway and Lambda as Proxy to replace Service Mesh Istio URL and handling path parameters
body: <p>Hi I would like to redirect my angular application traffic flow using API Gateway and Lambda Proxy before hitting the Service Mesh Istio URL directly.</p>
  <p>TLDR: I would like to replace the istio url with an proxy invoke url provided by API Gateway inside the angular application.</p>
  <p><a href="https://i.stack.imgur.com/mA3Qs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mA3Qs.png" alt="replacing the istio url with api gateway proxy resource" /></a></p>
  <p><a href="https://i.stack.imgur.com/vkwUK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vkwUK.png" alt="Service mesh API endpoint 200 success" /></a></p>
  <p>I went to refer to articles on redirecting the url and was successfully in creating an API to redirect the url to the istio URL. However, I was unable to pass the required parameters in the path url when invoked.</p>
  <pre><code>import json
  
  def lambda_handler(event, context):
      # https://docs.aws.amazon.com/lambda/latest/dg/with-on-demand-https.html
      path = event['path']
      return {
          'statusCode': 301,
          'headers': {
              'Location': 'https://istio-url.com/' + path.lstrip(&quot;/&quot;),
              'Access-Control-Allow-Origin': &quot;*&quot;
          }
      }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/mnipQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mnipQ.png" alt="API created by aws tested with the endpoint" /></a></p>