Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cloudfront-origins): ability to specify minimum origin SSL protocol #11997

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/@aws-cdk/aws-cloudfront-origins/lib/http-origin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ export interface HttpOriginProps extends cloudfront.OriginProps {
*/
readonly protocolPolicy?: cloudfront.OriginProtocolPolicy;

/**
* The SSL versions to use when interacting with the origin.
*
* @default OriginSslPolicy.TLS_V1_2
*/
readonly originSslProtocols?: cloudfront.OriginSslPolicy[];

/**
* The HTTP port that CloudFront uses to connect to the origin.
*
Expand Down Expand Up @@ -61,6 +68,7 @@ export class HttpOrigin extends cloudfront.OriginBase {

protected renderCustomOriginConfig(): cloudfront.CfnDistribution.CustomOriginConfigProperty | undefined {
return {
originSslProtocols: this.props.originSslProtocols ?? [cloudfront.OriginSslPolicy.TLS_V1_2],
originProtocolPolicy: this.props.protocolPolicy ?? cloudfront.OriginProtocolPolicy.HTTPS_ONLY,
httpPort: this.props.httpPort,
httpsPort: this.props.httpsPort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ test('Renders minimal example with just a domain name', () => {
domainName: 'www.example.com',
customOriginConfig: {
originProtocolPolicy: 'https-only',
originSslProtocols: [
'TLSv1.2',
],
},
});
});
Expand All @@ -37,6 +40,7 @@ test('renders an example with all available props', () => {
httpsPort: 8443,
readTimeout: Duration.seconds(45),
keepaliveTimeout: Duration.seconds(3),
originSslProtocols: [cloudfront.OriginSslPolicy.TLS_V1_2],
});
const originBindConfig = origin.bind(stack, { originId: 'StackOrigin029E19582' });

Expand All @@ -52,6 +56,9 @@ test('renders an example with all available props', () => {
}],
customOriginConfig: {
originProtocolPolicy: 'match-viewer',
originSslProtocols: [
'TLSv1.2',
],
httpPort: 8080,
httpsPort: 8443,
originReadTimeout: 45,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"Origins": [
{
"CustomOriginConfig": {
"OriginProtocolPolicy": "https-only"
"OriginProtocolPolicy": "https-only",
"OriginSSLProtocols": [
"TLSv1.2"
]
},
"DomainName": "www.example.com",
"Id": "cloudfronthttporiginDistributionOrigin162B02709"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,10 @@
"Origins": [
{
"CustomOriginConfig": {
"OriginProtocolPolicy": "https-only"
"OriginProtocolPolicy": "https-only",
"OriginSSLProtocols": [
"TLSv1.2"
]
},
"DomainName": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@
},
{
"CustomOriginConfig": {
"OriginProtocolPolicy": "https-only"
"OriginProtocolPolicy": "https-only",
"OriginSSLProtocols": [
"TLSv1.2"
]
},
"DomainName": "www.example.com",
"Id": "cloudfrontorigingroupDistributionOrigin2CCE5D500"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ test('Renders minimal example with just a load balancer', () => {
domainName: loadBalancer.loadBalancerDnsName,
customOriginConfig: {
originProtocolPolicy: 'https-only',
originSslProtocols: [
'TLSv1.2',
],
},
});
});
Expand All @@ -52,6 +55,9 @@ test('Can customize properties of the origin', () => {
connectionTimeout: 5,
customOriginConfig: {
originProtocolPolicy: 'match-viewer',
originSslProtocols: [
'TLSv1.2',
],
},
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ describe('With website-configured bucket', () => {
domainName: bucket.bucketWebsiteDomainName,
customOriginConfig: {
originProtocolPolicy: 'http-only',
originSslProtocols: [
'TLSv1.2',
],
},
});
});
Expand All @@ -155,6 +158,9 @@ describe('With website-configured bucket', () => {
originPath: '/assets',
customOriginConfig: {
originProtocolPolicy: 'http-only',
originSslProtocols: [
'TLSv1.2',
],
},
});
});
Expand Down