Issue:-
Terraform run time error on apply that the parameter Header Cloudfront-Viewer-Address is not allowed
Error:-
error updating CloudFront Distribution: InvalidArgument: The parameter Header Name contains Cloudfront-Viewer-Address that is not allowed.
Effect:-
SCloudfront-Viewer-Address contains the IP Address of the viewer that sent the request to Cloudfront, and the port used for the request. For e.g 3.110.159.137:443. Because the header is not whitelisted the same value is not available in the system.
Resolution:-
Change the configuration under the Behaviours in the cloudfront from Legacy cache settings to Legacy cache settings to Cache policy and origin request policy (recommended)
Explanation:-
The header
cloudfront-viewer-address
is supported by the Legacy cache settings to Cache policy and origin request policy (recommended) only and you cannot use it with the Legacy cache settings as per the AWS Documentation.