aws / aws/aws-cdk

feat(cloudfront): default Distribution behaviors to redirect HTTP to HTTPS

Open
#38,599 1 comment 1 reaction 0 assignees View on GitHub
@aws-cdk/aws-cloudfront effort/small feature-request p1
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

## Describe the feature

Change the default `viewerProtocolPolicy` for `Distribution` behaviors from `ViewerProtocolPolicy.ALLOW_ALL` to `ViewerProtocolPolicy.REDIRECT_TO_HTTPS` for new CDK projects.

## Use Case

A behavior with no explicit viewer protocol policy currently accepts HTTP. New distributions should redirect viewers to HTTPS by default.

## Proposed Solution

Add an `ApiDefault` feature flag, for example `@aws-cdk/aws-cloudfront:defaultViewerProtocolPolicyRedirectToHttps`.

- Recommended value: `true`
- Unconfigured behavior: `false`
- Flag enabled default: `REDIRECT_TO_HTTPS`
- Flag disabled default: `ALLOW_ALL`
- An explicit `viewerProtocolPolicy` always wins

Apply this to default and additional behaviors. Existing applications retain `ALLOW_ALL` unless they enable the flag.

## Acknowledgements

- [x] I may be able to implement this feature request
- [x] This feature might incur a breaking change

## AWS CDK Library version

main (`ccd263359f`)

## AWS CDK CLI version

N/A

## Environment details

macOS 26.5.1

Contributor guide

Open the contributing guide

Research direction

Start at the CloudFront Distribution behavior defaults and existing ApiDefault feature-flag handling. Trace both default and additional behaviors, confirming that the flag selects REDIRECT_TO_HTTPS or ALLOW_ALL, existing applications retain the legacy default when unconfigured, and an explicit viewerProtocolPolicy takes precedence.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.