Thanks! It helped. In case it would help anyone, here’s the updated json. I still have to check some things but for now it works.
{
"CloudFrontDistribution": {
"Type" : "AWS::CloudFront::Distribution",
"Properties" : {
"DistributionConfig" : {
"DefaultRootObject" : "",
"Enabled" : true,
"DefaultCacheBehavior" : {
"AllowedMethods" : ["GET", "HEAD"],
"CachedMethods" : ["HEAD", "GET"],
"ForwardedValues" : {
"QueryString" : true
},
"MinTTL" : "0",
"TargetOriginId" : "MY_SERVICE-${opt:stage}-serverlessdeploymentbucket-s3.amazonaws.com",
"ViewerProtocolPolicy" : "allow-all"
},
"CacheBehaviors" : [
{
"AllowedMethods" : ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"],
"CachedMethods" : ["HEAD", "GET"],
"ForwardedValues" : {
"QueryString" : true
},
"MinTTL" : "0",
"PathPattern" : "*",
"TargetOriginId" : "MY_FUNCTION-${opt:stage}-api-gateway",
"ViewerProtocolPolicy" : "allow-all"
}
],
"Origins" : [
{
"CustomOriginConfig" : {
"HTTPSPort" : "443",
"OriginProtocolPolicy" : "https-only"
},
"DomainName" : {
"Fn::Join": [
"",
[
{
"Ref": "ApiGatewayRestApi"
},
".execute-api.us-west-2.amazonaws.com"
]
]
},
"Id" : "MY_FUNCTION-${opt:stage}-api-gateway",
"OriginPath" : ""
},
{
"DomainName" : {
"Fn::Join": ["", [{"Ref": "ServerlessDeploymentBucket"}, ".s3.amazonaws.com"]]
},
"Id" : "MY_SERVICE-${opt:stage}-serverlessdeploymentbucket-s3.amazonaws.com",
"OriginPath" : "",
"S3OriginConfig" : {}
}
],
"PriceClass" : "PriceClass_100"
}
}
}
}