cookies - 如何使用对流层为 CloudFront 分配设置 cookie?
问题描述
使用 troposhphere,我正在尝试创建 CloudFront 分配。
CacheBehaviors = [
CacheBehavior(
TargetOriginId = Join("", ["cloudfront-", Ref("ParamOriginName")]),
PathPattern = '/en/Login/*',
AllowedMethods = ["GET", "HEAD", "OPTIONS", "PUT", "POST","PATCH"],
ForwardedValues = ForwardedValues(
QueryString = True,
Headers = ["user-agent",
"Host",
"CloudFront-Forwarded-Proto",
"CloudFront-Is-Desktop-Viewer",
"CloudFront-Is-Mobile-Viewer",
"CloudFront-Is-SmartTV-Viewer",
"CloudFront-Is-Tablet-Viewer",
"CloudFront-Viewer-Country",
"Origin",
"Referer"]
),
MaxTTL = 86400,
MinTTL = 14400,
DefaultTTL = 43200,
ViewerProtocolPolicy = "redirect-to-https",
Compress = True,
),
这似乎可以很好地构建 json 模板。但我还需要转发 cookie。QueryString
在我插入的行之后,Cookies = "All"
但这使构建失败。
错误信息:
TypeError: <class 'troposphere.cloudfront.ForwardedValues'>: None.Cookies is <class 'str'>, expected <class 'troposphere.cloudfront.Cookies'>
我需要添加什么以便它不会使构建失败并转发 cookie
解决方案
我在阅读此文档后解决了
QueryString = True,
在我添加的行之后
Cookies = Cookies(Forward = "all"),
它现在构建没有错误,并将正确的 cookie 值添加到 json 模板
推荐阅读
- python-3.x - 在使用 iterrows 进行迭代时比较数据框中的两个值
- javascript - React/Express: POST 错误 413: Payload too large (Bodyparser 不工作)
- flutter - Flutter Navigation 重新渲染历史堆栈页面中的所有页面
- reactjs - React Hook useState 不更新 UI
- loops - 尝试登录我的 Elementary OS 密码时遇到挑战
- python - 如何通过 Scrapy 收集 jpeg
- javascript - 有没有办法让两个函数同名?
- python - 如何在 BeautifulSoup 4 中找到明文兄弟?
- r - 如何将特定的'NA'值(不是全部'NA')替换为R数据框中的特定数值?
- javascript - 添加第二个幻灯片后幻灯片停止工作