-
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
chore(scheduler-targets-alpha): imported function as a LambdaInvoke target results in synth-time error #29615
chore(scheduler-targets-alpha): imported function as a LambdaInvoke target results in synth-time error #29615
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
Exemption Request: This PR just changes validation behavior and does not affect the integration test. The changes are covered by unit tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thank you for your contribution! Did a quick review and I'm not sure if this is the best way to fix this, see comment.
The proposed solution in the issue was to skip validations if sameEnvironment is set to true on the imported lambda. However, I did not adopt this solution because the sameEnvironment attribute is not stored in the Lambda function itself and cannot be used to toggle the validation.
Agree, that doesn't work for now. Will do a deeper dive to see if there is a way to expose this property
*/ | ||
export function sameEnvDimension(dim1: string, dim2: string) { | ||
return [TokenComparison.SAME, TokenComparison.BOTH_UNRESOLVED].includes(Token.compareStrings(dim1, dim2)); | ||
return [TokenComparison.SAME, TokenComparison.ONE_UNRESOLVED, TokenComparison.BOTH_UNRESOLVED].includes(Token.compareStrings(dim1, dim2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I'm wrong but this essentially negates the need for the validation as, I believe now, all cases will return true.
EDIT: I see that TokenComparison.DIFFERENT
can also be returned which would return false for this function. I'm still not sure if this is the best way to go about resolving this issue as it could change more things than just fixing this issue. Will consult with the team
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment: #29615 (comment)
Hi Aayush, thank you for your review and comment. Let me check it. |
@aaythapa As you mentioned, this change is more of a fundamental solution to just resolve this issue rather than a minimum change. However, the proposed addition of the |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
@aaythapa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I'm not sure I even feel this validation is worth while or that it should have been added to events targets. I probably would have turned down that PR when it initially came in if I had been the reviewer.
I'm curious what the user experience for this failure is if the environments aren't the same. Is the failure clear? Is it a fast failure at deploy time? If so, I'd prefer to delete this altogether. If not, your change is probably fine but we do need to have the conflicts resolved prior to being able to accept this so I'm putting it in changes requested for either path.
Hi @anan-k, just pinging on this PR again to see if you're still interested in working on it. There's just the merge conflicts and comment by Kendra to be addressed. |
Hi @paulhcsun, thank you for pinging to me. Thank you @TheRealAmazonKendra for the comment. Based on the comments received, I will reconsider the impact on users when validation fails and the methods for correction. |
I agree with @TheRealAmazonKendra that this validation is not worth while, even though it was good intention to let the customer know early that target in a different environment is not supported. Reasons:
@anan-k I will remove this check in all targets if you are not working on it already. |
Closing this as a new one is opened for this. |
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
Closes #29284
Reason for this change
When a lambda function in another stack is imported by ARN and used as a
LambdaInvoke
target, a synth-time error occurred due to an issue with environment (account or region) validationsameEnvDimension
. The validation compares two environment values such as account or region and returns true/false. The validation passes only if the values are the same (SAME
) or both are unresolved (BOTH_UNRESOLVED
), but since the region of the imported function was unresolved, it resulted inONE_UNRESOLVED
, causing the error. To resolve this, I modified the validation to allow theONE_UNRESOLVED
case.The proposed solution in the issue was to skip validations if
sameEnvironment
is set to true on the imported lambda. However, I did not adopt this solution because thesameEnvironment
attribute is not stored in the Lambda function itself and cannot be used to toggle the validation.Description of changes
I changed the
sameEnvDimension
function to allow the case where either one of the parameters is unresolved.I made these changes based on the implementation in aws-cdk-lib/aws-events-targets/lib/util.ts
Description of how you validated changes
I added a unit test for the
LambdaInvoke
target to cover the case when an imported lambda function is used.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license