-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sam: CfnFunction does not generate events in template after v2.87.0 #26637
Comments
I can reproduce this on Python as well, thanks for reporting |
Because of a mistake introduced into the SAM schema, the `AlexaSkill` event type doesn't have any required properties anymore. When the `CfnFunction` is trying all the different event types in the type union that it supports, it will go through every type in alphabetical order and pick the first type that doesn't fail its validation. After the schema change, the first type (`Alexa` which starts with an `A`) would therefore accept all types: no required fields, and for JavaScript compatibility purposes we allow superfluous fields, and so we pick a type that doesn't render anything. This change reorders the alternatives in the union such that stronger types are tried first. `HttpApiEvent` and `AlexaSkillEvent` both have no required properties, and this now reverses the problem: `AlexaSkillEvent` can no longer be specified because `HttpApiEvent` will match first. But that's the more common use case, so better for now, while we wait for the spec fix to come in, to prefer the HTTP API. Relates to #26637.
Because of a mistake introduced into the SAM schema, the `AlexaSkill` event type doesn't have any required properties anymore. When the `CfnFunction` is trying all the different event types in the type union that it supports, it will go through every type in alphabetical order and pick the first type that doesn't fail its validation. After the schema change, the first type (`Alexa` which starts with an `A`) would therefore accept all types: no required fields, and for JavaScript compatibility purposes we allow superfluous fields, and so we pick a type that doesn't render anything. This change reorders the alternatives in the union such that stronger types are tried first. `HttpApiEvent` and `AlexaSkillEvent` both have no required properties, and this now reverses the problem: `AlexaSkillEvent` can no longer be specified because `HttpApiEvent` will match first. But that's the more common use case, so better for now, while we wait for the spec fix to come in, to prefer the HTTP API. Relates to #26637. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
A workaround using Raw overrides: writeFunction.AddPropertyOverride($"Events.{sqsEventSourceName}.Properties.Queue", queue.QueueArn)
writeFunction.AddPropertyOverride($"Events.{sqsEventSourceName}.Properties.BatchSize", 1000) |
This has been fixed by #26679 and cdklabs/awscdk-service-spec#459 |
|
Describe the bug
Upgrading from v2.87.0 to v2.89.0 causes the events properties for a CfnFunction to no longer be generated:
Expected Behavior
It should generate this template.json
Current Behavior
But it generates this template.json missing the data in MyAPI.Events.GetResource.Properties:
Reproduction Steps
Creating this same stack that worked in 2.87.0 has issues in 2.89.0
Possible Solution
This won't deploy to AWS as the template.json isn't valid any more
Additional Information/Context
No response
CDK CLI Version
2.89.0
Framework Version
No response
Node.js Version
18.16.1
OS
macOS Ventura 13.5
Language
Typescript
Language Version
Typescript (4.7.4)
Other information
No response
The text was updated successfully, but these errors were encountered: