Skip to content
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

fix(AWS sqs): Ensure only ARN in plain string form is allowed as direct sqs event assignment #10263

Merged
merged 4 commits into from Nov 26, 2021

Conversation

sdas13
Copy link
Contributor

@sdas13 sdas13 commented Nov 23, 2021

Closes: #9723

@sdas13 sdas13 changed the title fix(AWS sqs): Ensure directly passing CF intrinsic functions to SQS is allowed fix(AWS sqs): Ensure directly passing CF intrinsic functions to sqs is allowed Nov 23, 2021
@codecov
Copy link

codecov bot commented Nov 23, 2021

Codecov Report

Merging #10263 (04cb05f) into master (ce66591) will decrease coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10263      +/-   ##
==========================================
- Coverage   85.39%   85.39%   -0.01%     
==========================================
  Files         339      339              
  Lines       13840    13854      +14     
==========================================
+ Hits        11819    11830      +11     
- Misses       2021     2024       +3     
Impacted Files Coverage Δ
lib/plugins/aws/package/compile/events/sqs.js 100.00% <ø> (ø)
lib/plugins/aws/deploy/lib/createStack.js 94.00% <0.00%> (-3.88%) ⬇️
lib/plugins/aws/lib/updateStack.js 94.80% <0.00%> (-3.81%) ⬇️
lib/plugins/aws/package/compile/events/s3/index.js 98.54% <0.00%> (ø)
lib/plugins/aws/provider.js 94.97% <0.00%> (+0.65%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce66591...04cb05f. Read the comment docs.

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdas13 thanks for contribution! Please mark PR as ready for review, once it's finalized.

@sdas13 sdas13 marked this pull request as ready for review November 23, 2021 09:20
@sdas13 sdas13 requested a review from medikoo November 24, 2021 09:42
Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdas13 thanks for picking this up. Still proposed implementation doesn't reflect the agreed solution (as outlined here: #9723 (comment))

If for some reason you do not agree with that, best if you elaborate in the issue first

@sdas13
Copy link
Contributor Author

sdas13 commented Nov 26, 2021

Hey @medikoo
Thanks for the feedback. I will use awsArnString at the top level.

{ $ref: '#/definitions/awsArn' },

But in case of passing CF intrinsic functions directly to sqs input, there will be a configuration warning that should have required property 'arn' but the Type Error will be still there, since EventSourceArn will become undefined

if (EventSourceArn['Fn::GetAtt']) {

Should it be handled as well or we just fix the schema?

@medikoo
Copy link
Contributor

medikoo commented Nov 26, 2021

But in case of passing CF intrinsic functions directly to sqs input, there will be a configuration warning that should have required property 'arn' but the Type Error will be still there, since EventSourceArn will become undefined

@sdas13 Can you provide an example of a configuration that will raise this problem? Sorry, from description it's not perfectly to me

@sdas13
Copy link
Contributor Author

sdas13 commented Nov 26, 2021

functions:
    eventHandler:
       handler: handler.test
       events:
          - sqs: !ImportValue MyExportedQueueArnId               

@medikoo this configuration would throw a Type Error

@medikoo
Copy link
Contributor

medikoo commented Nov 26, 2021

@medikoo this configuration would throw a Type Error

And that's ok, as that'll become invalid by schema - solution is to update schema so only ARN in plain string form is allowed as direct sqs event assignment, and CF intrinsic functions are supported only in object configuration form (so when arn is defined as a property on object assigned to sqs)

@sdas13
Copy link
Contributor Author

sdas13 commented Nov 26, 2021

thanks @medikoo I will update the PR

@sdas13 sdas13 changed the title fix(AWS sqs): Ensure directly passing CF intrinsic functions to sqs is allowed fix(AWS sqs): Ensure only ARN in plain string form is allowed as direct sqs event assignment Nov 26, 2021
@sdas13 sdas13 requested a review from medikoo November 26, 2021 16:42
Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @sdas13 ! That looks great :)

@medikoo medikoo merged commit f7bbd17 into serverless:master Nov 26, 2021
@sdas13
Copy link
Contributor Author

sdas13 commented Nov 26, 2021

Thank you for your guidance @medikoo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: Cannot read property 'Fn::GetAtt' of undefined
2 participants