@@ -2,7 +2,7 @@ import { expect } from '@aws-cdk/assert';
2
2
import s3 = require( '@aws-cdk/aws-s3' ) ;
3
3
import cdk = require( '@aws-cdk/cdk' ) ;
4
4
import { Test } from 'nodeunit' ;
5
- import { CloudFrontWebDistribution } from '../lib' ;
5
+ import { CloudFrontWebDistribution , ViewerProtocolPolicy } from '../lib' ;
6
6
7
7
// tslint:disable:object-literal-key-quotes
8
8
@@ -246,4 +246,80 @@ export = {
246
246
} ) ;
247
247
test . done ( ) ;
248
248
} ,
249
+
250
+ 'distribution with ViewerProtocolPolicy set to a non-default value' ( test : Test ) {
251
+ const stack = new cdk . Stack ( ) ;
252
+ const sourceBucket = new s3 . Bucket ( stack , 'Bucket' ) ;
253
+
254
+ new CloudFrontWebDistribution ( stack , 'AnAmazingWebsiteProbably' , {
255
+ viewerProtocolPolicy : ViewerProtocolPolicy . AllowAll ,
256
+ originConfigs : [
257
+ {
258
+ s3OriginSource : {
259
+ s3BucketSource : sourceBucket
260
+ } ,
261
+ behaviors : [
262
+ {
263
+ isDefaultBehavior : true ,
264
+ }
265
+ ]
266
+ }
267
+ ]
268
+ } ) ;
269
+
270
+ expect ( stack ) . toMatch ( {
271
+ "Resources" : {
272
+ "Bucket83908E77" : {
273
+ "Type" : "AWS::S3::Bucket" ,
274
+ "DeletionPolicy" : "Retain" ,
275
+ } ,
276
+ "AnAmazingWebsiteProbablyCFDistribution47E3983B" : {
277
+ "Type" : "AWS::CloudFront::Distribution" ,
278
+ "Properties" : {
279
+ "DistributionConfig" : {
280
+ "DefaultRootObject" : "index.html" ,
281
+ "Origins" : [
282
+ {
283
+ "DomainName" : {
284
+ "Fn::GetAtt" : [
285
+ "Bucket83908E77" ,
286
+ "DomainName"
287
+ ]
288
+ } ,
289
+ "Id" : "origin1" ,
290
+ "S3OriginConfig" : { }
291
+ }
292
+ ] ,
293
+ "ViewerCertificate" : {
294
+ "CloudFrontDefaultCertificate" : true
295
+ } ,
296
+ "PriceClass" : "PriceClass_100" ,
297
+ "DefaultCacheBehavior" : {
298
+ "AllowedMethods" : [
299
+ "GET" ,
300
+ "HEAD"
301
+ ] ,
302
+ "CachedMethods" : [
303
+ "GET" ,
304
+ "HEAD"
305
+ ] ,
306
+ "TargetOriginId" : "origin1" ,
307
+ "ViewerProtocolPolicy" : "allow-all" ,
308
+ "ForwardedValues" : {
309
+ "QueryString" : false ,
310
+ "Cookies" : { "Forward" : "none" }
311
+ }
312
+ } ,
313
+ "Enabled" : true ,
314
+ "IPV6Enabled" : true ,
315
+ "HttpVersion" : "http2" ,
316
+ "CacheBehaviors" : [ ]
317
+ }
318
+ }
319
+ }
320
+ }
321
+ } ) ;
322
+ test . done ( ) ;
323
+ } ,
324
+
249
325
} ;
0 commit comments