Skip to content

Conversation

Imadnajam
Copy link

Reason for this change

  • Fixes incorrect validation message for hour range (previously showed "0-24" instead of "0-23")
  • Adds support for parsing time strings in "HH:MM" format
  • Implements sensible defaults (22:00 UTC) for backup start time
  • Improves developer experience with better input validation and formatting

Description of changes

  1. Core Changes:

    • Added static fromString() method to parse "HH:MM" formatted time strings
    • Implemented default values (hour: 22, minute: 0) when no props are provided
    • Updated validation logic with correct hour range (0-23)
    • Improved string padding using padStart() instead of manual concatenation
  2. Design Decisions:

    • Maintained backward compatibility with existing constructor
    • Chose 22:00 UTC (default) as it's typically off-peak for most regions
    • Implemented strict validation for both constructor and string parsing
    • Used regex pattern matching for string input validation
  3. AWS Use Cases Enabled:

    • Simplifies backup scheduling for:
      • Amazon RDS automated backups
      • Amazon EFS backup configurations
      • AWS Backup plan schedules
    • Provides reusable time validation for:
      • CloudFormation custom resources
      • Lambda-backed custom constructs

Describe any new or updated permissions being added

No new permissions are required as this change only affects client-side validation and formatting logic.

Description of how you validated changes

  1. Unit Testing:

    • Added 15 new test cases covering:
      • Default value behavior
      • Valid/invalid time inputs
      • String parsing functionality
      • Edge cases (00:00, 23:59)
      • Error conditions
  2. Manual Validation:

    • Verified integration with existing CDK constructs
    • Tested with AWS Backup plan creation
    • Confirmed backward compatibility

Added proper default values (hour:22, minute:0)

Fixed validation error message for hour

Added fromString static method for parsing time strings

Improved JSDoc documentation

Added comprehensive unit tests

Simplified getTwoDigitString using padStart

Made props optional in the interface
@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 labels Apr 15, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team April 15, 2025 10:48
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 fails with the following errors:

❌ The title prefix of this pull request must be one of "feat|fix|build|chore|ci|docs|style|refactor|perf|test|revert"
❌ The first word of the pull request title should not be capitalized. If the title starts with a CDK construct, it should be in backticks "``".
❌ Pull requests from `main` branch of a fork cannot be accepted. Please reopen this contribution from another branch on your fork. For more information, see https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md#step-4-pull-request.

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

Your pull request must be based off of a branch in a personal account (not an organization owned account, and not the main branch). You must also have the setting enabled that allows the CDK team to push changes to your branch (this setting is enabled by default for personal accounts, and cannot be enabled for organization owned accounts). The reason for this is that our automation needs to synchronize your branch with our main after it has been approved, and we cannot do that if we cannot push to your branch.

Copy link
Contributor

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 Apr 15, 2025
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 9a07df3
  • Result: FAILED
  • Build Logs (available for 30 days)

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants