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

feat(cloudwatch): validate Dashboards with an end time must also have a start time #27124

Merged
merged 4 commits into from
Sep 20, 2023

Conversation

go-to-k
Copy link
Contributor

@go-to-k go-to-k commented Sep 13, 2023

This PR adds a validation for a start and an end in Dashboard.

It throws an error if you specify an end without a start.

While it is possible to deploy a dashboard with only an end time in CloudFormation, the setting will be ignored and the dashboard displayed with the default time period.

With this validation, we are stopping the faulty deployment early.
API Reference contains the following description and the user will not be aware of this situation.

If you specify a value for end, you must also specify a value for start.

https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/CloudWatch-Dashboard-Body-Structure.html

And each Widget in graph.ts also validates the same case.

https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-cloudwatch/lib/graph.ts#L245-L247


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the p2 label Sep 13, 2023
@aws-cdk-automation aws-cdk-automation requested a review from a team September 13, 2023 05:52
@github-actions github-actions bot added the admired-contributor [Pilot] contributed between 13-24 PRs to the CDK label Sep 13, 2023
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 13, 2023
Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

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

Thanks 👍
Just a minor change on the message.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 13, 2023
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 14, 2023
@mrgrain mrgrain changed the title chore(cloudwatch): add validation for start and end in dashboard fix(cloudwatch): add validation for start and end in dashboard Sep 19, 2023
@mrgrain
Copy link
Contributor

mrgrain commented Sep 19, 2023

@go-to-k Is this failing in CFN if end is provided without start?
Code looks good. Just trying to understand what's going on here.

aws-cdk-automation

This comment was marked as outdated.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 19, 2023
@mrgrain mrgrain changed the title fix(cloudwatch): add validation for start and end in dashboard fix(cloudwatch): deployment fails when a Dashboard defines an end time without a start time Sep 19, 2023
@mrgrain mrgrain changed the title fix(cloudwatch): deployment fails when a Dashboard defines an end time without a start time fix(cloudwatch): deployment fails when a Dashboard defines an end time without a start time Sep 19, 2023
@mrgrain mrgrain changed the title fix(cloudwatch): deployment fails when a Dashboard defines an end time without a start time fix(cloudwatch): deployment fails for Dashboard with an end time but without a start time Sep 19, 2023
@mrgrain mrgrain added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Sep 19, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review September 19, 2023 14:32

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

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 19, 2023
@go-to-k
Copy link
Contributor Author

go-to-k commented Sep 20, 2023

@mrgrain

Is this failing in CFN if end is provided without start?

No, the deployment succeeds by CFn. Also manual setting without CFn in CloudWatch Dashboard console succeeds.

But that setting is ignored and the dashboard is displayed with the default time period.

I think the deployment should be stopped because the API Reference contains the following description and the user will not be aware of this situation.

If you specify a value for end, you must also specify a value for start.

https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/CloudWatch-Dashboard-Body-Structure.html

And each Widget in graph.ts also validates the same case.

https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-cloudwatch/lib/graph.ts#L245-L247

@mrgrain
Copy link
Contributor

mrgrain commented Sep 20, 2023

Thank you, save I fully agree. We need to record these explanations on the PR for future reference.

@mrgrain mrgrain changed the title fix(cloudwatch): deployment fails for Dashboard with an end time but without a start time fix(cloudwatch): Dashboards with an end time must also have a start time Sep 20, 2023
@mrgrain mrgrain changed the title fix(cloudwatch): Dashboards with an end time must also have a start time feat(cloudwatch): Dashboards with only an end time must also have a start time Sep 20, 2023
@mrgrain mrgrain changed the title feat(cloudwatch): Dashboards with only an end time must also have a start time feat(cloudwatch): Dashboards with an end time must also have a start time Sep 20, 2023
@mrgrain mrgrain changed the title feat(cloudwatch): Dashboards with an end time must also have a start time feat(cloudwatch): validate Dashboards with an end time must also have a start time Sep 20, 2023
@mrgrain mrgrain added the pr-linter/exempt-readme The PR linter will not require README changes label Sep 20, 2023
@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 20, 2023
@mergify
Copy link
Contributor

mergify bot commented Sep 20, 2023

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: 0ee4a94
  • 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 097bd0f into aws:main Sep 20, 2023
9 checks passed
@mergify
Copy link
Contributor

mergify bot commented Sep 20, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
admired-contributor [Pilot] contributed between 13-24 PRs to the CDK p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-readme The PR linter will not require README changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants