-
Notifications
You must be signed in to change notification settings - Fork 4k
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
(aws-sam): cannot generate string policies for CfnFunction #12854
Comments
@spalladino you're missing a bunch of required properties in your code, I'm surprised it compiles... This: new sam.CfnFunction(this, 'MyFunction', {
codeUri: {
bucket: 'my-bucket',
key: 'my-key',
},
runtime: 'nodejs-12.x',
handler: 'index.handler',
policies: 'AWSLambdaExecute',
}); Produces this for me: Transform: AWS::Serverless-2016-10-31
MyFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri:
Bucket: my-bucket
Key: my-key
Handler: index.handler
Runtime: nodejs-12.x
Policies: AWSLambdaExecute
Metadata:
aws:cdk:path: TestStack/MyFunction |
Oh, I see what you're saying. The problem is for an array of strings, not a single string. Let me see. |
Sorry, I guess I went with a too minimal example - I only included the property that was causing trouble. Let me know if you need a more complete example to reproduce. |
No, I'm good, thanks. Let me dig into this one a little bit more. I suspect it might be a bug with our code generation. |
If I had to bet, I'd say the culprit is the |
I think you're exactly right. I feel like I'm barely needed here 😃. |
Which means we need to make sure that a string is not a valid object in our validation logic. |
…red properties in a union In our code generation, in the validation functions for CFN complex types, we never checked whether the argument we received is an object. Because of that, passing a string was actually a correct candidate for a union with a complex type that had no required properties. Fix that by checking for that error explicitly, which removes the complex type without required properties from the candidates when a string is passed. Fixes aws#12854
…red properties in a union In our code generation, in the validation functions for CFN complex types, we never checked whether the argument we received is an object. Because of that, passing a string was actually a correct candidate for a union with a complex type that had no required properties. Fix that by checking for that error explicitly, which removes the complex type without required properties from the candidates when a string is passed. Fixes aws#12854
…red properties in a union (#12954) In our code generation, in the validation functions for CFN complex types, we never checked whether the argument we received is an object. Because of that, passing a string was actually a correct candidate for a union with a complex type that had no required properties. Fix that by checking for that error explicitly, which removes the complex type without required properties from the candidates for the union type when a string is passed. Fixes #12854 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
…red properties in a union (aws#12954) In our code generation, in the validation functions for CFN complex types, we never checked whether the argument we received is an object. Because of that, passing a string was actually a correct candidate for a union with a complex type that had no required properties. Fix that by checking for that error explicitly, which removes the complex type without required properties from the candidates for the union type when a string is passed. Fixes aws#12854 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
The property
CfnFunctionProps.policies
accepts a list of both objects and strings. However, when I try to generate a list with a string, an empty object is generated instead.Reproduction Steps
Running
cdk synth
with the following construct:What did you expect to happen?
What actually happened?
Environment
Other
Note that if I use a string, instead of a list of strings, the output is correct.
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: