fix(scheduler-targets-alpha): create a role per target instead of singleton schedule target role#31895
Conversation
23306b4 to
8e5659a
Compare
aws-cdk-automation
left a comment
There was a problem hiding this comment.
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.
bd4cfc4 to
e8f20c4
Compare
e8f20c4 to
564ae30
Compare
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
| message.assertAtPath( | ||
| 'Messages.0.Body', | ||
| ExpectedResult.exact(payload), | ||
| ExpectedResult.stringLikeRegexp(payload), |
There was a problem hiding this comment.
When I ran this test with exact it would fail the assertion. From logs:
INFO Testing equality between "test" and "{\"$Exact\":\"test\"}"
INFO Assertion Failed:
{
"failed": true,
"assertion": "{\"status\":\"fail\",\"message\":\"!! Expected type object but received string\\n\\\"test\\\"\"}"
}
There was a problem hiding this comment.
From the logs, it sounds like the message in the queue is the text test, as expected. I wonder if the assertion logic is correct. Can you verify if the message in the queue is indeed test (without quotes)?
There was a problem hiding this comment.
After looking into this further, I believe ExpectedResult.exact is not fully implemented (code).
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
Tracking #31785.
Reason for this change
The current logic for creating a schedule target execution role uses a hash on the
targetArnto determine if there is an existing role in the stack. Currently if thetargetArncontains token values (e.g. intrinsic functions),stack.resolve(targetArn).toString()is used to convert the tokenized ARN into a string. However this always results in[object Object]which then gets hashed, meaning the same role is used for any target where the ARN passed in is not a pure string. This does not follow principle of least privilege, and a singleton role used across multiple different targets/target types can be confusing for the customer to manage.Description of changes
JSON.stringify()instead of.toString()to produce unique hash (and thus create new role) per target.Description of how you validated changes
Updated unit tests and integration tests
Checklist
BREAKING CHANGE: Schedule Target will reuse role if target is re-used across schedules. This change triggered replacement of existing roles for Schedule as logical ID of the roles are changed.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license