@@ -17,6 +17,7 @@ import {
17
17
LambdaEdgeEventType ,
18
18
PriceClass ,
19
19
SecurityPolicyProtocol ,
20
+ SSLMethod ,
20
21
} from '../lib' ;
21
22
import { defaultOrigin , defaultOriginGroup } from './test-origin' ;
22
23
@@ -56,7 +57,139 @@ test('minimal example renders correctly', () => {
56
57
} ) ;
57
58
} ) ;
58
59
59
- test ( 'exhaustive example of props renders correctly' , ( ) => {
60
+ test ( 'exhaustive example of props renders correctly and SSL method sni-only' , ( ) => {
61
+ const origin = defaultOrigin ( ) ;
62
+ const certificate = acm . Certificate . fromCertificateArn ( stack , 'Cert' , 'arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012' ) ;
63
+
64
+ new Distribution ( stack , 'MyDist' , {
65
+ defaultBehavior : { origin } ,
66
+ certificate,
67
+ comment : 'a test' ,
68
+ defaultRootObject : 'index.html' ,
69
+ domainNames : [ 'example.com' ] ,
70
+ enabled : false ,
71
+ enableIpv6 : false ,
72
+ enableLogging : true ,
73
+ geoRestriction : GeoRestriction . denylist ( 'US' , 'GB' ) ,
74
+ httpVersion : HttpVersion . HTTP1_1 ,
75
+ logFilePrefix : 'logs/' ,
76
+ logIncludesCookies : true ,
77
+ sslSupportMethod : SSLMethod . SNI ,
78
+ minimumProtocolVersion : SecurityPolicyProtocol . TLS_V1_2_2019 ,
79
+ priceClass : PriceClass . PRICE_CLASS_100 ,
80
+ webAclId : '473e64fd-f30b-4765-81a0-62ad96dd167a' ,
81
+ } ) ;
82
+
83
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::CloudFront::Distribution' , {
84
+ DistributionConfig : {
85
+ Aliases : [ 'example.com' ] ,
86
+ DefaultCacheBehavior : {
87
+ CachePolicyId : '658327ea-f89d-4fab-a63d-7e88639e58f6' ,
88
+ Compress : true ,
89
+ TargetOriginId : 'StackMyDistOrigin1D6D5E535' ,
90
+ ViewerProtocolPolicy : 'allow-all' ,
91
+ } ,
92
+ Comment : 'a test' ,
93
+ DefaultRootObject : 'index.html' ,
94
+ Enabled : false ,
95
+ HttpVersion : 'http1.1' ,
96
+ IPV6Enabled : false ,
97
+ Logging : {
98
+ Bucket : { 'Fn::GetAtt' : [ 'MyDistLoggingBucket9B8976BC' , 'RegionalDomainName' ] } ,
99
+ IncludeCookies : true ,
100
+ Prefix : 'logs/' ,
101
+ } ,
102
+ Origins : [ {
103
+ DomainName : 'www.example.com' ,
104
+ Id : 'StackMyDistOrigin1D6D5E535' ,
105
+ CustomOriginConfig : {
106
+ OriginProtocolPolicy : 'https-only' ,
107
+ } ,
108
+ } ] ,
109
+ PriceClass : 'PriceClass_100' ,
110
+ Restrictions : {
111
+ GeoRestriction : {
112
+ Locations : [ 'US' , 'GB' ] ,
113
+ RestrictionType : 'blacklist' ,
114
+ } ,
115
+ } ,
116
+ ViewerCertificate : {
117
+ AcmCertificateArn : 'arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012' ,
118
+ SslSupportMethod : 'sni-only' ,
119
+ MinimumProtocolVersion : 'TLSv1.2_2019' ,
120
+ } ,
121
+ WebACLId : '473e64fd-f30b-4765-81a0-62ad96dd167a' ,
122
+ } ,
123
+ } ) ;
124
+ } ) ;
125
+
126
+ test ( 'exhaustive example of props renders correctly and SSL method vip' , ( ) => {
127
+ const origin = defaultOrigin ( ) ;
128
+ const certificate = acm . Certificate . fromCertificateArn ( stack , 'Cert' , 'arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012' ) ;
129
+
130
+ new Distribution ( stack , 'MyDist' , {
131
+ defaultBehavior : { origin } ,
132
+ certificate,
133
+ comment : 'a test' ,
134
+ defaultRootObject : 'index.html' ,
135
+ domainNames : [ 'example.com' ] ,
136
+ enabled : false ,
137
+ enableIpv6 : false ,
138
+ enableLogging : true ,
139
+ geoRestriction : GeoRestriction . denylist ( 'US' , 'GB' ) ,
140
+ httpVersion : HttpVersion . HTTP1_1 ,
141
+ logFilePrefix : 'logs/' ,
142
+ logIncludesCookies : true ,
143
+ sslSupportMethod : SSLMethod . VIP ,
144
+ minimumProtocolVersion : SecurityPolicyProtocol . TLS_V1_2_2019 ,
145
+ priceClass : PriceClass . PRICE_CLASS_100 ,
146
+ webAclId : '473e64fd-f30b-4765-81a0-62ad96dd167a' ,
147
+ } ) ;
148
+
149
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::CloudFront::Distribution' , {
150
+ DistributionConfig : {
151
+ Aliases : [ 'example.com' ] ,
152
+ DefaultCacheBehavior : {
153
+ CachePolicyId : '658327ea-f89d-4fab-a63d-7e88639e58f6' ,
154
+ Compress : true ,
155
+ TargetOriginId : 'StackMyDistOrigin1D6D5E535' ,
156
+ ViewerProtocolPolicy : 'allow-all' ,
157
+ } ,
158
+ Comment : 'a test' ,
159
+ DefaultRootObject : 'index.html' ,
160
+ Enabled : false ,
161
+ HttpVersion : 'http1.1' ,
162
+ IPV6Enabled : false ,
163
+ Logging : {
164
+ Bucket : { 'Fn::GetAtt' : [ 'MyDistLoggingBucket9B8976BC' , 'RegionalDomainName' ] } ,
165
+ IncludeCookies : true ,
166
+ Prefix : 'logs/' ,
167
+ } ,
168
+ Origins : [ {
169
+ DomainName : 'www.example.com' ,
170
+ Id : 'StackMyDistOrigin1D6D5E535' ,
171
+ CustomOriginConfig : {
172
+ OriginProtocolPolicy : 'https-only' ,
173
+ } ,
174
+ } ] ,
175
+ PriceClass : 'PriceClass_100' ,
176
+ Restrictions : {
177
+ GeoRestriction : {
178
+ Locations : [ 'US' , 'GB' ] ,
179
+ RestrictionType : 'blacklist' ,
180
+ } ,
181
+ } ,
182
+ ViewerCertificate : {
183
+ AcmCertificateArn : 'arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012' ,
184
+ SslSupportMethod : 'vip' ,
185
+ MinimumProtocolVersion : 'TLSv1.2_2019' ,
186
+ } ,
187
+ WebACLId : '473e64fd-f30b-4765-81a0-62ad96dd167a' ,
188
+ } ,
189
+ } ) ;
190
+ } ) ;
191
+
192
+ test ( 'exhaustive example of props renders correctly and SSL method default' , ( ) => {
60
193
const origin = defaultOrigin ( ) ;
61
194
const certificate = acm . Certificate . fromCertificateArn ( stack , 'Cert' , 'arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012' ) ;
62
195
@@ -404,6 +537,7 @@ describe('certificates', () => {
404
537
new Distribution ( stack , 'Dist' , {
405
538
defaultBehavior : { origin : defaultOrigin ( ) } ,
406
539
domainNames : [ 'www.example.com' ] ,
540
+ sslSupportMethod : SSLMethod . SNI ,
407
541
minimumProtocolVersion : SecurityPolicyProtocol . TLS_V1_2016 ,
408
542
certificate : certificate ,
409
543
} ) ;
0 commit comments