|
3 | 3 | Equals, route53, FindInMap, AWS_REGION, serverless, constants, awslambda, kms, iam, s3, dynamodb, \ |
4 | 4 | ImportValue, Not, And, Condition, If, AWS_NO_VALUE |
5 | 5 | from troposphere.cloudfront import Origin, CustomOriginConfig, Distribution, \ |
6 | | - DistributionConfig, ViewerCertificate, DefaultCacheBehavior, ForwardedValues, Cookies |
| 6 | + DistributionConfig, ViewerCertificate, DefaultCacheBehavior |
7 | 7 | import custom_resources.ssm |
8 | 8 | import custom_resources.acm |
9 | 9 | import custom_resources.cognito |
|
124 | 124 | )) |
125 | 125 | template.set_parameter_label(param_create_own_cloudfront, "Create own CloudFront distribution") |
126 | 126 |
|
127 | | -cookies = template.add_parameter(Parameter( |
128 | | - "Cookies", |
129 | | - Type=constants.COMMA_DELIMITED_LIST, |
130 | | - Default="refresh_token", |
131 | | - Description="Comma delimited list of Cookies that will be used in cache key and forwarded to the origin. \ |
132 | | - Stack will fail if list is empty while using 'Forward-list' as 'Cookie behaviour'", |
| 127 | +cache_policy_id = template.add_parameter(Parameter( |
| 128 | + "CachePolicyId", |
| 129 | + Type=constants.STRING, |
| 130 | + Default="4135ea2d-6df8-44a3-9df3-4b5a84be39ad", # Managed-CachingDisabled |
| 131 | + Description="Cache policy ID to use for the CloudFront distribution.", |
133 | 132 | )) |
134 | | -template.set_parameter_label(cookies, "Comma delimited list of Cookies to forward.") |
| 133 | +template.set_parameter_label(cache_policy_id, "Cache policy ID to use for the CloudFront distribution.") |
135 | 134 |
|
136 | | -headers = template.add_parameter(Parameter( |
137 | | - "Headers", |
138 | | - Type=constants.COMMA_DELIMITED_LIST, |
139 | | - Default="Authorization,Host", |
140 | | - Description="Comma delimited list of Headers that will be used in cache key and forwarded to the origin.", |
| 135 | +origin_policy_id = template.add_parameter(Parameter( |
| 136 | + "OriginPolicyId", |
| 137 | + Type=constants.STRING, |
| 138 | + Default="216adef6-5c7f-47e4-b989-5492eafa07d3", # Managed-AllViewer |
| 139 | + Description="Origin policy ID to use for the CloudFront distribution.", |
141 | 140 | )) |
142 | | -template.set_parameter_label(headers, "Comma delimited list of Headers to forward.") |
| 141 | +template.set_parameter_label(origin_policy_id, "Origin policy ID to use for the CloudFront distribution.") |
143 | 142 |
|
144 | 143 | use_domain_name = template.add_parameter(Parameter( |
145 | 144 | "UseDomainName", |
|
734 | 733 | DefaultCacheBehavior=DefaultCacheBehavior( |
735 | 734 | ViewerProtocolPolicy='redirect-to-https', # HTTPS required. Cookies need to be sent securely |
736 | 735 | TargetOriginId='default', |
737 | | - ForwardedValues=ForwardedValues( |
738 | | - Headers=Ref(headers), |
739 | | - QueryString=True, |
740 | | - Cookies=Cookies( |
741 | | - Forward='whitelist', |
742 | | - WhitelistedNames=Ref(cookies), # Cookies can be edited in the Cookies parameter |
743 | | - ), |
744 | | - ), |
| 736 | + CachePolicyId=Ref(cache_policy_id), |
| 737 | + OriginRequestPolicyId=Ref(origin_policy_id), |
745 | 738 | AllowedMethods=['DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT'], # /delegate sends POST |
746 | 739 | ), |
747 | 740 | ViewerCertificate=ViewerCertificate( |
|
0 commit comments