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(fsx): construct for NetApp ONTAP file system #30849

Closed
wants to merge 14 commits into from
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import { App, Duration, RemovalPolicy, Stack } from 'aws-cdk-lib';
import * as integ from '@aws-cdk/integ-tests-alpha';
import * as fsx from 'aws-cdk-lib/aws-fsx';

const app = new App();

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

const vpc = new ec2.Vpc(stack, 'Vpc');

new fsx.OntapFileSystem(stack, 'OntapMultiAzFileSystem', {
vpc,
vpcSubnets: vpc.privateSubnets,
storageCapacityGiB: 5120,
ontapConfiguration: {
automaticBackupRetention: Duration.days(7),
dailyAutomaticBackupStartTime: new fsx.DailyAutomaticBackupStartTime({
hour: 1,
minute: 0,
}),
deploymentType: fsx.OntapDeploymentType.MULTI_AZ_2,
diskIops: 15360,
endpointIpAddressRange: '192.168.39.0/24',
fsxAdminPassword: 'fsxPassword1',
haPairs: 1,
prefferredSubnet: vpc.privateSubnets[0],
routeTables: [vpc.privateSubnets[0].routeTable, vpc.privateSubnets[1].routeTable],
throughputCapacity: 384,
weeklyMaintenanceStartTime: new fsx.MaintenanceTime({
day: fsx.Weekday.SUNDAY,
hour: 1,
minute: 0,
}),
},
removalPolicy: RemovalPolicy.DESTROY,
});

new fsx.OntapFileSystem(stack, 'OntapSingleAzFileSystem', {
vpc,
vpcSubnets: [vpc.privateSubnets[0]],
storageCapacityGiB: 5120,
ontapConfiguration: {
automaticBackupRetention: Duration.days(7),
dailyAutomaticBackupStartTime: new fsx.DailyAutomaticBackupStartTime({
hour: 1,
minute: 0,
}),
deploymentType: fsx.OntapDeploymentType.SINGLE_AZ_2,
diskIops: 76800,
fsxAdminPassword: 'fsxPassword1',
haPairs: 5,
throughputCapacityPerHaPair: 1536,
weeklyMaintenanceStartTime: new fsx.MaintenanceTime({
day: fsx.Weekday.SUNDAY,
hour: 1,
minute: 0,
}),
},
removalPolicy: RemovalPolicy.DESTROY,
});

new integ.IntegTest(app, 'FsxForOntapTest', {
testCases: [stack],
});
3 changes: 2 additions & 1 deletion packages/aws-cdk-lib/aws-fsx/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export * from './daily-automatic-backup-start-time';
export * from './file-system';
export * from './fsx.generated';
export * from './lustre-file-system';
export * from './maintenance-time';
export * from './maintenance-time';
export * from './ontap-file-system';
73 changes: 73 additions & 0 deletions packages/aws-cdk-lib/aws-fsx/lib/maintenance-time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,79 @@ export class LustreMaintenanceTime {
return numberString;
}

/**
* Validation needed for the values of the maintenance time.
*/
private validate(hour: number, minute: number) {
if (!Number.isInteger(hour) || hour < 0 || hour > 23) {
throw new Error('Maintenance time hour must be an integer between 0 and 23');
}
if (!Number.isInteger(minute) || minute < 0 || minute > 59) {
throw new Error('Maintenance time minute must be an integer between 0 and 59');
}
}
}

/**
* Properties required for setting up a weekly maintenance time
*/
export interface MaintenanceTimeProps {
/**
* The day of the week for maintenance to be performed.
*/
readonly day: Weekday;
/**
* The hour of the day (from 0-23) for maintenance to be performed.
*/
readonly hour: number;
/**
* The minute of the hour (from 0-59) for maintenance to be performed.
*/
readonly minute: number;
}

/**
* Class for scheduling a weekly maintenance time.
*/
export class MaintenanceTime {
/**
* The day of the week for maintenance to be performed.
*/
private readonly day: Weekday;
/**
* The hour of the day (from 00-23) for maintenance to be performed.
*/
private readonly hour: string;
/**
* The minute of the hour (from 00-59) for maintenance to be performed.
*/
private readonly minute: string;

constructor(props: MaintenanceTimeProps) {
this.validate(props.hour, props.minute);

this.day = props.day;
this.hour = this.getTwoDigitString(props.hour);
this.minute = this.getTwoDigitString(props.minute);
}
/**
* Converts a day, hour, and minute into a timestamp as used by FSx for Lustre's weeklyMaintenanceStartTime field.
*/
public toTimestamp(): string {
return `${this.day.valueOf()}:${this.hour}:${this.minute}`;
}

/**
* Pad an integer so that it always contains at least 2 digits. Assumes the number is a positive integer.
*/
private getTwoDigitString(n: number): string {
const numberString = n.toString();
if (numberString.length === 1) {
return `0${n}`;
}
return numberString;
}

/**
* Validation needed for the values of the maintenance time.
*/
Expand Down
Loading
Loading