CloudFront distributions must require or redirect viewers to HTTPS to prevent plaintext HTTP traffic that can expose sensitive data in transit and enable interception or downgrade attacks. In AWS::CloudFront::Distribution resources, set DistributionConfig.DefaultCacheBehavior.ViewerProtocolPolicy and each DistributionConfig.CacheBehaviors[].ViewerProtocolPolicy to https-only or redirect-to-https. Resources missing these properties or configured with allow-all (which permits HTTP) will be flagged as insecure.
#this code is a correct code for which the query should not find any resultAWSTemplateFormatVersion:"2010-09-09"Resources:cloudfrontdistribution:Type:AWS::CloudFront::DistributionProperties:DistributionConfig:CacheBehaviors:- LambdaFunctionAssociations:- EventType:viewer-requestLambdaFunctionARN:exampDefaultCacheBehavior:LambdaFunctionAssociations:- EventType:viewer-requestLambdaFunctionARN:exampIPV6Enabled:trueOrigins:- CustomOriginConfig:OriginKeepaliveTimeout:60OriginReadTimeout:30Tags:- Key:nameValue:example
Non-Compliant Code Examples
#this is a problematic code where the query should report a result(s)AWSTemplateFormatVersion:"2010-09-09"Resources:cloudfrontdistribution_1:Type:AWS::CloudFront::DistributionProperties:DistributionConfig:CacheBehaviors:- LambdaFunctionAssociations:- EventType:viewer-requestLambdaFunctionARN:exampDefaultCacheBehavior:ViewerProtocolPolicy:allow-allLambdaFunctionAssociations:- EventType:viewer-requestLambdaFunctionARN:exampIPV6Enabled:trueOrigins:- CustomOriginConfig:OriginKeepaliveTimeout:60OriginReadTimeout:30Tags:- Key:nameValue:examplecloudfrontdistribution_2:Type:AWS::CloudFront::DistributionProperties:DistributionConfig:CacheBehaviors:ViewerProtocolPolicy:allow-allLambdaFunctionAssociations:- EventType:viewer-requestLambdaFunctionARN:exampDefaultCacheBehavior:LambdaFunctionAssociations:- EventType:viewer-requestLambdaFunctionARN:exampIPV6Enabled:trueOrigins:- CustomOriginConfig:OriginKeepaliveTimeout:60OriginReadTimeout:30Tags:- Key:nameValue:example
1
2
rulesets:- CloudFormation / AWS # Rules to enforce / AWS.
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.