Skip to content

fsx: hour validation in LustreMaintenanceTime is not correct #30341

@mazyu36

Description

@mazyu36

Describe the bug

The validate method in the LustreMaintenanceTime checks hour property between 0 and 24.

if (!Number.isInteger(hour) || hour < 0 || hour > 24) {

But hour property should be between 0 and 23.

The following is a quotation from the CloudFormation docs.

HH is the zero-padded hour of the day (0-23), and MM is the zero-padded minute of the hour.

Expected Behavior

Should be validation error when hour property is set to 24.

Current Behavior

No validation error when hour property is set to 24.
But error occurs when deploy phase.

image

Reproduction Steps

import { Vpc } from 'aws-cdk-lib/aws-ec2';
import { App, RemovalPolicy, Stack } from 'aws-cdk-lib';
import { LustreDeploymentType, LustreFileSystem, LustreDataCompressionType, LustreMaintenanceTime, Weekday } from 'aws-cdk-lib/aws-fsx';

const app = new App();

const stack = new Stack(app, 'FsxLustre');

const vpc = new Vpc(stack, 'VPC', { restrictDefaultSecurityGroup: false });

const storageCapacity = 1200;
const lustreConfiguration = {
  deploymentType: LustreDeploymentType.SCRATCH_2,
  dataCompressionType: LustreDataCompressionType.LZ4,
  weeklyMaintenanceStartTime: new LustreMaintenanceTime({ day: Weekday.TUESDAY, hour: 24, minute: 0 }),
};
new LustreFileSystem(stack, 'FsxLustreFileSystem', {
  lustreConfiguration,
  storageCapacityGiB: storageCapacity,
  vpc,
  vpcSubnet: vpc.privateSubnets[0],
  removalPolicy: RemovalPolicy.DESTROY,
});

Possible Solution

Change validate method like this.

  private validate(hour: number, minute: number) {
    if (!Number.isInteger(hour) || hour < 0 || hour > 23) {  // change 24->23
      throw new Error('Maintenance time hour must be an integer between 0 and 23');  // change 24->23
    }

  // omit

Additional Information/Context

Even if you set the value to 24 for hour, it results in a deployment error, so in my understanding, the above change is not a breaking change.

CDK CLI Version

2.143.0

Framework Version

No response

Node.js Version

v20.6.0

OS

MacOS

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-fsxRelated to Amazon FSxbugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions