我有一个Cloudformation模板,用于设置AWS :: CloudFront :: Distribution和AWS :: S3 :: Bucket。不幸的是,对GET / subdirectory的请求以403响应。如何配置Cloudformation模板以使GET / subdirectory为/subdirectory/index.html服务?
我的Cloudfront配置如下:
CloudFrontDistribution:
Type: 'AWS::CloudFront::Distribution'
Properties:
DistributionConfig:
Aliases:
- !FindInMap [Domain, !Ref Stage, Domain]
ViewerCertificate:
AcmCertificateArn: !Ref Cert
SslSupportMethod: sni-only
CustomErrorResponses:
- ErrorCode: 403 # not found
ResponseCode: 404
ResponsePagePath: !Ref ErrorPagePath
DefaultCacheBehavior:
AllowedMethods:
- GET
- HEAD
- OPTIONS
CachedMethods:
- GET
- HEAD
- OPTIONS
Compress: true
DefaultTTL: 3600 # in seconds
ForwardedValues:
Cookies:
Forward: none
QueryString: false
MaxTTL: 86400 # in seconds
MinTTL: 60 # in seconds
TargetOriginId: s3origin
ViewerProtocolPolicy: redirect-to-https
DefaultRootObject: !Ref DefaultRootObject
Enabled: true
HttpVersion: http2
Origins:
- DomainName: !GetAtt 'S3Bucket.DomainName'
Id: s3origin
S3OriginConfig:
OriginAccessIdentity: !Sub 'origin-access-identity/cloudfront/${CloudFrontOriginAccessIdentity}'
PriceClass: 'PriceClass_All'
除了对GET / subdirectory的请求外,所有其他操作都有效。>>
我也尝试过:
- DomainName: !GetAtt 'S3Bucket.RegionalDomainName' Id: s3origin S3OriginConfig: OriginProtocolPolicy: http-only
但是我在
Property TemplateURL cannot be empty.
上收到错误AWS::CloudFormation::Stack
。
我有一个Cloudformation模板,用于设置AWS :: CloudFront :: Distribution和AWS :: S3 :: Bucket。不幸的是,对GET / subdirectory的请求响应为403。如何配置...