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(scheduler-targets-alpha): create a role per target instead of singleton schedule target role #31895

Merged
merged 15 commits into from
Nov 1, 2024

Conversation

gracelu0
Copy link
Contributor

@gracelu0 gracelu0 commented Oct 25, 2024

Issue # (if applicable)

Tracking #31785.

Reason for this change

The current logic for creating a schedule target execution role uses a hash on the targetArn to determine if there is an existing role in the stack. Currently if the targetArn contains 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

  • Use 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

@gracelu0 gracelu0 marked this pull request as draft October 25, 2024 01:59
@aws-cdk-automation aws-cdk-automation requested a review from a team October 25, 2024 01:59
@github-actions github-actions bot added the p2 label Oct 25, 2024
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Oct 25, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a 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.

@aws-cdk-automation aws-cdk-automation dismissed their stale review October 29, 2024 19:01

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@@ -38,8 +39,8 @@ const message = integ.assertions.awsApiCall('SQS', 'receiveMessage', {
// Verifies that expected message is received from the queue
message.assertAtPath(
'Messages.0.Body',
ExpectedResult.exact(payload),
ExpectedResult.stringLikeRegexp(payload),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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\\\"\"}"
}

Copy link
Contributor

Choose a reason for hiding this comment

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

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)?

Copy link
Contributor

Choose a reason for hiding this comment

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

After looking into this further, I believe ExpectedResult.exact is not fully implemented (code).

@gracelu0 gracelu0 marked this pull request as ready for review October 29, 2024 21:27
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Oct 31, 2024
samson-keung
samson-keung previously approved these changes Nov 1, 2024
Copy link
Contributor

@samson-keung samson-keung left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you

Copy link
Contributor

mergify bot commented Nov 1, 2024

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-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 1, 2024
@samson-keung samson-keung self-requested a review November 1, 2024 03:38
@samson-keung samson-keung dismissed their stale review November 1, 2024 03:47

missed a comment

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 1, 2024
Copy link
Contributor

mergify bot commented Nov 1, 2024

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-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 1, 2024
Copy link
Contributor

mergify bot commented Nov 1, 2024

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).

Copy link
Contributor

mergify bot commented Nov 1, 2024

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-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: daea128
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit aee1b30 into aws:main Nov 1, 2024
12 checks passed
Copy link
Contributor

mergify bot commented Nov 1, 2024

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).

Copy link

github-actions bot commented Nov 1, 2024

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution/core This is a PR that came from AWS. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants