AppSync use / access CloudFront Viewer Headers

1

CloudFront has a number of headers regarding viewer information that we would like to access in our AppSync vtl / resolvers, see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-cloudfront-headers.html

Specifically, we'd like to use CloudFront-Viewer-Country-Region

In a 'normal' Cloudfront -> S3 origin for example, we would add an Origin request policy to forward the headers on.

How is this possible in Appsync please?

2개 답변
1

Hey the way I found to solve it is to put Cloudfront distribution in front of the app-sync one. You can configure this new CF distribution to include the headers so they can be used in the resolvers.

P.S.: AWS it would be nice to be able to to configure the header behavior of the CF you guys create for the AppSync instance so we do no need to do this :)

답변함 일 년 전
  • Thanks - yeah, this is what we've ended up doing by adding a kind of reverse proxy to our front end's cloudfront dist.

0

You can access all request headers via the $context.request.headers construct.

AWS
답변함 일 년 전
  • Hi thanks - yes we know this, but the point is it doesn't include all the headers from cloudfront.

    e.g. we get cloudfront-viewer-country but not cloudfront-viewer-country-region

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠