ViewerProtocolPolicy Enum
How HTTPs should be handled with your distribution.
Example
ts
// Create a Distribution with configured HTTP methods and viewer protocol policy of the cache.
declare const myBucket: s3.Bucket;
const myWebDistribution = new cloudfront.Distribution(this, 'myDist', {
defaultBehavior: {
origin: new origins.S3Origin(myBucket),
allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
},
});
python
# Create a Distribution with configured HTTP methods and viewer protocol policy of the cache.
# my_bucket: s3.Bucket
my_web_distribution = cloudfront.Distribution(self, "myDist",
default_behavior=cloudfront.BehaviorOptions(
origin=origins.S3Origin(my_bucket),
allowed_methods=cloudfront.AllowedMethods.ALLOW_ALL,
viewer_protocol_policy=cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS
)
)
java
// Create a Distribution with configured HTTP methods and viewer protocol policy of the cache.
Bucket myBucket;
Distribution myWebDistribution = Distribution.Builder.create(this, "myDist")
.defaultBehavior(BehaviorOptions.builder()
.origin(new S3Origin(myBucket))
.allowedMethods(AllowedMethods.ALLOW_ALL)
.viewerProtocolPolicy(ViewerProtocolPolicy.REDIRECT_TO_HTTPS)
.build())
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// Create a Distribution with configured HTTP methods and viewer protocol policy of the cache.
Bucket myBucket;
var myWebDistribution = new Distribution(this, "myDist", new DistributionProps {
DefaultBehavior = new BehaviorOptions {
Origin = new S3Origin(myBucket),
AllowedMethods = AllowedMethods.ALLOW_ALL,
ViewerProtocolPolicy = ViewerProtocolPolicy.REDIRECT_TO_HTTPS
}
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Create a Distribution with configured HTTP methods and viewer protocol policy of the cache.
var myBucket Bucket
myWebDistribution := cloudfront.NewDistribution(this, jsii.String("myDist"), &DistributionProps{
DefaultBehavior: &BehaviorOptions{
Origin: origins.NewS3Origin(myBucket),
AllowedMethods: cloudfront.AllowedMethods_ALLOW_ALL(),
ViewerProtocolPolicy: cloudfront.ViewerProtocolPolicy_REDIRECT_TO_HTTPS,
},
})
Members
| Member | Description |
|---|---|
HTTPS_ONLY | HTTPS only. |
REDIRECT_TO_HTTPS | Will redirect HTTP requests to HTTPS. |
ALLOW_ALL | Both HTTP and HTTPS supported. |
Referenced by
AddBehaviorOptions.viewerProtocolPolicyviewer_protocol_policyviewerProtocolPolicyViewerProtocolPolicyViewerProtocolPolicyBehavior.viewerProtocolPolicyviewer_protocol_policyviewerProtocolPolicyViewerProtocolPolicyViewerProtocolPolicyCloudFrontWebDistributionProps.viewerProtocolPolicyviewer_protocol_policyviewerProtocolPolicyViewerProtocolPolicyViewerProtocolPolicy