@@ -19,11 +19,14 @@ Object {
19
19
" DefaultCacheBehavior" : Object {
20
20
" CachePolicyId" : " 658327ea-f89d-4fab-a63d-7e88639e58f6" ,
21
21
" Compress" : true ,
22
- " LambdaFunctionAssociations " : Array [
22
+ " FunctionAssociations " : Array [
23
23
Object {
24
- " EventType" : " origin-response" ,
25
- " LambdaFunctionARN" : Object {
26
- " Ref" : " testcloudfronts3SetHttpSecurityHeadersVersionF1C744BB" ,
24
+ " EventType" : " viewer-response" ,
25
+ " FunctionARN" : Object {
26
+ " Fn::GetAtt" : Array [
27
+ " testcloudfronts3SetHttpSecurityHeaders6C5A1E69" ,
28
+ " FunctionARN" ,
29
+ ],
27
30
},
28
31
},
29
32
],
@@ -368,149 +371,36 @@ Object {
368
371
" Type" : " AWS::S3::BucketPolicy" ,
369
372
},
370
373
" testcloudfronts3SetHttpSecurityHeaders6C5A1E69" : Object {
371
- " DependsOn" : Array [
372
- " testcloudfronts3SetHttpSecurityHeadersServiceRoleDefaultPolicy7A7EF47A" ,
373
- " testcloudfronts3SetHttpSecurityHeadersServiceRole74D1E252" ,
374
- ],
375
- " Metadata" : Object {
376
- " cfn_nag" : Object {
377
- " rules_to_suppress" : Array [
378
- Object {
379
- " id" : " W58" ,
380
- " reason" : " Lambda functions has the required permission to write CloudWatch Logs. It uses custom policy instead of arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole with tighter permissions." ,
381
- },
382
- Object {
383
- " id" : " W89" ,
384
- " reason" : " This is not a rule for the general case, just for specific use cases/industries" ,
385
- },
386
- Object {
387
- " id" : " W92" ,
388
- " reason" : " Impossible for us to define the correct concurrency for clients" ,
389
- },
390
- ],
391
- },
392
- },
393
374
" Properties" : Object {
394
- " Code" : Object {
395
- "ZipFile": "exports.handler = (event, context, callback) => { const response = event.Records[0].cf.response; const headers = response.headers; headers['x-xss-protection'] = [ { key: 'X-XSS-Protection', value: '1; mode=block' } ]; headers['x-frame-options'] = [ { key: 'X-Frame-Options', value: 'DENY' } ]; headers['x-content-type-options'] = [ { key: 'X-Content-Type-Options', value: 'nosniff' } ]; headers['strict-transport-security'] = [ { key: 'Strict-Transport-Security', value: 'max-age=63072000; includeSubdomains; preload' } ]; headers['referrer-policy'] = [ { key: 'Referrer-Policy', value: 'same-origin' } ]; headers['content-security-policy'] = [ { key: 'Content-Security-Policy', value: \\"default-src 'none'; base-uri 'self'; img-src 'self'; script-src 'self'; style-src 'self' https:; object-src 'none'; frame-ancestors 'none'; font-src 'self' https:; form-action 'self'; manifest-src 'self'; connect-src 'self'\\" } ]; callback(null, response); };",
396
- },
397
- " Handler" : " index.handler" ,
398
- " Role" : Object {
399
- " Fn::GetAtt" : Array [
400
- " testcloudfronts3SetHttpSecurityHeadersServiceRole74D1E252" ,
401
- " Arn" ,
402
- ],
403
- },
404
- " Runtime" : " nodejs12.x" ,
405
- " TracingConfig" : Object {
406
- " Mode" : " Active" ,
407
- },
408
- },
409
- " Type" : " AWS::Lambda::Function" ,
410
- },
411
- " testcloudfronts3SetHttpSecurityHeadersServiceRole74D1E252" : Object {
412
- " Properties" : Object {
413
- " AssumeRolePolicyDocument" : Object {
414
- " Statement" : Array [
415
- Object {
416
- " Action" : " sts:AssumeRole" ,
417
- " Effect" : " Allow" ,
418
- " Principal" : Object {
419
- " Service" : " lambda.amazonaws.com" ,
420
- },
421
- },
422
- Object {
423
- " Action" : " sts:AssumeRole" ,
424
- " Effect" : " Allow" ,
425
- " Principal" : Object {
426
- " Service" : " edgelambda.amazonaws.com" ,
427
- },
428
- },
429
- ],
430
- " Version" : " 2012-10-17" ,
431
- },
432
- " Policies" : Array [
433
- Object {
434
- " PolicyDocument" : Object {
435
- " Statement" : Array [
375
+ " AutoPublish" : true ,
376
+ " FunctionCode" : " function handler(event) { var response = event.response; var headers = response.headers; headers['strict-transport-security'] = { value: 'max-age=63072000; includeSubdomains; preload'}; headers['content-security-policy'] = { value: \\ " default - src ' none' ; img - src ' self' ; script - src ' self' ; style - src ' self' ; object - src ' none' \\" }; headers['x-content-type-options'] = { value: 'nosniff'}; headers['x-frame-options'] = {value: 'DENY'}; headers['x-xss-protection'] = {value: '1; mode=block'}; return response; }" ,
377
+ " FunctionConfig" : Object {
378
+ " Comment" : Object {
379
+ " Fn::Join" : Array [
380
+ " " ,
381
+ Array [
436
382
Object {
437
- " Action" : Array [
438
- " logs:CreateLogGroup" ,
439
- " logs:CreateLogStream" ,
440
- " logs:PutLogEvents" ,
441
- ],
442
- " Effect" : " Allow" ,
443
- " Resource" : Object {
444
- " Fn::Join" : Array [
445
- " " ,
446
- Array [
447
- " arn:" ,
448
- Object {
449
- " Ref" : " AWS::Partition" ,
450
- },
451
- " :logs:" ,
452
- Object {
453
- " Ref" : " AWS::Region" ,
454
- },
455
- " :" ,
456
- Object {
457
- " Ref" : " AWS::AccountId" ,
458
- },
459
- " :log-group:/aws/lambda/*" ,
460
- ],
461
- ],
462
- },
383
+ " Ref" : " AWS::Region" ,
463
384
},
385
+ " testcloudfs3SetHttpSecurityHeaders794DF6AB" ,
464
386
],
465
- " Version" : " 2012-10-17" ,
466
- },
467
- " PolicyName" : " LambdaFunctionServiceRolePolicy" ,
387
+ ],
468
388
},
469
- ],
470
- },
471
- " Type" : " AWS::IAM::Role" ,
472
- },
473
- " testcloudfronts3SetHttpSecurityHeadersServiceRoleDefaultPolicy7A7EF47A" : Object {
474
- " Metadata" : Object {
475
- " cfn_nag" : Object {
476
- " rules_to_suppress" : Array [
477
- Object {
478
- " id" : " W12" ,
479
- " reason" : " Lambda needs the following minimum required permissions to send trace data to X-Ray and access ENIs in a VPC." ,
480
- },
481
- ],
389
+ " Runtime" : " cloudfront-js-1.0" ,
482
390
},
483
- },
484
- " Properties" : Object {
485
- " PolicyDocument" : Object {
486
- " Statement" : Array [
487
- Object {
488
- " Action" : Array [
489
- " xray:PutTraceSegments" ,
490
- " xray:PutTelemetryRecords" ,
491
- ],
492
- " Effect" : " Allow" ,
493
- " Resource" : " *" ,
494
- },
391
+ " Name" : Object {
392
+ " Fn::Join" : Array [
393
+ " " ,
394
+ Array [
395
+ Object {
396
+ " Ref" : " AWS::Region" ,
397
+ },
398
+ " testcloudfs3SetHttpSecurityHeaders794DF6AB" ,
399
+ ],
495
400
],
496
- " Version" : " 2012-10-17" ,
497
- },
498
- " PolicyName" : " testcloudfronts3SetHttpSecurityHeadersServiceRoleDefaultPolicy7A7EF47A" ,
499
- " Roles" : Array [
500
- Object {
501
- " Ref" : " testcloudfronts3SetHttpSecurityHeadersServiceRole74D1E252" ,
502
- },
503
- ],
504
- },
505
- " Type" : " AWS::IAM::Policy" ,
506
- },
507
- " testcloudfronts3SetHttpSecurityHeadersVersionF1C744BB" : Object {
508
- " Properties" : Object {
509
- " FunctionName" : Object {
510
- " Ref" : " testcloudfronts3SetHttpSecurityHeaders6C5A1E69" ,
511
401
},
512
402
},
513
- " Type" : " AWS::Lambda::Version " ,
403
+ " Type" : " AWS::CloudFront::Function " ,
514
404
},
515
405
},
516
406
}
0 commit comments