# ViewerProtocolPolicy

How HTTPs should be handled with your distribution.

- Source: [`aws-cloudfront/lib/distribution.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-cloudfront/lib/distribution.ts#L956)

## 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,
  },
});
```

## 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`](/v2/docs/aws-cdk-lib.aws_cloudfront.AddBehaviorOptions).viewerProtocolPolicy
- [`Behavior`](/v2/docs/aws-cdk-lib.aws_cloudfront.Behavior).viewerProtocolPolicy
- [`CloudFrontWebDistributionProps`](/v2/docs/aws-cdk-lib.aws_cloudfront.CloudFrontWebDistributionProps).viewerProtocolPolicy
