Search code examples
amazon-web-servicesamazon-cloudfrontaws-waf

Is there a way to forward AWS cloudfront request id to the origin?


I was looking for a unique correlation id to identify request that flows from the cloudfront to the origin and also should be able to relate it with the WAF logs. I see there is a filed named httpRequest.requestId but, this is not visible in the request headers that are being sent to the origin.


Solution

  • I would suggest using X-Amz-Cf-Id as this holds the Cloudfront request id, which if you want you can use as a correlation id for the request lifecycle within your backend systems.

    CloudFront adds the header to the viewer request before forwarding the request to your origin. The header value contains an encrypted string that uniquely identifies the request.

    https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorCustomOrigin.html#request-custom-headers-behavior