Open antoniocaiazzo opened 2 years ago
Update configValidationMode: off
to configValidationMode: error
, and see what happens then
Same error. It happens during the creation of the CloudFormation stack on AWS, the serverless.yml schema checks all passes.
On Wed, 7 Sept 2022 at 16:14, Mariusz Nowak @.***> wrote:
Assigned #11378 https://github.com/serverless/serverless/issues/11378 to @antoniocaiazzo https://github.com/antoniocaiazzo.
— Reply to this email directly, view it on GitHub https://github.com/serverless/serverless/issues/11378#event-7339329132, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANGMYUNE5JC5I7ZBJ6IQOTV5CPKZANCNFSM6AAAAAAQGZX4KU . You are receiving this because you were assigned.Message ID: @.***>
--
Antonio Caiazzo Senior Fullstack Software Engineer
+44 78030 99033 LinkedIn http://www.linkedin.com/in/antoniocaiazzo
Are you certain it's a bug?
Is the issue caused by a plugin?
Are you using the latest v3 release?
Is there an existing issue for this?
Issue description
I've been getting an error while deploying a service with CloudFront configuration:
`CREATE_FAILED: CloudFrontDistribution (AWS::CloudFront::Distribution) Properties validation failed for resource CloudFrontDistribution with message:
/DistributionConfig/DefaultCacheBehavior/CachePolicyId: expected type: String, found: JSONObject`
Digging into the code the problem seems to arise when some functions use
cachePolicy
with a name from the ones configured underprovider.cloudFront.cachePolicies
and others don't. See service configuration for an example.This is the problematic part of the generated CloudFront template:
"CachePolicyId": { "0": "6", "1": "5", "2": "8", "3": "3", "4": "2", "5": "7", "6": "e", "7": "a", "8": "-", "9": "f", "10": "8", "11": "9", "12": "d", "13": "-", "14": "4", "15": "f", "16": "a", "17": "b", "18": "-", "19": "a", "20": "6", "21": "3", "22": "d", "23": "-", "24": "7", "25": "e", "26": "8", "27": "8", "28": "6", "29": "3", "30": "9", "31": "e", "32": "5", "33": "8", "34": "f", "35": "6", "Ref": "CloudFrontCachePolicyDefaultCachePolicy" },
As you can see from the serverless configuration, the
headers
function doesn't use acachePolicy
, so it gets assigned the defaultCachePolicyId: '658327ea-f89d-4fab-a63d-7e88639e58f6'
. After this step, the behavior is then merged into an existing one, which already has aCachePolicyId: { "Ref": "CloudFrontCachePolicyDefaultCachePolicy" }
property, causing theextendDeep()
function to try and merge a string with an object.I'm not sure of the right way to fix this, so I've opened a new issue (didn't find a similar one already opened). In my case I had forgotten to add the
cachePolicy
name to one of my functions, but I imagine the default cache policy id it's a feature that's supposed to work for the people of need it.Service configuration (serverless.yml) content
Command name and used flags
sls --stage staging deploy
Command output
Environment information